| 1 | ########################################### | ||||||||||
| 2 | package Net::SSH::AuthorizedKey::SSH1; | ||||||||||
| 3 | ########################################### | ||||||||||
| 4 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 12 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 12 | ▶ | use Net::SSH::AuthorizedKey::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 12 | ▶ | use base qw(Net::SSH::AuthorizedKey::Base); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 12 | ▶ | use Log::Log4perl qw(:easy); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 12 | our @REQUIRED_FIELDS = qw( | |||||||||
| 11 | keylen exponent | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 12 | __PACKAGE__->make_accessor( $_ ) for @REQUIRED_FIELDS; | |||||||||
| 15 | |||||||||||
| 16 | # No additional options, only global ones | ||||||||||
| 17 | 12 | our %VALID_OPTIONS = (); | |||||||||
| 18 | |||||||||||
| 19 | ########################################### | ||||||||||
| 20 | 17 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 21 | ########################################### | ||||||||||
| 22 | 17 | my($class, %options) = @_; | |||||||||
| 23 | |||||||||||
| 24 | 17 | return $class->SUPER::new( %options, type => "ssh-1" ); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | ########################################### | ||||||||||
| 28 | 126 | ▶ | sub key_read { | ||||||||
|
Subroutine
key_read: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 29 | ############################################ | ||||||||||
| 30 | 126 | my($class, $line) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 126 | ▶ | if($line !~ s/^(\d+)\s*//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 106 | DEBUG "Cannot find ssh-1 keylen"; | |||||||||
| 34 | 106 | return undef; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 20 | my $keylen = $1; | |||||||||
| 38 | 20 | DEBUG "Parsed keylen: $keylen"; | |||||||||
| 39 | |||||||||||
| 40 | 20 | ▶ | if($line !~ s/^(\d+)\s*//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 2 | DEBUG "Cannot find ssh-1 exponent"; | |||||||||
| 42 | 2 | return undef; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 18 | my $exponent = $1; | |||||||||
| 46 | 18 | DEBUG "Parsed exponent: $exponent"; | |||||||||
| 47 | |||||||||||
| 48 | 18 | ▶ | if($line !~ s/^(\d+)\s*//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | DEBUG "Cannot find ssh-1 key"; | |||||||||
| 50 | 1 | return undef; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 17 | my $key = $1; | |||||||||
| 54 | 17 | DEBUG "Parsed key: $key"; | |||||||||
| 55 | |||||||||||
| 56 | 17 | my $obj = __PACKAGE__->new(); | |||||||||
| 57 | 17 | $obj->keylen( $keylen ); | |||||||||
| 58 | 17 | $obj->key( $key ); | |||||||||
| 59 | 17 | $obj->exponent( $exponent ); | |||||||||
| 60 | 17 | $obj->email( $line ); | |||||||||
| 61 | 17 | $obj->comment( $line ); | |||||||||
| 62 | |||||||||||
| 63 | 17 | return $obj; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | ########################################### | ||||||||||
| 67 | 22 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 68 | ########################################### | ||||||||||
| 69 | 22 | my($self) = @_; | |||||||||
| 70 | |||||||||||
| 71 | 22 | my $string = $self->options_as_string(); | |||||||||
| 72 | 22 | ▶ | $string .= " " if length $string; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | |||||||||||
| 74 | 22 | $string .= "$self->{keylen} $self->{exponent} $self->{key}"; | |||||||||
| 75 | 22 | ▶ | $string .= " $self->{email}" if length $self->{email}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | |||||||||||
| 77 | 22 | return $string; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | ########################################### | ||||||||||
| 81 | 2 | ▶ | sub sanity_check { | ||||||||
|
Subroutine
sanity_check: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||
| 82 | ########################################### | ||||||||||
| 83 | 2 | my($self) = @_; | |||||||||
| 84 | |||||||||||
| 85 | 2 | for my $field (@REQUIRED_FIELDS) { | |||||||||
| 86 | 4 | ▶ | if(! length $self->$field()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | 0 | WARN "ssh-1 sanity check failed '$field' requirement"; | |||||||||
| 88 | 0 | return undef; | |||||||||
| 89 | } | ||||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 2 | return 1; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | ########################################### | ||||||||||
| 96 | 0 | ▶ | sub option_type { | ||||||||
|
Subroutine
option_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 97 | ########################################### | ||||||||||
| 98 | 0 | my($self, $option) = @_; | |||||||||
| 99 | |||||||||||
| 100 | 0 | ▶ | if(exists $VALID_OPTIONS{ $option }) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | 0 | return $VALID_OPTIONS{ $option }; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 0 | return undef; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 12 | 1; | |||||||||
| 108 | |||||||||||
| 109 | __END__ | ||||||||||