home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / perl5 / GnuPG / UserId.pm < prev   
Encoding:
Perl POD Document  |  2010-06-05  |  3.2 KB  |  150 lines

  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. use Any::Moose;
  18.  
  19. has [qw( validity as_string )] => (
  20.     isa => 'Any',
  21.     is  => 'rw',
  22. );
  23.  
  24. has signatures => (
  25.     isa       => 'ArrayRef',
  26.     is        => 'rw',
  27.     default   => sub { [] },
  28. );
  29. has revocations => (
  30.     isa       => 'ArrayRef',
  31.     is        => 'rw',
  32.     default   => sub { [] },
  33. );
  34.  
  35. sub push_signatures {
  36.     my $self = shift;
  37.     push @{ $self->signatures }, @_;
  38. }
  39. sub push_revocations {
  40.     my $self = shift;
  41.     push @{ $self->revocations }, @_;
  42. }
  43.  
  44. sub compare {
  45.   my ( $self, $other, $deep ) = @_;
  46.  
  47.   my @comparison_ints = qw( validity as_string );
  48.  
  49.   foreach my $field ( @comparison_ints ) {
  50.     return 0 unless $self->$field() eq $other->$field();
  51.   }
  52.  
  53.   return 0 unless @{$self->signatures} == @{$other->signatures};
  54.   return 0 unless @{$self->revocations} == @{$other->revocations};
  55.  
  56.   # FIXME: is it actually wrong if the associated signatures come out
  57.   # in a different order on the two compared designated revokers?
  58.   if (defined $deep && $deep) {
  59.     for ( my $i = 0; $i < scalar(@{$self->signatures}); $i++ ) {
  60.       return 0
  61.         unless $self->signatures->[$i]->compare($other->signatures->[$i], 1);
  62.     }
  63.     for ( my $i = 0; $i < scalar(@{$self->revocations}); $i++ ) {
  64.       return 0
  65.         unless $self->revocations->[$i]->compare($other->revocations->[$i], 1);
  66.     }
  67.   }
  68.  
  69.   return 1;
  70. }
  71.  
  72.  
  73. # DEPRECATED
  74. sub user_id_string {
  75.     my ( $self, $v ) = @_;
  76.     $self->as_string($v) if defined $v;
  77.     return $self->as_string();
  78. }
  79.  
  80. __PACKAGE__->meta->make_immutable;
  81.  
  82. 1;
  83.  
  84. __END__
  85.  
  86. =head1 NAME
  87.  
  88. GnuPG::UserId - GnuPG User ID Objects
  89.  
  90. =head1 SYNOPSIS
  91.  
  92.   # assumes a GnuPG::PublicKey object in $publickey
  93.   my $user_id = $publickey->user_ids_ref->[0]->as_string;
  94.  
  95. =head1 DESCRIPTION
  96.  
  97. GnuPG::UserId objects are generally not instantiated on their
  98. own, but rather as part of GnuPG::PublicKey or GnuPG::SecretKey
  99. objects.
  100.  
  101. =head1 OBJECT METHODS
  102.  
  103. =over 4
  104.  
  105. =item new( I<%initialization_args> )
  106.  
  107. This methods creates a new object.  The optional arguments are
  108. initialization of data members;
  109.  
  110. =item compare( I<$other>, I<$deep> )
  111.  
  112. Returns non-zero only when this User ID is identical to the other
  113. GnuPG::UserID.  If $deep is present and non-zero, the User ID's
  114. signatures and revocations will also be compared.
  115.  
  116. =back
  117.  
  118. =head1 OBJECT DATA MEMBERS
  119.  
  120. =over 4
  121.  
  122. =item as_string
  123.  
  124. A string of the user id.
  125.  
  126. =item validity
  127.  
  128. A scalar holding the value GnuPG reports for the trust of authenticity
  129. (a.k.a.) validity of a key.
  130. See GnuPG's DETAILS file for details.
  131.  
  132. =item signatures
  133.  
  134. A list of GnuPG::Signature objects embodying the signatures
  135. on this user id.
  136.  
  137. =item revocations
  138.  
  139. A list of revocations associated with this User ID, stored as
  140. GnuPG::Signature objects (since revocations are a type of
  141. certification as well).
  142.  
  143. =back
  144.  
  145. =head1 SEE ALSO
  146.  
  147. L<GnuPG::Signature>,
  148.  
  149. =cut
  150.