line |
stmt |
bran |
path |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
# UserId.pm |
2
|
|
|
|
|
|
|
|
# - providing an object-oriented approach to GnuPG user ids |
3
|
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
# Copyright (C) 2000 Frank J. Tobin <ftobin@cpan.org> |
5
|
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or modify it |
7
|
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
10
|
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
|
# $Id: UserId.pm,v 1.7 2001/08/21 13:31:50 ftobin Exp $ |
14
|
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
package GnuPG::UserId; |
17
|
6
|
|
|
|
6
|
|
20397
|
use Moo; |
|
6
|
|
|
|
|
|
9433
|
|
|
6
|
|
|
|
|
|
41
|
|
18
|
6
|
|
|
|
6
|
|
3701
|
use MooX::late; |
|
6
|
|
|
|
|
|
29617
|
|
|
6
|
|
|
|
|
|
67
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
has [qw( validity as_string )] => ( |
21
|
|
|
|
|
|
|
|
isa => 'Any', |
22
|
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
has signatures => ( |
26
|
|
|
|
|
|
|
|
isa => 'ArrayRef', |
27
|
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
|
default => sub { [] }, |
29
|
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
has revocations => ( |
31
|
|
|
|
|
|
|
|
isa => 'ArrayRef', |
32
|
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
|
default => sub { [] }, |
34
|
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
sub push_signatures { |
37
|
9
|
|
|
|
9
|
0
|
594
|
my $self = shift; |
38
|
9
|
|
|
|
|
|
17
|
push @{ $self->signatures }, @_; |
|
9
|
|
|
|
|
|
150
|
|
39
|
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
sub push_revocations { |
41
|
0
|
|
|
|
0
|
0
|
0
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
0
|
push @{ $self->revocations }, @_; |
|
0
|
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
sub compare { |
46
|
4
|
|
|
|
4
|
1
|
21
|
my ( $self, $other, $deep ) = @_; |
47
|
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
|
21
|
my @comparison_ints = qw( validity as_string ); |
49
|
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
|
11
|
foreach my $field ( @comparison_ints ) { |
51
|
8
|
50
|
|
|
|
|
317
|
return 0 unless $self->$field() eq $other->$field(); |
52
|
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
|
54
|
4
|
50
|
|
|
|
|
42
|
return 0 unless @{$self->signatures} == @{$other->signatures}; |
|
4
|
|
|
|
|
|
63
|
|
|
4
|
|
|
|
|
|
84
|
|
55
|
4
|
50
|
|
|
|
|
39
|
return 0 unless @{$self->revocations} == @{$other->revocations}; |
|
4
|
|
|
|
|
|
63
|
|
|
4
|
|
|
|
|
|
74
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
# FIXME: is it actually wrong if the associated signatures come out |
58
|
|
|
|
|
|
|
|
# in a different order on the two compared designated revokers? |
59
|
4
|
50
|
|
33
|
|
|
114
|
if (defined $deep && $deep) { |
60
|
4
|
|
|
|
|
|
12
|
for ( my $i = 0; $i < scalar(@{$self->signatures}); $i++ ) { |
|
11
|
|
|
|
|
|
1274
|
|
61
|
7
|
50
|
|
|
|
|
103
|
return 0 |
62
|
|
|
|
|
|
|
|
unless $self->signatures->[$i]->compare($other->signatures->[$i], 1); |
63
|
|
|
|
|
|
|
|
} |
64
|
4
|
|
|
|
|
|
28
|
for ( my $i = 0; $i < scalar(@{$self->revocations}); $i++ ) { |
|
4
|
|
|
|
|
|
58
|
|
65
|
0
|
0
|
|
|
|
|
0
|
return 0 |
66
|
|
|
|
|
|
|
|
unless $self->revocations->[$i]->compare($other->revocations->[$i], 1); |
67
|
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
|
70
|
4
|
|
|
|
|
|
34
|
return 1; |
71
|
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
# DEPRECATED |
75
|
|
|
|
|
|
|
|
sub user_id_string { |
76
|
2
|
|
|
|
2
|
0
|
140
|
my ( $self, $v ) = @_; |
77
|
2
|
100
|
|
|
|
|
31
|
$self->as_string($v) if defined $v; |
78
|
2
|
|
|
|
|
|
71
|
return $self->as_string(); |
79
|
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
__END__ |
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
GnuPG::UserId - GnuPG User ID Objects |
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
=head1 SYNOPSIS |
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
# assumes a GnuPG::PublicKey object in $publickey |
92
|
|
|
|
|
|
|
|
my $user_id = $publickey->user_ids_ref->[0]->as_string; |
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
GnuPG::UserId objects are generally not instantiated on their |
97
|
|
|
|
|
|
|
|
own, but rather as part of GnuPG::PublicKey or GnuPG::SecretKey |
98
|
|
|
|
|
|
|
|
objects. |
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
=item new( I<%initialization_args> ) |
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
This methods creates a new object. The optional arguments are |
107
|
|
|
|
|
|
|
|
initialization of data members; |
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
=item compare( I<$other>, I<$deep> ) |
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
Returns non-zero only when this User ID is identical to the other |
112
|
|
|
|
|
|
|
|
GnuPG::UserID. If $deep is present and non-zero, the User ID's |
113
|
|
|
|
|
|
|
|
signatures and revocations will also be compared. |
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
=back |
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
=head1 OBJECT DATA MEMBERS |
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
=over 4 |
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
=item as_string |
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
A string of the user id. |
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
=item validity |
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
A scalar holding the value GnuPG reports for the trust of authenticity |
128
|
|
|
|
|
|
|
|
(a.k.a.) validity of a key. |
129
|
|
|
|
|
|
|
|
See GnuPG's DETAILS file for details. |
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
=item signatures |
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
A list of GnuPG::Signature objects embodying the signatures |
134
|
|
|
|
|
|
|
|
on this user id. |
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
=item revocations |
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
A list of revocations associated with this User ID, stored as |
139
|
|
|
|
|
|
|
|
GnuPG::Signature objects (since revocations are a type of |
140
|
|
|
|
|
|
|
|
certification as well). |
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
=back |
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
=head1 SEE ALSO |
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
L<GnuPG::Signature>, |
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
=cut |