| 1 | ########################################### | ||||||||||
| 2 | package Net::SSH::AuthorizedKey::SSH1; | ||||||||||
| 3 | ########################################### | ||||||||||
| 4 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 11 | ▶ | use Net::SSH::AuthorizedKey::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 11 | ▶ | use base qw(Net::SSH::AuthorizedKey::Base); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 11 | ▶ | use Log::Log4perl qw(:easy); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 11 | our @REQUIRED_FIELDS = qw( | |||||||||
| 11 | keylen exponent | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 11 | __PACKAGE__->make_accessor( $_ ) for @REQUIRED_FIELDS; | |||||||||
| 15 | |||||||||||
| 16 | # No additional options, only global ones | ||||||||||
| 17 | 11 | our %VALID_OPTIONS = (); | |||||||||
| 18 | |||||||||||
| 19 | ########################################### | ||||||||||
| 20 | sub new { | ||||||||||
| 21 | ########################################### | ||||||||||
| 22 | 15 | ▶ | my($class, %options) = @_; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 23 | |||||||||||
| 24 | 15 | return $class->SUPER::new( %options, type => "ssh-1" ); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | ########################################### | ||||||||||
| 28 | sub key_read { | ||||||||||
| 29 | ############################################ | ||||||||||
| 30 | 122 | ▶ | my($class, $line) = @_; | ||||||||
|
Subroutine
key_read: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 31 | |||||||||||
| 32 | 122 | ▶ | if($line !~ s/^(\d+)\s*//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 104 | DEBUG "Cannot find ssh-1 keylen"; | |||||||||
| 34 | 104 | return undef; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 18 | my $keylen = $1; | |||||||||
| 38 | 18 | DEBUG "Parsed keylen: $keylen"; | |||||||||
| 39 | |||||||||||
| 40 | 18 | ▶ | if($line !~ s/^(\d+)\s*//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 2 | DEBUG "Cannot find ssh-1 exponent"; | |||||||||
| 42 | 2 | return undef; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 16 | my $exponent = $1; | |||||||||
| 46 | 16 | DEBUG "Parsed exponent: $exponent"; | |||||||||
| 47 | |||||||||||
| 48 | 16 | ▶ | if($line !~ s/^(\d+)\s*//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | DEBUG "Cannot find ssh-1 key"; | |||||||||
| 50 | 1 | return undef; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 15 | my $key = $1; | |||||||||
| 54 | 15 | DEBUG "Parsed key: $key"; | |||||||||
| 55 | |||||||||||
| 56 | 15 | my $obj = __PACKAGE__->new(); | |||||||||
| 57 | 15 | $obj->keylen( $keylen ); | |||||||||
| 58 | 15 | $obj->key( $key ); | |||||||||
| 59 | 15 | $obj->exponent( $exponent ); | |||||||||
| 60 | 15 | $obj->email( $line ); | |||||||||
| 61 | 15 | $obj->comment( $line ); | |||||||||
| 62 | |||||||||||
| 63 | 15 | return $obj; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | ########################################### | ||||||||||
| 67 | sub as_string { | ||||||||||
| 68 | ########################################### | ||||||||||
| 69 | 20 | ▶ | my($self) = @_; | ||||||||
|
Subroutine
as_string: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 70 | |||||||||||
| 71 | 20 | my $string = $self->options_as_string(); | |||||||||
| 72 | 20 | ▶ | $string .= " " if length $string; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | |||||||||||
| 74 | 20 | $string .= "$self->{keylen} $self->{exponent} $self->{key}"; | |||||||||
| 75 | 20 | ▶ | $string .= " $self->{email}" if length $self->{email}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | |||||||||||
| 77 | 20 | return $string; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | ########################################### | ||||||||||
| 81 | sub sanity_check { | ||||||||||
| 82 | ########################################### | ||||||||||
| 83 | 2 | ▶ | my($self) = @_; | ||||||||
|
Subroutine
sanity_check: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||
| 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 | sub option_type { | ||||||||||
| 97 | ########################################### | ||||||||||
| 98 | 0 | ▶ | my($self, $option) = @_; | ||||||||
|
Subroutine
option_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 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 | 11 | 1; | |||||||||
| 108 | |||||||||||
| 109 | __END__ | ||||||||||
| 110 | |||||||||||
| 111 | =head1 NAME | ||||||||||
| 112 | |||||||||||
| 113 | Net::SSH::AuthorizedKey::SSH1 - Net::SSH::AuthorizedKey subclass for ssh-1 | ||||||||||
| 114 | |||||||||||
| 115 | =head1 DESCRIPTION | ||||||||||
| 116 | |||||||||||
| 117 | See Net::SSH::AuthorizedKey. | ||||||||||
| 118 | |||||||||||
| 119 | =head1 LEGALESE | ||||||||||
| 120 | |||||||||||
| 121 | Copyright 2005 by Mike Schilli, all rights reserved. | ||||||||||
| 122 | This program is free software, you can redistribute it and/or | ||||||||||
| 123 | modify it under the same terms as Perl itself. | ||||||||||
| 124 | |||||||||||
| 125 | =head1 AUTHOR | ||||||||||
| 126 | |||||||||||
| 127 | 2005, Mike Schilli <m@perlmeister.com> | ||||||||||