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