[Rt-commit] r10074 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Mon Dec 24 18:47:39 EST 2007
Author: ruz
Date: Mon Dec 24 18:47:39 2007
New Revision: 10074
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm
Log:
r9826 at cubic-pc (orig r9825): ruz | 2007-12-05 21:39:02 +0300
* add GetKeysForSigning function that return keys suitable for
signing by key identifier(email, fpr or id)
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm Mon Dec 24 18:47:39 2007
@@ -1623,6 +1623,27 @@
return %res;
}
+sub GetKeysForSigning {
+ my $key_id = shift;
+ my %res = GetKeysInfo( $key_id, 'private' );
+ return %res if $res{'exit_code'};
+ return %res unless $res{'info'};
+
+ foreach my $key ( splice @{ $res{'info'} } ) {
+ # skip disabled keys
+ next if $key->{'Capabilities'} =~ /D/;
+ # skip keys not suitable for signing
+ next unless $key->{'Capabilities'} =~ /s/i;
+ # skip disabled, expired, revoke and keys with no trust,
+ # but leave keys with unknown trust level
+ next if $key->{'TrustLevel'} < 0;
+
+ push @{ $res{'info'} }, $key;
+ }
+ delete $res{'info'} unless @{ $res{'info'} };
+ return %res;
+}
+
sub CheckRecipients {
my @recipients = (@_);
More information about the Rt-commit
mailing list