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 / PrimaryKey.pm < prev    next >
Encoding:
Perl POD Document  |  2010-06-05  |  3.0 KB  |  143 lines

  1. #  PrimaryKey.pm
  2. #      - objectified GnuPG primary keys (can have subkeys)
  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: PrimaryKey.pm,v 1.4 2001/09/14 12:34:36 ftobin Exp $
  14. #
  15.  
  16. package GnuPG::PrimaryKey;
  17. use Any::Moose;
  18.  
  19. BEGIN { extends qw( GnuPG::Key ) }
  20.  
  21. for my $list (qw(user_ids subkeys user_attributes)) {
  22.     has $list => (
  23.         isa        => 'ArrayRef',
  24.         is         => 'rw',
  25.         default    => sub { [] },
  26.         auto_deref => 1,
  27.     );
  28.  
  29.     __PACKAGE__->meta->add_method("push_$list" => sub {
  30.         my $self = shift;
  31.         push @{ $self->$list }, @_;
  32.     });
  33. }
  34.  
  35. has $_ => (
  36.     isa     => 'Any',
  37.     is      => 'rw',
  38.     clearer => 'clear_' . $_,
  39. ) for qw( local_id owner_trust );
  40.  
  41.  
  42. sub compare {
  43.   my ($self, $other, $deep) = @_;
  44.  
  45.   # not comparing local_id because it is meaningless in modern
  46.   # versions of GnuPG.
  47.   my @comparison_fields = qw (
  48.      owner_trust
  49.   );
  50.  
  51.   foreach my $field (@comparison_fields) {
  52.     return 0 unless $self->$field eq $other->$field;
  53.   }
  54.  
  55.   if (defined $deep && $deep) {
  56.     my @lists = qw(
  57.       user_ids
  58.       subkeys
  59.       user_attributes
  60.                  );
  61.  
  62.     foreach my $list (@lists) {
  63.       return 0 unless @{$self->$list} == @{$other->$list};
  64.       for ( my $i = 0; $i < scalar(@{$self->$list}); $i++ ) {
  65.         return 0
  66.           unless $self->$list->[$i]->compare($other->$list->[$i], 1);
  67.       }
  68.     }
  69.   }
  70.  
  71.   return $self->SUPER::compare($other, $deep);
  72. }
  73.  
  74.  
  75. __PACKAGE__->meta->make_immutable;
  76.  
  77. 1;
  78.  
  79. __END__
  80.  
  81. =head1 NAME
  82.  
  83. GnuPG::PrimaryKey - GnuPG Primary Key Objects
  84.  
  85. =head1 SYNOPSIS
  86.  
  87.   # assumes a GnuPG::Interface object in $gnupg
  88.   my @keys = $gnupg->get_public_keys( 'ftobin' );
  89.  
  90.   # or
  91.  
  92.   my @keys = $gnupg->get_secret_keys( 'ftobin' );
  93.  
  94.   # now GnuPG::PrimaryKey objects are in @keys
  95.  
  96. =head1 DESCRIPTION
  97.  
  98. GnuPG::PrimaryKey objects are generally instantiated
  99. as GnuPG::PublicKey or GnuPG::SecretKey objects
  100. through various methods of GnuPG::Interface.
  101. They embody various aspects of a GnuPG primary key.
  102.  
  103. This package inherits data members and object methods
  104. from GnuPG::Key, which is not described here, but rather
  105. in L<GnuPG::Key>.
  106.  
  107. =head1 OBJECT DATA MEMBERS
  108.  
  109. =over 4
  110.  
  111. =item user_ids
  112.  
  113. A list of GnuPG::UserId objects associated with this key.
  114.  
  115. =item user_attributes
  116.  
  117. A list of GnuPG::UserAttribute objects associated with this key.
  118.  
  119. =item subkeys
  120.  
  121. A list of GnuPG::SubKey objects associated with this key.
  122.  
  123. =item local_id
  124.  
  125. WARNING: DO NOT USE.  This used to mean GnuPG's local id for the key,
  126. but modern versions of GnuPG do not produce it.  Expect this to be the
  127. empty string or undef.
  128.  
  129. =item owner_trust
  130.  
  131. The scalar value GnuPG reports as the ownertrust for this key.
  132. See GnuPG's DETAILS file for details.
  133.  
  134. =back
  135.  
  136. =head1 SEE ALSO
  137.  
  138. L<GnuPG::Key>,
  139. L<GnuPG::UserId>,
  140. L<GnuPG::SubKey>,
  141.  
  142. =cut
  143.