| 1 | |||
| 2 | package Slackware::Slackget::GPG::Signature; | ||
| 3 | |||
| 4 | use warnings; | ||
| 5 | use strict; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Slackware::Slackget::GPG::Signature - A simple class to represent an output of gpg signature verification. | ||
| 10 | |||
| 11 | =head1 VERSION | ||
| 12 | |||
| 13 | Version 0.5 | ||
| 14 | |||
| 15 | =cut | ||
| 16 | |||
| 17 | our $VERSION = '0.5'; | ||
| 18 | |||
| 19 | =head1 SYNOPSIS | ||
| 20 | |||
| 21 | A simple class to represent an output of gpg signature verification. This class parse the output of the 'gpg' command line tool. | ||
| 22 | |||
| 23 | use Slackware::Slackget::GPG::Signature; | ||
| 24 | |||
| 25 | my $slackget_gpg_signature_object = Slackware::Slackget::GPG::Signature->new(); | ||
| 26 | |||
| 27 | =cut | ||
| 28 | |||
| 29 | =head1 CONSTRUCTOR | ||
| 30 | |||
| 31 | new() : The constructor take the followings arguments : | ||
| 32 | |||
| 33 | - key_id : the id of the key which have been use to sign the file | ||
| 34 | |||
| 35 | - warnings : an array reference which contains all | ||
| 36 | |||
| 37 | - status : GOOD, BAD or UNKNOW the status of the verification | ||
| 38 | |||
| 39 | - date : date the signature was made | ||
| 40 | |||
| 41 | - emitter : the signature emitter. | ||
| 42 | |||
| 43 | - fingerprint : the primary key fingerprint. | ||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | sub new | ||
| 50 | { | ||
| 51 | my ($class,%args) = @_ ; | ||
| 52 | my $self={}; | ||
| 53 | $self->{DATA}->{key_id} = undef ; | ||
| 54 | $self->{DATA}->{key_id} = $args{key_id} if(exists($args{key_id}) && defined($args{key_id})); | ||
| 55 | $self->{DATA}->{'warnings'} = [] ; | ||
| 56 | $self->{DATA}->{'warnings'} = $args{warnings} if(exists($args{warnings}) && defined($args{warnings})); | ||
| 57 | $self->{DATA}->{status} = undef ; | ||
| 58 | $self->{DATA}->{status} = $args{status} if(exists($args{status}) && defined($args{status})); | ||
| 59 | $self->{DATA}->{date} = undef ; | ||
| 60 | $self->{DATA}->{date} = $args{date} if(exists($args{date}) && defined($args{date})); | ||
| 61 | $self->{DATA}->{emitter} = undef ; | ||
| 62 | $self->{DATA}->{emitter} = $args{emitter} if(exists($args{emitter}) && defined($args{emitter})); | ||
| 63 | $self->{DATA}->{fingerprint} = undef ; | ||
| 64 | $self->{DATA}->{fingerprint} = $args{fingerprint} if(exists($args{fingerprint}) && defined($args{fingerprint})); | ||
| 65 | bless($self,$class); | ||
| 66 | return $self; | ||
| 67 | } | ||
| 68 | |||
| 69 | =head1 METHODS | ||
| 70 | |||
| 71 | =head2 is_good | ||
| 72 | |||
| 73 | True if the signature is good, false otherwise. | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | sub is_good | ||
| 78 | { | ||
| 79 | my ($self) = @_; | ||
| 80 | return ($self->{DATA}->{status} eq 'GOOD') ? 1 : 0 ; | ||
| 81 | } | ||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | =head1 ACCESSORS | ||
| 86 | |||
| 87 | |||
| 88 | =head2 key_id | ||
| 89 | |||
| 90 | Accessor for the key_id constructor's parameter. Return a scalar. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | sub key_id | ||
| 95 | { | ||
| 96 | return $_[1] ? $_[0]->{DATA}->{key_id}=$_[1] : $_[0]->{DATA}->{key_id}; | ||
| 97 | } | ||
| 98 | |||
| 99 | =head2 warnings | ||
| 100 | |||
| 101 | Accessor for the warnings constructor's parameter. Return a hashref. | ||
| 102 | |||
| 103 | =cut | ||
| 104 | |||
| 105 | sub warnings | ||
| 106 | { | ||
| 107 | return $_[1] ? $_[0]->{DATA}->{'warnings'}=$_[1] : $_[0]->{DATA}->{'warnings'}; | ||
| 108 | } | ||
| 109 | |||
| 110 | =head2 status | ||
| 111 | |||
| 112 | Accessor for the status constructor's parameter. Return a scalar. | ||
| 113 | |||
| 114 | =cut | ||
| 115 | |||
| 116 | sub status | ||
| 117 | { | ||
| 118 | return $_[1] ? $_[0]->{DATA}->{status}=$_[1] : $_[0]->{DATA}->{status}; | ||
| 119 | } | ||
| 120 | |||
| 121 | =head2 date | ||
| 122 | |||
| 123 | Accessor for the date constructor's parameter. Return a scalar. | ||
| 124 | |||
| 125 | =cut | ||
| 126 | |||
| 127 | sub date | ||
| 128 | { | ||
| 129 | return $_[1] ? $_[0]->{DATA}->{date}=$_[1] : $_[0]->{DATA}->{date}; | ||
| 130 | } | ||
| 131 | |||
| 132 | =head2 emitter | ||
| 133 | |||
| 134 | Accessor for the emitter constructor's parameter. Return a scalar. | ||
| 135 | |||
| 136 | =cut | ||
| 137 | |||
| 138 | sub emitter | ||
| 139 | { | ||
| 140 | return $_[1] ? $_[0]->{DATA}->{emitter}=$_[1] : $_[0]->{DATA}->{emitter}; | ||
| 141 | } | ||
| 142 | |||
| 143 | =head2 fingerprint | ||
| 144 | |||
| 145 | Accessor for the fingerprint constructor's parameter. Return a scalar. | ||
| 146 | |||
| 147 | =cut | ||
| 148 | |||
| 149 | sub fingerprint | ||
| 150 | { | ||
| 151 | return $_[1] ? $_[0]->{DATA}->{fingerprint}=$_[1] : $_[0]->{DATA}->{fingerprint}; | ||
| 152 | } | ||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | =head1 AUTHOR | ||
| 157 | |||
| 158 | DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >> | ||
| 159 | |||
| 160 | =head1 BUGS | ||
| 161 | |||
| 162 | Please report any bugs or feature requests to | ||
| 163 | C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at | ||
| 164 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>. | ||
| 165 | I will be notified, and then you'll automatically be notified of progress on | ||
| 166 | your bug as I make changes. | ||
| 167 | |||
| 168 | =head1 SUPPORT | ||
| 169 | |||
| 170 | You can find documentation for this module with the perldoc command. | ||
| 171 | |||
| 172 | perldoc Slackware::Slackget::GPG::Signature | ||
| 173 | |||
| 174 | |||
| 175 | You can also look for information at: | ||
| 176 | |||
| 177 | =over 4 | ||
| 178 | |||
| 179 | =item * Infinity Perl website | ||
| 180 | |||
| 181 | L<http://www.infinityperl.org> | ||
| 182 | |||
| 183 | =item * slack-get specific website | ||
| 184 | |||
| 185 | L<http://slackget.infinityperl.org> | ||
| 186 | |||
| 187 | =item * RT: CPAN's request tracker | ||
| 188 | |||
| 189 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget> | ||
| 190 | |||
| 191 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 192 | |||
| 193 | L<http://annocpan.org/dist/Slackware-Slackget> | ||
| 194 | |||
| 195 | =item * CPAN Ratings | ||
| 196 | |||
| 197 | L<http://cpanratings.perl.org/d/Slackware-Slackget> | ||
| 198 | |||
| 199 | =item * Search CPAN | ||
| 200 | |||
| 201 | L<http://search.cpan.org/dist/Slackware-Slackget> | ||
| 202 | |||
| 203 | =back | ||
| 204 | |||
| 205 | =head1 ACKNOWLEDGEMENTS | ||
| 206 | |||
| 207 | Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. | ||
| 208 | |||
| 209 | =head1 SEE ALSO | ||
| 210 | |||
| 211 | =head1 COPYRIGHT & LICENSE | ||
| 212 | |||
| 213 | Copyright 2005 DUPUIS Arnaud, All Rights Reserved. | ||
| 214 | |||
| 215 | This program is free software; you can redistribute it and/or modify it | ||
| 216 | under the same terms as Perl itself. | ||
| 217 | |||
| 218 | =cut | ||
| 219 | |||
| 220 | 1; # Fin de Slackware::Slackget::GPG::Signature | ||
| 221 |