| 1 | package Catalyst::Authentication::User::Hash; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use base qw/Catalyst::Authentication::User/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 9 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | bless { ( @_ > 1 ) ? @_ : %{ $_[0] } }, $class; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 24 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | 24 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 16 | 24 | ( my $key ) = ( our $AUTOLOAD =~ m/([^:]*)$/ ); | |||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | 24 | $self->_accessor( $key, @_ ); | |||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | # this class effectively handles any method calls | ||||||||||||||||||||||||||||||||||||||
| 22 | 13 | ▶ | sub can { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
can: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 23 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 24 | 13 | my $coderef = $self->SUPER::can(@_); | |||||||||||||||||||||||||||||||||||||
| 25 | 13 | ▶ | return defined $coderef | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 26 | if $coderef; | ||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||
| 28 | 13 | my $method = shift; | |||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 31 | 0 | $self->_accessor(@_); | |||||||||||||||||||||||||||||||||||||
| 32 | 13 | }; | |||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 37 | 0 | $self->_accessor( "id", @_ ); | |||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | ## deprecated. Let the base class handle this. | ||||||||||||||||||||||||||||||||||||||
| 41 | # sub store { | ||||||||||||||||||||||||||||||||||||||
| 42 | # my $self = shift; | ||||||||||||||||||||||||||||||||||||||
| 43 | # $self->_accessor( "store", @_ ) || ref $self; | ||||||||||||||||||||||||||||||||||||||
| 44 | # } | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | 24 | ▶ | sub _accessor { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_accessor: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 47 | 24 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 48 | 24 | my $key = shift; | |||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||
| 50 | 24 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 51 | 1 | my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1; | |||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | $self->{$key} = $arr ? [@_] : shift; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | 24 | my $data = $self->{$key}; | |||||||||||||||||||||||||||||||||||||
| 56 | ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ ) | ||||||||||||||||||||||||||||||||||||||
| 57 | 24 | ▶ | ? @{ $data || [] } | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
$self->{"__hash_obj_key_is_array"}{$key} or $key =~ /roles/
$data || []
MC/DC100%2/2
$self->{"__hash_obj_key_is_array"}{$key} or $key =~ /roles/
$self->{"__hash_obj_key_is_array"}{$key}
$key =~ /roles/
MC/DC100%1/1
$data || []
$data
Truth table100%3/3
A or B
A= $self->{"__hash_obj_key_is_array"}{$key}B= $key =~ /roles/
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||
| 58 | : $data; | ||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | ## password portion of this is no longer necessary, but here for backwards compatibility. | ||||||||||||||||||||||||||||||||||||||
| 62 | 6 | my %features = ( | |||||||||||||||||||||||||||||||||||||
| 63 | password => { | ||||||||||||||||||||||||||||||||||||||
| 64 | clear => ["password"], | ||||||||||||||||||||||||||||||||||||||
| 65 | crypted => ["crypted_password"], | ||||||||||||||||||||||||||||||||||||||
| 66 | hashed => [qw/hashed_password hash_algorithm/], | ||||||||||||||||||||||||||||||||||||||
| 67 | self_check => undef, | ||||||||||||||||||||||||||||||||||||||
| 68 | }, | ||||||||||||||||||||||||||||||||||||||
| 69 | roles => ["roles"], | ||||||||||||||||||||||||||||||||||||||
| 70 | session => 1, | ||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | 19 | ▶ | sub supports { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
supports: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 74 | 19 | my ( $self, @spec ) = @_; | |||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | 19 | my $cursor = \%features; | |||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||
| 78 | 19 | ▶ | return 1 if @spec == 1 and exists $self->{ $spec[0] }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@spec == 1 and exists $$self{$spec[0]}
MC/DC0%0/2
@spec == 1 and exists $$self{$spec[0]}
@spec == 1
exists $$self{$spec[0]}
Truth table33%1/3
A and B
A= @spec == 1B= exists $$self{$spec[0]}
| |||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | # traverse the feature list, | ||||||||||||||||||||||||||||||||||||||
| 81 | 19 | for (@spec) { | |||||||||||||||||||||||||||||||||||||
| 82 | 38 | ▶ | return if ref($cursor) ne "HASH"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 83 | 38 | $cursor = $cursor->{$_}; | |||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | 19 | ▶ | if ( ref $cursor ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 87 | 17 | ▶ | die "bad feature spec: @spec" unless ref $cursor eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | # check that all the keys required for a feature are in here | ||||||||||||||||||||||||||||||||||||||
| 90 | 17 | foreach my $key (@$cursor) { | |||||||||||||||||||||||||||||||||||||
| 91 | 20 | ▶ | return undef unless exists $self->{$key}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||
| 96 | else { | ||||||||||||||||||||||||||||||||||||||
| 97 | 2 | return $cursor; | |||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub for_session { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
for_session: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $self; # we serialize the whole user | |||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub from_session { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
from_session: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my ( $self, $c, $user ) = @_; | |||||||||||||||||||||||||||||||||||||
| 109 | 0 | $user; | |||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | 6 | __PACKAGE__; | |||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||
| 114 | __END__ | ||||||||||||||||||||||||||||||||||||||