line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::KeyMetadata; |
2
|
15
|
|
|
15
|
|
83
|
use strict; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
522
|
|
3
|
15
|
|
|
15
|
|
78
|
use warnings; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
677
|
|
4
|
15
|
|
|
15
|
|
10360
|
use Crypt::Keyczar::KeyVersion; |
|
15
|
|
|
|
|
43
|
|
|
15
|
|
|
|
|
514
|
|
5
|
15
|
|
|
15
|
|
94
|
use Crypt::Keyczar::Util qw(decode_json encode_json json_true json_false json_null); |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
11372
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
0
|
20
|
sub get_name { $_[0]->{name} } |
9
|
4
|
|
|
4
|
0
|
25
|
sub get_purpose { $_[0]->{purpose} } |
10
|
183
|
|
|
183
|
0
|
751
|
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
|
167
|
my $class = shift; |
20
|
87
|
|
|
|
|
214
|
my ($name, $purpose, $type) = @_; |
21
|
87
|
|
|
|
|
741
|
my $self = bless { |
22
|
|
|
|
|
|
|
name => $name, |
23
|
|
|
|
|
|
|
purpose => $purpose, |
24
|
|
|
|
|
|
|
type => $type, |
25
|
|
|
|
|
|
|
encrypted => undef, |
26
|
|
|
|
|
|
|
__version_map => {}, |
27
|
|
|
|
|
|
|
versions => [], |
28
|
|
|
|
|
|
|
}, $class; |
29
|
87
|
|
|
|
|
244
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub read { |
33
|
78
|
|
|
78
|
0
|
176
|
my $class = shift; |
34
|
78
|
|
|
|
|
114
|
my $json_string = shift; |
35
|
78
|
|
|
|
|
327
|
my $obj = decode_json($json_string); |
36
|
78
|
|
|
|
|
408
|
my $self = $class->new($obj->{name}, $obj->{purpose}, $obj->{type}); |
37
|
78
|
|
|
|
|
214
|
$self->{encrypted} = $obj->{encrypted}; |
38
|
78
|
|
|
|
|
113
|
for my $v (@{$obj->{versions}}) { |
|
78
|
|
|
|
|
245
|
|
39
|
170
|
100
|
|
|
|
445
|
if (!$v) { |
40
|
8
|
|
|
|
|
63
|
$self->add_version(undef); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
162
|
|
|
|
|
843
|
$self->add_version(Crypt::Keyczar::KeyVersion->new($v->{versionNumber}, $v->{status}, $v->{exportable})); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
78
|
|
|
|
|
636
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_versions { |
51
|
155
|
|
|
155
|
0
|
284
|
my $self = shift; |
52
|
155
|
|
|
|
|
198
|
return @{$self->{versions}}; |
|
155
|
|
|
|
|
643
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_version { |
57
|
41
|
|
|
41
|
0
|
64
|
my $self = shift; |
58
|
41
|
|
|
|
|
59
|
my $version = shift; |
59
|
41
|
|
|
|
|
140
|
return $self->{__version_map}->{$version}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub add_version { |
64
|
196
|
|
|
196
|
0
|
287
|
my $self = shift; |
65
|
196
|
|
|
|
|
240
|
my $key_version = shift; |
66
|
|
|
|
|
|
|
|
67
|
196
|
100
|
|
|
|
394
|
if (defined $key_version) { |
68
|
185
|
50
|
|
|
|
581
|
if (exists $self->{__version_map}->{$key_version->get_number}) { |
69
|
0
|
|
|
|
|
0
|
return undef; |
70
|
|
|
|
|
|
|
} |
71
|
185
|
|
|
|
|
572
|
$self->{__version_map}->{$key_version->get_number()} = $key_version; |
72
|
|
|
|
|
|
|
} |
73
|
196
|
|
|
|
|
282
|
push @{$self->{versions}}, $key_version; |
|
196
|
|
|
|
|
448
|
|
74
|
196
|
|
|
|
|
521
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub remove_version { |
79
|
6
|
|
|
6
|
0
|
9
|
my $self = shift; |
80
|
6
|
|
|
|
|
11
|
my $version_number = shift; |
81
|
|
|
|
|
|
|
|
82
|
6
|
50
|
|
|
|
23
|
if (!exists $self->{__version_map}->{$version_number}) { |
83
|
0
|
|
|
|
|
0
|
return undef; |
84
|
|
|
|
|
|
|
} |
85
|
6
|
|
|
|
|
16
|
undef $self->{versions}->[$version_number - 1]; |
86
|
6
|
|
|
|
|
16
|
delete $self->{__version_map}->{$version_number}; |
87
|
|
|
|
|
|
|
|
88
|
6
|
|
|
|
|
33
|
return 1; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub expose { |
93
|
57
|
|
|
57
|
0
|
96
|
my $self = shift; |
94
|
57
|
|
|
|
|
98
|
my $expose = {}; |
95
|
|
|
|
|
|
|
|
96
|
57
|
|
|
|
|
203
|
$expose->{name} = $self->{name}; |
97
|
57
|
|
|
|
|
150
|
$expose->{purpose} = $self->{purpose}; |
98
|
57
|
|
|
|
|
147
|
$expose->{type} = $self->{type}; |
99
|
57
|
50
|
|
|
|
434
|
$expose->{encrypted} = $self->{encrypted} ? json_true() : json_false(); |
100
|
57
|
|
|
|
|
308
|
$expose->{versions} = []; |
101
|
57
|
|
|
|
|
167
|
for my $v ($self->get_versions) { |
102
|
129
|
100
|
|
|
|
211
|
push @{$expose->{versions}}, $v ? $v->expose : json_null(); |
|
129
|
|
|
|
|
557
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
57
|
|
|
|
|
255
|
return $expose; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
57
|
|
|
57
|
0
|
197
|
sub to_string { return encode_json($_[0]->expose) } |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
__END__ |