line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::KeyVersion; |
2
|
15
|
|
|
15
|
|
85
|
use strict; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
330
|
|
3
|
15
|
|
|
15
|
|
75
|
use warnings; |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
335
|
|
4
|
15
|
|
|
15
|
|
2114
|
use Crypt::Keyczar::Util qw(json_true json_false); |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
753
|
|
5
|
15
|
|
|
15
|
|
99
|
use Carp; |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
5793
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
179
|
|
|
179
|
0
|
301
|
my $class = shift; |
11
|
179
|
|
|
|
|
357
|
my ($version, $status, $exportable) = @_; |
12
|
179
|
|
|
|
|
493
|
my $self = bless { |
13
|
|
|
|
|
|
|
exportable => json_false(), |
14
|
|
|
|
|
|
|
status => 'ACTIVE', |
15
|
|
|
|
|
|
|
version_number => 0, |
16
|
|
|
|
|
|
|
}, $class; |
17
|
179
|
100
|
|
|
|
1199
|
$self->exportable($exportable) if defined $exportable; |
18
|
179
|
50
|
|
|
|
1894
|
$self->status($status) if defined $status; |
19
|
179
|
50
|
|
|
|
416
|
$self->{version_number} = $version if defined $version; |
20
|
179
|
|
|
|
|
518
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub create { |
24
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
25
|
0
|
|
|
|
|
0
|
my $opt = shift; |
26
|
0
|
|
|
|
|
0
|
return $class->new($opt->{versionNumber}, $opt->{status}, $opt->{exportable}); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub read { |
30
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
31
|
0
|
|
|
|
|
0
|
my $json_string = shift; |
32
|
0
|
|
|
|
|
0
|
my $obj = from_json($json_string); |
33
|
0
|
|
|
|
|
0
|
return bless $obj, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub exportable { |
39
|
162
|
|
|
162
|
0
|
253
|
my $self = shift; |
40
|
162
|
50
|
|
|
|
782
|
$self->{exportable} = $_[0] ? json_true() : json_false() if @_; |
|
|
50
|
|
|
|
|
|
41
|
162
|
50
|
|
|
|
700
|
return $self->{exportable} eq json_true() ? 1 : undef; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub status { |
46
|
450
|
|
|
450
|
0
|
680
|
my $self = shift; |
47
|
450
|
100
|
|
|
|
960
|
if (@_) { |
48
|
216
|
100
|
|
|
|
622
|
if (uc $_[0] eq 'ACTIVE') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
49
|
115
|
|
|
|
|
247
|
$self->{status} = uc $_[0]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif (uc $_[0] eq 'PRIMARY') { |
52
|
77
|
|
|
|
|
172
|
$self->{status} = uc $_[0]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif (uc $_[0] eq 'INACTIVE') { |
55
|
24
|
|
|
|
|
51
|
$self->{status} = uc $_[0]; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
0
|
|
|
|
|
0
|
croak "unknown key status: $_[0]"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
450
|
|
|
|
|
1179
|
return $self->{status}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_number { |
66
|
795
|
|
|
795
|
0
|
1222
|
my $self = shift; |
67
|
795
|
50
|
|
|
|
1690
|
$self->{version_number} = shift if @_; |
68
|
795
|
|
|
|
|
3275
|
return $self->{version_number}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub expose { |
74
|
120
|
|
|
120
|
0
|
194
|
my $self = shift; |
75
|
120
|
|
|
|
|
220
|
my $expose = {}; |
76
|
120
|
50
|
|
|
|
271
|
$expose->{exportable} = $self->{exportable} ? json_true() : json_false(); |
77
|
120
|
|
|
|
|
479
|
$expose->{status} = $self->{status}; |
78
|
120
|
|
|
|
|
219
|
$expose->{versionNumber} = $self->{version_number}; |
79
|
120
|
|
|
|
|
310
|
return $expose; |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
0
|
0
|
|
sub to_string { return to_json($_[0]->expose) } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
__END__ |