| 1 | package Net::OATH::Server::Lite::Model::User; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use parent 'Class::Accessor::Fast'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Params::Validate qw(SCALAR); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 6 | __PACKAGE__->mk_accessors(qw( | |||||||||||||||||||||||||||
| 9 | id | ||||||||||||||||||||||||||||
| 10 | type | ||||||||||||||||||||||||||||
| 11 | secret | ||||||||||||||||||||||||||||
| 12 | algorithm | ||||||||||||||||||||||||||||
| 13 | digits | ||||||||||||||||||||||||||||
| 14 | counter | ||||||||||||||||||||||||||||
| 15 | period | ||||||||||||||||||||||||||||
| 16 | )); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | sub new { | ||||||||||||||||||||||||||||
| 19 | 16 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 16 | ▶ | my @args = @_ == 1 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 16 | my %params = Params::Validate::validate_with( | |||||||||||||||||||||||||||
| 22 | params => \@args, | ||||||||||||||||||||||||||||
| 23 | spec => { | ||||||||||||||||||||||||||||
| 24 | id => { | ||||||||||||||||||||||||||||
| 25 | type => SCALAR, | ||||||||||||||||||||||||||||
| 26 | }, | ||||||||||||||||||||||||||||
| 27 | type => { | ||||||||||||||||||||||||||||
| 28 | type => SCALAR, | ||||||||||||||||||||||||||||
| 29 | default => q{totp}, | ||||||||||||||||||||||||||||
| 30 | optional => 1, | ||||||||||||||||||||||||||||
| 31 | }, | ||||||||||||||||||||||||||||
| 32 | secret => { | ||||||||||||||||||||||||||||
| 33 | type => SCALAR, | ||||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||
| 35 | algorithm => { | ||||||||||||||||||||||||||||
| 36 | type => SCALAR, | ||||||||||||||||||||||||||||
| 37 | default => q{SHA1}, | ||||||||||||||||||||||||||||
| 38 | optional => 1, | ||||||||||||||||||||||||||||
| 39 | }, | ||||||||||||||||||||||||||||
| 40 | digits => { | ||||||||||||||||||||||||||||
| 41 | type => SCALAR, | ||||||||||||||||||||||||||||
| 42 | default => 6, | ||||||||||||||||||||||||||||
| 43 | optional => 1, | ||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||
| 45 | counter => { | ||||||||||||||||||||||||||||
| 46 | type => SCALAR, | ||||||||||||||||||||||||||||
| 47 | default => 0, | ||||||||||||||||||||||||||||
| 48 | optional => 1, | ||||||||||||||||||||||||||||
| 49 | }, | ||||||||||||||||||||||||||||
| 50 | period => { | ||||||||||||||||||||||||||||
| 51 | type => SCALAR, | ||||||||||||||||||||||||||||
| 52 | default => 30, | ||||||||||||||||||||||||||||
| 53 | optional => 1, | ||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||
| 56 | allow_extra => 0, | ||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 16 | my $self = bless \%params, $class; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 16 | return $self; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub is_valid { | ||||||||||||||||||||||||||||
| 65 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 9 | ▶ | return unless ($self->type eq q{totp} || $self->type eq q{hotp}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->type eq "totp" or $self->type eq "hotp"
MC/DC100%2/2
$self->type eq "totp" or $self->type eq "hotp"
$self->type eq "totp"
$self->type eq "hotp"
Truth table100%3/3
A or B
A= $self->type eq "totp"B= $self->type eq "hotp"
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # TODO: Support SHA256, SHA512 | ||||||||||||||||||||||||||||
| 70 | 6 | ▶ | return unless ($self->algorithm eq q{SHA1} || $self->algorithm eq q{MD5}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->algorithm eq "SHA1" or $self->algorithm eq "MD5"
MC/DC50%1/2
$self->algorithm eq "SHA1" or $self->algorithm eq "MD5"
$self->algorithm eq "SHA1"
$self->algorithm eq "MD5"
Truth table66%2/3
A or B
A= $self->algorithm eq "SHA1"B= $self->algorithm eq "MD5"
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # TODO: Validation other params | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 5 | return 1; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 6 | 1; | |||||||||||||||||||||||||||