line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Bank::Natwest::CredentialsProvider::Callback; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1303
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
259
|
|
4
|
3
|
|
|
3
|
|
877
|
use Finance::Bank::Natwest::CredentialsProvider::Constant; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
94
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use vars qw( $VERSION ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
665
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Finance::Bank::Natwest::CredentialsProvider::Callback - Credentials provider that uses a callback to gather the required information |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
CredentialsProvider module that uses a callback to retrieve the credentials. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $credentials = Finance::Bank::Natwest::CredentialsProvider::Callback->new( |
20
|
|
|
|
|
|
|
callback => \&credentials_callback |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item B |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $credentials = Finance::Bank::Natwest::CredentialsProvider::Callback->new( |
30
|
|
|
|
|
|
|
callback => \&credentials_callback |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Or we can also provide an ID to pass into the callback routine |
34
|
|
|
|
|
|
|
my $credentials = Finance::Bank::Natwest::CredentialsProvider::Callback->new( |
35
|
|
|
|
|
|
|
callback => \&credentials_callback, id => 1 |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
If C is provided then it must be a simple scalar, and not a reference. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new{ |
43
|
14
|
|
|
14
|
1
|
19372
|
my ($class, %opts) = @_; |
44
|
|
|
|
|
|
|
|
45
|
14
|
|
|
|
|
65
|
my $self = bless {}, $class; |
46
|
|
|
|
|
|
|
|
47
|
14
|
100
|
|
|
|
107
|
croak "Must provide a callback, stopped" unless |
48
|
|
|
|
|
|
|
exists $opts{callback}; |
49
|
|
|
|
|
|
|
|
50
|
11
|
100
|
|
|
|
117
|
croak "Callback must be a code ref, stopped" unless |
51
|
|
|
|
|
|
|
ref $opts{callback} eq "CODE"; |
52
|
|
|
|
|
|
|
|
53
|
9
|
|
|
|
|
31
|
$self->{callback} = $opts{callback}; |
54
|
9
|
|
100
|
|
|
47
|
$self->{cache} = $opts{cache} || 0; |
55
|
|
|
|
|
|
|
|
56
|
9
|
50
|
|
|
|
26
|
croak "ID must be a simple scalar, stopped" if |
57
|
|
|
|
|
|
|
ref $opts{id}; |
58
|
|
|
|
|
|
|
|
59
|
9
|
|
|
|
|
21
|
$self->{id} = $opts{id}; |
60
|
|
|
|
|
|
|
|
61
|
9
|
|
|
|
|
29
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub get_start{ |
65
|
48
|
|
|
48
|
0
|
40767
|
my ($self, %opts) = @_; |
66
|
|
|
|
|
|
|
|
67
|
48
|
50
|
33
|
|
|
425
|
croak "ID must be a simple scalar, stopped" if |
68
|
|
|
|
|
|
|
exists $opts{id} and ref $opts{id}; |
69
|
|
|
|
|
|
|
|
70
|
48
|
50
|
|
|
|
141
|
$self->{id} = $opts{id} if |
71
|
|
|
|
|
|
|
exists $opts{id}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
{ |
74
|
3
|
|
|
3
|
|
14
|
no warnings 'uninitialized'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
472
|
|
|
48
|
|
|
|
|
85
|
|
75
|
48
|
|
|
|
|
578
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
76
|
48
|
100
|
|
|
|
186
|
if (!exists $self->{my_cache}{$self->{id}}) { |
77
|
41
|
|
|
|
|
145
|
$self->{my_cache}{$self->{id}} = |
78
|
|
|
|
|
|
|
Finance::Bank::Natwest::CredentialsProvider::Constant->new( |
79
|
41
|
|
|
|
|
53
|
%{$self->{callback}->($self->{id})}); |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub get_stop{ |
85
|
28
|
|
|
28
|
0
|
6383
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
{ |
88
|
3
|
|
|
3
|
|
16
|
no warnings 'uninitialized'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
279
|
|
|
28
|
|
|
|
|
47
|
|
89
|
28
|
|
|
|
|
44
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
90
|
28
|
100
|
|
|
|
197
|
delete $self->{my_cache}{$self->{id}} unless |
91
|
|
|
|
|
|
|
$self->{cache}; |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_identity{ |
96
|
7
|
|
|
7
|
0
|
48
|
my ($self) = @_; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
{ |
99
|
3
|
|
|
3
|
|
13
|
no warnings 'uninitialized'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1189
|
|
|
7
|
|
|
|
|
9
|
|
100
|
7
|
|
|
|
|
15
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
101
|
7
|
|
|
|
|
30
|
return $self->{my_cache}{$self->{id}}->get_identity(); |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_pinpass{ |
106
|
14
|
|
|
14
|
0
|
29
|
my ($self, $chars, $digits) = @_; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
{ |
109
|
3
|
|
|
3
|
|
17
|
no warnings 'uninitialized'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
211
|
|
|
14
|
|
|
|
|
24
|
|
110
|
14
|
|
|
|
|
2124423
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
111
|
14
|
|
|
|
|
87
|
return $self->{my_cache}{$self->{id}}->get_pinpass($chars, $digits); |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
__END__ |