blib/lib/Lemonldap/NG/Portal/Password/Combination.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 70 CC 6 SCAR 26.6
CC
6
Cov
0%
init
30.0
delegate
6.0
confirm
2.0
CRAP 14.3
1 package Lemonldap::NG::Portal::Password::Combination;
2  
3 use strict;
4 use Mouse;
5 use Lemonldap::NG::Portal::Main::Constants qw(
6 PE_OK
7 PE_ERROR
8 PE_FIRSTACCESS
9 );
10  
11 extends 'Lemonldap::NG::Portal::Password::Base';
12 with 'Lemonldap::NG::Portal::Lib::OverConf';
13  
14 our $VERSION = '2.0.16';
15  
16 has mods => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
17  
18 sub init {
19 my $self = shift;
20  
21 # Check if expression exists
22 unless ( $self->conf->{combination} ) {
23 $self->error('No combination found');
24 return 0;
25 }
26  
27 # Load all declared modules
28 my %mods;
29 foreach my $key ( keys %{ $self->conf->{combModules} } ) {
30 my $tmp;
31 my $mod = $self->conf->{combModules}->{$key};
32  
33 unless ( $mod->{type} and defined $mod->{for} ) {
34 $self->error("Malformed combination module $key");
35 return 0;
36 }
37  
38 # Only load modules used for UserDB
39 unless ( $mod->{for} == 1 ) {
40 $tmp =
41 $self->loadModule( "::Password::$mod->{type}", $mod->{over} );
42 unless ($tmp) {
43 $self->logger->notice("Unable to load Password::$mod->{type}");
44 next;
45 }
46 }
47  
48 # Store modules as array
49 $self->mods->{$key} = $tmp;
50 }
51 return $self->SUPER::init;
52 }
53  
54 sub delegate {
55 my ( $self, $req, $name, @args ) = @_;
56  
57 # The user might want to override which password DB is used with a macro
58 # This is useful when using SASL delegation in OpenLDAP
59 my $userDB =
60 $req->sessionInfo->{_cmbPasswordDB} || $req->sessionInfo->{_userDB};
61 unless ( $self->mods->{$userDB} ) {
62 $self->logger->error("No Password module available for $userDB");
63 return PE_ERROR;
64 }
65  
66 return $self->mods->{$userDB}->$name( $req, @args );
67 }
68  
69 sub confirm {
70 my ( $self, $req, @args ) = @_;
71 return $self->delegate( $req, "confirm", @args );
72 }
73  
74 sub modifyPassword {
75 my ( $self, $req, $pwd, %args ) = @_;
76 return $self->delegate( $req, "modifyPassword", $pwd, %args );
77 }
78  
79 1;