| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Session::ID::SHA256; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
928
|
use parent 'Data::Session::SHA'; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
9
|
|
|
4
|
1
|
|
|
1
|
|
86
|
no autovivification; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
5
|
1
|
|
|
1
|
|
57
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use Hash::FieldHash ':all'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
373
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.18'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ----------------------------------------------- |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub generate |
|
15
|
|
|
|
|
|
|
{ |
|
16
|
15
|
|
|
15
|
0
|
44
|
my($self) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
15
|
|
|
|
|
114
|
return $self -> SUPER::generate(256); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
} # End of generate. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# ----------------------------------------------- |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub id_length |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
return 64; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} # End of id_length. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# ----------------------------------------------- |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
30
|
|
|
30
|
1
|
274
|
my($class, %arg) = @_; |
|
37
|
30
|
|
50
|
|
|
132
|
$arg{verbose} ||= 0; |
|
38
|
|
|
|
|
|
|
|
|
39
|
30
|
|
|
|
|
1799
|
return from_hash(bless({}, $class), \%arg); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} # End of new. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# ----------------------------------------------- |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
L - A persistent session manager |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 Synopsis |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
See L for details. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 Description |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
L allows L to generate session ids using L. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
To use this module do this: |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over 4 |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item o Specify an id generator of type SHA256, as Data::Session -> new(type => '... id:SHA256 ...') |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=back |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 Case-sensitive Options |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
See L for important information. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 Method: new() |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Creates a new object of type L. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
C takes a hash of key/value pairs, some of which might mandatory. Further, some combinations |
|
78
|
|
|
|
|
|
|
might be mandatory. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The keys are listed here in alphabetical order. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
They are lower-case because they are (also) method names, meaning they can be called to set or get |
|
83
|
|
|
|
|
|
|
the value at any time. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item o verbose => $integer |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Print to STDERR more or less information. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Typical values are 0, 1 and 2. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This key is normally passed in as Data::Session -> new(verbose => $integer). |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This key is optional. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 Method: generate() |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Generates the next session id, or dies if it can't. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The algorithm is Digest::SHA -> new(256) -> add($$, time, rand(time) ) -> hexdigest. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns the new id. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 Method: id_length() |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns 64 because that's the number of hex digits in an SHA256 digest. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This can be used to generate the SQL to create the sessions table. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 Support |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Log a bug on RT: L. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 Author |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L was written by Ron Savage Iron@savage.net.auE> in 2010. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Home page: L. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 Copyright |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Australian copyright (c) 2010, Ron Savage. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
All Programs of mine are 'OSI Certified Open Source Software'; |
|
128
|
|
|
|
|
|
|
you can redistribute them and/or modify them under the terms of |
|
129
|
|
|
|
|
|
|
The Artistic License, a copy of which is available at: |
|
130
|
|
|
|
|
|
|
http://www.opensource.org/licenses/index.html |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |