line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::KeyMetadata; |
2
|
15
|
|
|
15
|
|
85
|
use strict; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
350
|
|
3
|
15
|
|
|
15
|
|
69
|
use warnings; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
300
|
|
4
|
15
|
|
|
15
|
|
4163
|
use Crypt::Keyczar::KeyVersion; |
|
15
|
|
|
|
|
36
|
|
|
15
|
|
|
|
|
405
|
|
5
|
15
|
|
|
15
|
|
85
|
use Crypt::Keyczar::Util qw(decode_json encode_json json_true json_false json_null); |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
7167
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
0
|
16
|
sub get_name { $_[0]->{name} } |
9
|
4
|
|
|
4
|
0
|
18
|
sub get_purpose { $_[0]->{purpose} } |
10
|
183
|
|
|
183
|
0
|
546
|
sub get_type { $_[0]->{type} } |
11
|
|
|
|
|
|
|
sub encrypted { |
12
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
13
|
0
|
0
|
|
|
|
0
|
$self->{encrypted} = shift if @_; |
14
|
0
|
|
|
|
|
0
|
return $self->{encrypted}; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
87
|
|
|
87
|
0
|
178
|
my $class = shift; |
20
|
87
|
|
|
|
|
225
|
my ($name, $purpose, $type) = @_; |
21
|
87
|
|
|
|
|
411
|
my $self = bless { |
22
|
|
|
|
|
|
|
name => $name, |
23
|
|
|
|
|
|
|
purpose => $purpose, |
24
|
|
|
|
|
|
|
type => $type, |
25
|
|
|
|
|
|
|
encrypted => undef, |
26
|
|
|
|
|
|
|
__version_map => {}, |
27
|
|
|
|
|
|
|
versions => [], |
28
|
|
|
|
|
|
|
}, $class; |
29
|
87
|
|
|
|
|
203
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub read { |
33
|
78
|
|
|
78
|
0
|
182
|
my $class = shift; |
34
|
78
|
|
|
|
|
134
|
my $json_string = shift; |
35
|
78
|
|
|
|
|
233
|
my $obj = decode_json($json_string); |
36
|
78
|
|
|
|
|
295
|
my $self = $class->new($obj->{name}, $obj->{purpose}, $obj->{type}); |
37
|
78
|
|
|
|
|
163
|
$self->{encrypted} = $obj->{encrypted}; |
38
|
78
|
|
|
|
|
142
|
for my $v (@{$obj->{versions}}) { |
|
78
|
|
|
|
|
196
|
|
39
|
170
|
100
|
|
|
|
384
|
if (!$v) { |
40
|
8
|
|
|
|
|
22
|
$self->add_version(undef); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
162
|
|
|
|
|
603
|
$self->add_version(Crypt::Keyczar::KeyVersion->new($v->{versionNumber}, $v->{status}, $v->{exportable})); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
78
|
|
|
|
|
469
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_versions { |
51
|
155
|
|
|
155
|
0
|
269
|
my $self = shift; |
52
|
155
|
|
|
|
|
260
|
return @{$self->{versions}}; |
|
155
|
|
|
|
|
438
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_version { |
57
|
41
|
|
|
41
|
0
|
68
|
my $self = shift; |
58
|
41
|
|
|
|
|
64
|
my $version = shift; |
59
|
41
|
|
|
|
|
101
|
return $self->{__version_map}->{$version}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub add_version { |
64
|
196
|
|
|
196
|
0
|
317
|
my $self = shift; |
65
|
196
|
|
|
|
|
298
|
my $key_version = shift; |
66
|
|
|
|
|
|
|
|
67
|
196
|
100
|
|
|
|
438
|
if (defined $key_version) { |
68
|
185
|
50
|
|
|
|
482
|
if (exists $self->{__version_map}->{$key_version->get_number}) { |
69
|
0
|
|
|
|
|
0
|
return undef; |
70
|
|
|
|
|
|
|
} |
71
|
185
|
|
|
|
|
466
|
$self->{__version_map}->{$key_version->get_number()} = $key_version; |
72
|
|
|
|
|
|
|
} |
73
|
196
|
|
|
|
|
323
|
push @{$self->{versions}}, $key_version; |
|
196
|
|
|
|
|
408
|
|
74
|
196
|
|
|
|
|
408
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub remove_version { |
79
|
6
|
|
|
6
|
0
|
14
|
my $self = shift; |
80
|
6
|
|
|
|
|
13
|
my $version_number = shift; |
81
|
|
|
|
|
|
|
|
82
|
6
|
50
|
|
|
|
21
|
if (!exists $self->{__version_map}->{$version_number}) { |
83
|
0
|
|
|
|
|
0
|
return undef; |
84
|
|
|
|
|
|
|
} |
85
|
6
|
|
|
|
|
18
|
undef $self->{versions}->[$version_number - 1]; |
86
|
6
|
|
|
|
|
14
|
delete $self->{__version_map}->{$version_number}; |
87
|
|
|
|
|
|
|
|
88
|
6
|
|
|
|
|
22
|
return 1; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub expose { |
93
|
57
|
|
|
57
|
0
|
107
|
my $self = shift; |
94
|
57
|
|
|
|
|
117
|
my $expose = {}; |
95
|
|
|
|
|
|
|
|
96
|
57
|
|
|
|
|
161
|
$expose->{name} = $self->{name}; |
97
|
57
|
|
|
|
|
131
|
$expose->{purpose} = $self->{purpose}; |
98
|
57
|
|
|
|
|
137
|
$expose->{type} = $self->{type}; |
99
|
57
|
50
|
|
|
|
296
|
$expose->{encrypted} = $self->{encrypted} ? json_true() : json_false(); |
100
|
57
|
|
|
|
|
274
|
$expose->{versions} = []; |
101
|
57
|
|
|
|
|
149
|
for my $v ($self->get_versions) { |
102
|
129
|
100
|
|
|
|
223
|
push @{$expose->{versions}}, $v ? $v->expose : json_null(); |
|
129
|
|
|
|
|
428
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
57
|
|
|
|
|
179
|
return $expose; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
57
|
|
|
57
|
0
|
170
|
sub to_string { return encode_json($_[0]->expose) } |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
__END__ |