line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Bank::Natwest::CredentialsProvider::Constant; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
96187
|
use Carp; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
451
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
31
|
use vars qw( $VERSION ); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
3463
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Finance::Bank::Natwest::CredentialsProvider::Constant - Static credentials provider |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
CredentialsProvider module for static credentials. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $credentials = Finance::Bank::Natwest::CredentialsProvider::Constant->new( |
19
|
|
|
|
|
|
|
dob => '010179', uid => '0001', password => 'Password', pin => '4321' |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item B |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $credentials = Finance::Bank::Natwest::CredentialsProvider::Constant->new( |
29
|
|
|
|
|
|
|
dob => '010179', uid => '0001', password => 'Password', pin => '4321' |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Or we can combine the dob and uid together |
33
|
|
|
|
|
|
|
my $credentials = Finance::Bank::Natwest::CredentialsProvider::Constant->new( |
34
|
|
|
|
|
|
|
customer_no => '0101790001', password => 'Password', pin => '4321' |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
All the parameters are mandatory in both forms of the constructor. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new{ |
43
|
70
|
|
|
70
|
1
|
26523
|
my ($class, %opts) = @_; |
44
|
70
|
|
|
|
|
99
|
my %creds; |
45
|
|
|
|
|
|
|
|
46
|
70
|
100
|
100
|
|
|
719
|
croak "Must not provide both a customer number and dob/uid combo, stopped" if |
|
|
|
66
|
|
|
|
|
47
|
|
|
|
|
|
|
exists $opts{customer_no} and (exists $opts{dob} or exists $opts{uid}); |
48
|
|
|
|
|
|
|
|
49
|
64
|
100
|
|
|
|
180
|
if (exists $opts{customer_no}) { |
50
|
47
|
100
|
|
|
|
244
|
croak "Customer number must be 10 digits, stopped" unless |
51
|
|
|
|
|
|
|
$opts{customer_no} =~ /^\d{10}$/; |
52
|
43
|
|
|
|
|
320
|
($opts{dob}, $opts{uid}) = $opts{customer_no} =~ /(\d{6})(\d{4})/; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
60
|
100
|
66
|
|
|
431
|
croak "Must provide a customer number or dob/uid combo, stopped" unless |
56
|
|
|
|
|
|
|
exists $opts{dob} and exists $opts{uid}; |
57
|
|
|
|
|
|
|
|
58
|
52
|
100
|
|
|
|
249
|
croak "The dob must be 6 digits, stopped" unless |
59
|
|
|
|
|
|
|
$opts{dob} =~ /^\d{6}$/; |
60
|
48
|
100
|
|
|
|
229
|
croak "The uid must be 4 digits, stopped" unless |
61
|
|
|
|
|
|
|
$opts{uid} =~ /^\d{4}$/; |
62
|
|
|
|
|
|
|
|
63
|
44
|
100
|
|
|
|
145
|
croak "Must provide a password, stopped" unless |
64
|
|
|
|
|
|
|
exists $opts{password}; |
65
|
40
|
100
|
|
|
|
112
|
croak "Must provide a pin, stopped" unless |
66
|
|
|
|
|
|
|
exists $opts{pin}; |
67
|
|
|
|
|
|
|
|
68
|
38
|
100
|
100
|
|
|
253
|
croak "Password must be between 6 and 20 characters inclusive, stopped" if |
69
|
|
|
|
|
|
|
length $opts{password} < 6 or length $opts{password} > 20; |
70
|
|
|
|
|
|
|
|
71
|
34
|
100
|
|
|
|
165
|
croak "The pin must be 4 digits, stopped" unless |
72
|
|
|
|
|
|
|
$opts{pin} =~ /^\d{4}$/; |
73
|
|
|
|
|
|
|
|
74
|
30
|
|
|
|
|
925
|
return bless { creds => { dob => $opts{dob}, |
75
|
|
|
|
|
|
|
uid => $opts{uid}, |
76
|
|
|
|
|
|
|
password => [split/ */, $opts{password}], |
77
|
|
|
|
|
|
|
pin => [split/ */, $opts{pin}] |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
}, $class; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
5
|
|
|
5
|
0
|
18
|
sub get_start{} |
83
|
5
|
|
|
5
|
0
|
10
|
sub get_stop{} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub get_identity{ |
86
|
12
|
|
|
12
|
0
|
24
|
my ($self) = @_; |
87
|
|
|
|
|
|
|
|
88
|
12
|
|
|
|
|
98
|
return { uid => $self->{creds}{uid}, dob => $self->{creds}{dob} }; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub get_pinpass{ |
92
|
25
|
|
|
25
|
0
|
158
|
my ($self, $digits, $chars) = @_; |
93
|
|
|
|
|
|
|
|
94
|
25
|
100
|
|
|
|
119
|
croak "Must pass in a ref to an array with required password chars" unless |
95
|
|
|
|
|
|
|
ref $chars eq "ARRAY"; |
96
|
|
|
|
|
|
|
|
97
|
23
|
100
|
|
|
|
140
|
croak "Must pass in a ref to an array with required pin digits" unless |
98
|
|
|
|
|
|
|
ref $digits eq "ARRAY"; |
99
|
|
|
|
|
|
|
|
100
|
21
|
|
|
|
|
99
|
return { password => [@{$self->{creds}{password}}[@$chars]], |
|
21
|
|
|
|
|
198
|
|
101
|
21
|
|
|
|
|
41
|
pin => [@{$self->{creds}{pin}}[@$digits]] }; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
__END__ |