| 1 | package PGP::Finger::GPG; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | |||
| 5 | extends 'PGP::Finger::Source'; | ||
| 6 | |||
| 7 | # ABSTRACT: gpgfinger source to query local gnupg | ||
| 8 | our $VERSION = '1.0'; # VERSION | ||
| 9 | |||
| 10 | use PGP::Finger::Result; | ||
| 11 | use PGP::Finger::Key; | ||
| 12 | |||
| 13 | use IPC::Run qw(run); | ||
| 14 | |||
| 15 | has 'cmd' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, | ||
| 16 | default => sub { [ '/usr/bin/gpg', '--export' ] }, | ||
| 17 | ); | ||
| 18 | |||
| 19 | sub fetch { | ||
| 20 | my ( $self, $addr ) = @_; | ||
| 21 | my @cmd = ( @{$self->cmd}, $addr ); | ||
| 22 | my ( $in, $out, $err ); | ||
| 23 | run( \@cmd, \$in, \$out, \$err ) | ||
| 24 | or die('error running gpg: '.$err.' ('.$!.')'); | ||
| 25 | |||
| 26 | my $result = PGP::Finger::Result->new; | ||
| 27 | my $key = PGP::Finger::Key->new( | ||
| 28 | mail => $addr, | ||
| 29 | data => $out, | ||
| 30 | ); | ||
| 31 | $key->set_attr( source => 'local GnuPG' ); | ||
| 32 | |||
| 33 | $result->add_key( $key ); | ||
| 34 | return $result; | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; | ||
| 38 | |||
| 39 | __END__ | ||
| 40 | |||
| 41 | =pod | ||
| 42 | |||
| 43 | =encoding UTF-8 | ||
| 44 | |||
| 45 | =head1 NAME | ||
| 46 | |||
| 47 | PGP::Finger::GPG - gpgfinger source to query local gnupg | ||
| 48 | |||
| 49 | =head1 VERSION | ||
| 50 | |||
| 51 | version 1.0 | ||
| 52 | |||
| 53 | =head1 AUTHOR | ||
| 54 | |||
| 55 | Markus Benning <ich@markusbenning.de> | ||
| 56 | |||
| 57 | =head1 COPYRIGHT AND LICENSE | ||
| 58 | |||
| 59 | This software is Copyright (c) 2015 by Markus Benning. | ||
| 60 | |||
| 61 | This is free software, licensed under: | ||
| 62 | |||
| 63 | The GNU General Public License, Version 2 or later | ||
| 64 | |||
| 65 | =cut |