Aut/Ticket.pm

filter: Statementstmt 13.9% 11 / 79 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 16.6% 3 / 18 Podpod 93.3% 14 / 15 totaltotal 23.7% 28 / 118 CC 4 SCAR 11.0
CC
4
Cov
13%
new
6.0
gen6
6.0
decrypt
6.0
CRAP 3.0
« Aut/Backend/Conf.pm ↑ Summary Aut/Crypt.pm »
1 package Aut::Ticket;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Aut::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Aut::Crypt;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 srand(time());
9  
10 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
11 0 my $class=shift;
12 0 my $account=shift;
13 0 my $pass=shift;
14  
15 0 my $self;
16  
17 0 $self->{"conf"}->{"aut"}="there";
18  
19 0 $self->{"pass"}=$pass;
20 0 $self->{"account"}=$account;
21 0 $self->{"valid"}=1;
22  
23 0 my $s="";
24 0 ▶ while (length($s)<32) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $s < 32) 0 0 0
25 0 $s.=rand();
26 0 $s=~s/[^0-9]//g;
27 }
28 0 $s=substr($s,0,32);
29 0 $self->{"seed"}=$s;
30  
31 0 bless $self,$class;
32 0 return $self;
33 }
34  
35 0 ▶sub invalidate {
Subroutine invalidate: not called CC=1 SCAR=6.9
Pod documented
36 0 my $self=shift;
37 0 $self->{"valid"}=0;
38 }
39  
40 0 ▶sub valid {
Subroutine valid: not called CC=1 SCAR=6.9
Pod documented
41 0 my $self=shift;
42 0 return $self->{"valid"};
43 }
44  
45 0 ▶sub rights {
Subroutine rights: not called CC=1 SCAR=6.9
Pod documented
46 0 my $self=shift;
47 0 return $self->{"rights"};
48 }
49  
50 0 ▶sub account {
Subroutine account: not called CC=1 SCAR=6.9
Pod documented
51 0 my $self=shift;
52 0 return $self->{"account"};
53 }
54  
55 0 ▶sub pass {
Subroutine pass: not called CC=1 SCAR=6.9
Pod documented
56 0 my $self=shift;
57 0 return $self->{"pass"};
58 }
59  
60 0 ▶sub seed {
Subroutine seed: not called CC=1 SCAR=6.9
Pod documented
61 0 my $self=shift;
62 0 return $self->{"seed"};
63 }
64  
65  
66 0 ▶sub set_rights {
Subroutine set_rights: not called CC=1 SCAR=6.9
Pod documented
67 0 my $self=shift;
68 0 my $rights=shift;
69 0 $self->{"rights"}=$rights;
70 }
71  
72 0 ▶sub set_seed {
Subroutine set_seed: not called CC=1 SCAR=6.9
Pod documented
73 0 my $self=shift;
74 0 my $seed=shift;
75 0 $self->{"seed"}=$seed;
76 }
77  
78 0 ▶sub set_pass {
Subroutine set_pass: not called CC=1 SCAR=6.9
Pod documented
79 0 my $self=shift;
80 0 my $pass=shift;
81 0 $self->{"pass"}=$pass;
82 }
83  
84 0 ▶sub gen6 {
Subroutine gen6: not called CC=2 SCAR=17.9
Pod undocumented
85 0 my $r="";
86  
87 0 ▶ while (length $r lt 6) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $r lt 6) 0 0 0
88 0 $r.=rand();
89 0 $r=~s/[.]//;
90 0 $r=~s/^0//;
91 }
92 0 $r=substr($r,0,6);
93 0 return $r;
94 }
95  
96 0 ▶sub encrypt {
Subroutine encrypt: not called CC=1 SCAR=6.9
Pod documented
97 0 my $self=shift;
98 0 my $text=shift;
99 0 my $crypter=new Aut::Crypt($self->seed());
100 0 my $base64=new Aut::Base64();
101 0 my $r=gen6();
102 0 return $base64->encode($crypter->encrypt("$r$r".$text));
103 }
104  
105 0 ▶sub decrypt {
Subroutine decrypt: not called CC=2 SCAR=17.9
Pod documented
106 0 my $self=shift;
107 0 my $text=shift;
108 0 my $dtext;
109 0 my $crypter=new Aut::Crypt($self->seed());
110 0 my $base64=new Aut::Base64();
111  
112 0 $dtext=$crypter->decrypt($base64->decode($text));
113 0 my $r1=substr($dtext,0,6);
114 0 my $r2=substr($dtext,6,6);
115 0 ▶ if ($r1 ne $r2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r1 ne $r2) { } 0 0 0
116 0 return undef;
117 }
118 else {
119 0 return substr($dtext,12,length($dtext));
120 }
121 }
122  
123 0 ▶sub set {
Subroutine set: not called CC=1 SCAR=6.9
Pod documented
124 0 my $self=shift;
125 0 my $var=shift;
126 0 my $val=shift;
127 0 $self->{"conf"}->{$var}=$val;
128 }
129  
130 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod documented
131 0 my $self=shift;
132 0 my $var=shift;
133 0 return $self->{"conf"}->{$var};
134 }
135  
136 1 1;
137 __END__
« Aut/Backend/Conf.pm ↑ Summary Aut/Crypt.pm »