line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenID::Lite::RelyingParty::Store::OnMemory; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1710
|
use Any::Moose; |
|
2
|
|
|
|
|
40193
|
|
|
2
|
|
|
|
|
18
|
|
4
|
2
|
|
|
2
|
|
2021
|
use OpenID::Lite::Nonce; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
580
|
|
5
|
|
|
|
|
|
|
with 'OpenID::Lite::Role::Storable'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'associations' => ( |
8
|
|
|
|
|
|
|
is => 'ro', |
9
|
|
|
|
|
|
|
isa => 'HashRef', |
10
|
|
|
|
|
|
|
default => sub { {}, }, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'nonces' => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
isa => 'HashRef', |
16
|
|
|
|
|
|
|
default => sub { {}, }, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub store_association { |
20
|
9
|
|
|
9
|
0
|
1605
|
my ( $self, $server_url, $assoc ) = @_; |
21
|
9
|
|
100
|
|
|
52
|
my $assocs = $self->associations->{$server_url}||{}; |
22
|
9
|
|
|
|
|
30
|
$assocs->{ $assoc->handle } = $assoc->copy(); |
23
|
9
|
|
|
|
|
55
|
$self->associations->{$server_url} = $assocs; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get_association { |
27
|
23
|
|
|
23
|
0
|
7094
|
my ( $self, $server_url, $handle ) = @_; |
28
|
23
|
|
100
|
|
|
97
|
my $assocs = $self->associations->{$server_url}||{}; |
29
|
23
|
|
|
|
|
23
|
my $assoc; |
30
|
23
|
100
|
|
|
|
41
|
if ($handle) { |
31
|
14
|
|
|
|
|
19
|
$assoc = $assocs->{$handle}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
9
|
|
|
|
|
28
|
my @sorted = sort { $a->issued <=> $b->issued } values %$assocs; |
|
4
|
|
|
|
|
19
|
|
35
|
9
|
|
|
|
|
16
|
$assoc = $sorted[-1]; |
36
|
|
|
|
|
|
|
} |
37
|
23
|
|
|
|
|
46
|
return $assoc; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub remove_association { |
41
|
13
|
|
|
13
|
0
|
5160
|
my ( $self, $server_url, $handle ) = @_; |
42
|
13
|
|
100
|
|
|
63
|
my $assocs = $self->associations->{$server_url}||{}; |
43
|
13
|
100
|
|
|
|
44
|
return delete $assocs->{$handle} ? 1 : 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub cleanup_associations { |
47
|
2
|
|
|
2
|
0
|
12
|
my $self = shift; |
48
|
2
|
|
|
|
|
4
|
my $count = 0; |
49
|
2
|
|
|
|
|
4
|
for my $server_url ( keys %{ $self->associations } ) { |
|
2
|
|
|
|
|
12
|
|
50
|
5
|
|
|
|
|
14
|
my $assocs = $self->associations->{$server_url}; |
51
|
5
|
|
|
|
|
13
|
for my $handle ( keys %$assocs ) { |
52
|
4
|
|
|
|
|
6
|
my $assoc = $assocs->{$handle}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# if ($assoc->expires_in == 0) { |
55
|
4
|
100
|
|
|
|
19
|
if ( $assoc->is_expired ) { |
56
|
2
|
|
|
|
|
5
|
delete $assocs->{$handle}; |
57
|
2
|
|
|
|
|
12
|
$count++; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
2
|
|
|
|
|
6
|
return $count; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub use_nonce { |
65
|
14
|
|
|
14
|
0
|
53
|
my ( $self, $server_url, $timestamp, $salt ) = @_; |
66
|
14
|
100
|
|
|
|
44
|
return 0 if ( abs($timestamp - time()) > OpenID::Lite::Nonce->skew ); |
67
|
12
|
|
|
|
|
22
|
my $nonce = join('', $server_url, $timestamp, $salt); |
68
|
12
|
100
|
|
|
|
52
|
return 0 if exists $self->nonces->{$nonce}; |
69
|
7
|
|
|
|
|
22
|
$self->nonces->{$nonce} = $timestamp; |
70
|
7
|
|
|
|
|
27
|
return 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub cleanup_nonces { |
75
|
2
|
|
|
2
|
0
|
9
|
my $self = shift; |
76
|
2
|
|
|
|
|
3
|
my $count = 0; |
77
|
2
|
|
|
|
|
3
|
my $now = time(); |
78
|
2
|
|
|
|
|
3
|
for my $nonce ( keys %{ $self->nonces } ) { |
|
2
|
|
|
|
|
12
|
|
79
|
7
|
|
|
|
|
18
|
my $timestamp = $self->nonces->{$nonce}; |
80
|
7
|
100
|
|
|
|
21
|
if ( abs($now - $timestamp) > OpenID::Lite::Nonce->skew ) { |
81
|
2
|
|
|
|
|
7
|
delete $self->nonces->{$nonce}; |
82
|
2
|
|
|
|
|
3
|
$count++; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
2
|
|
|
|
|
7
|
return $count; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
2
|
|
|
2
|
|
1039
|
no Any::Moose; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
20
|
|
89
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|