line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Session::ID::SHA1; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
928
|
use parent 'Data::Session::SHA'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
4
|
1
|
|
|
1
|
|
59
|
no autovivification; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
86
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Hash::FieldHash ':all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
275
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.18'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ----------------------------------------------- |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub generate |
15
|
|
|
|
|
|
|
{ |
16
|
15
|
|
|
15
|
0
|
36
|
my($self) = @_; |
17
|
|
|
|
|
|
|
|
18
|
15
|
|
|
|
|
106
|
return $self -> SUPER::generate(1); |
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 40; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} # End of id_length. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# ----------------------------------------------- |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new |
35
|
|
|
|
|
|
|
{ |
36
|
30
|
|
|
30
|
1
|
282
|
my($class, %arg) = @_; |
37
|
30
|
|
50
|
|
|
128
|
$arg{verbose} ||= 0; |
38
|
|
|
|
|
|
|
|
39
|
30
|
|
|
|
|
1813
|
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 SHA1, as Data::Session -> new(type => '... id:SHA1 ...') |
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(1) -> add($$, time, rand(time) ) -> hexdigest. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns the new id. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 Method: id_length() |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns 40 because that's the number of hex digits in an SHA1 digest. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 Support |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Log a bug on RT: L. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 Author |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L was written by Ron Savage Iron@savage.net.auE> in 2010. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Home page: L. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 Copyright |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Australian copyright (c) 2010, Ron Savage. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
All Programs of mine are 'OSI Certified Open Source Software'; |
126
|
|
|
|
|
|
|
you can redistribute them and/or modify them under the terms of |
127
|
|
|
|
|
|
|
The Artistic License, a copy of which is available at: |
128
|
|
|
|
|
|
|
http://www.opensource.org/licenses/index.html |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |