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