File Coverage

blib/lib/Net/DRI/Protocol/RRI/Session.pm
Criterion Covered Total %
statement 12 35 34.2
branch 0 6 0.0
condition 0 9 0.0
subroutine 4 8 50.0
pod 0 4 0.0
total 16 62 25.8


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, RRI Session commands (DENIC-11)
2             ##
3             ## Copyright (c) 2007,2012 Tonnerre Lombard . All rights reserved.
4             ## (c) 2013 Michael Holloway . All rights reserved.
5             ##
6             ## This file is part of Net::DRI
7             ##
8             ## Net::DRI is free software; you can redistribute it and/or modify
9             ## it under the terms of the GNU General Public License as published by
10             ## the Free Software Foundation; either version 2 of the License, or
11             ## (at your option) any later version.
12             ##
13             ## See the LICENSE file that comes with this distribution for more details.
14             ####################################################################################################
15              
16             package Net::DRI::Protocol::RRI::Session;
17              
18 1     1   1616 use strict;
  1         2  
  1         28  
19 1     1   5 use warnings;
  1         2  
  1         21  
20              
21 1     1   6 use Net::DRI::Exception;
  1         2  
  1         16  
22 1     1   3 use Net::DRI::Util;
  1         2  
  1         290  
23              
24             =pod
25              
26             =head1 NAME
27              
28             Net::DRI::Protocol::RRI::Session - RRI Session commands (DENIC-11) for Net::DRI
29              
30             =head1 DESCRIPTION
31              
32             Please see the README file for details.
33              
34             =head1 SUPPORT
35              
36             For now, support questions should be sent to:
37              
38             Etonnerre.lombard@sygroup.chE
39              
40             Please also see the SUPPORT file in the distribution.
41              
42             =head1 SEE ALSO
43              
44             Ehttp://oss.bsdprojects.net/projects/netdri/E
45              
46             =head1 AUTHOR
47              
48             Tonnerre Lombard, Etonnerre.lombard@sygroup.chE
49              
50             =head1 COPYRIGHT
51              
52             Copyright (c) 2007,2013 Tonnerre Lombard .
53             All rights reserved.
54              
55             This program is free software; you can redistribute it and/or modify
56             it under the terms of the GNU General Public License as published by
57             the Free Software Foundation; either version 2 of the License, or
58             (at your option) any later version.
59              
60             See the LICENSE file that comes with this distribution for more details.
61              
62             =cut
63              
64             ####################################################################################################
65              
66             sub register_commands
67             {
68 0     0 0   my ($class,$version)=@_;
69 0           my %tmp=(
70             noop => [ \&hello ],
71             logout => [ \&logout ],
72             login => [ \&login ],
73             );
74              
75 0           return { 'session' => \%tmp };
76             }
77              
78             sub hello ## should trigger a greeting from server, allowed at any time
79             {
80 0     0 0   my ($rri)=@_;
81 0           my $mes=$rri->message();
82 0           $mes->command(['hello']);
83 0           return;
84             }
85              
86             sub logout
87             {
88 0     0 0   my ($rri)=@_;
89 0           my $mes=$rri->message();
90 0           $mes->command(['logout']);
91 0           return;
92             }
93              
94             sub login
95             {
96 0     0 0   my ($rri,$id,$pass,$newpass,$opts)=@_;
97 0 0 0       Net::DRI::Exception::usererr_insufficient_parameters('login & password') unless (defined($id) && $id && defined($pass) && $pass);
      0        
      0        
98              
99 0 0         Net::DRI::Exception::usererr_invalid_parameters('login') unless Net::DRI::Util::xml_is_token($id,3,32);
100 0 0         Net::DRI::Exception::usererr_invalid_parameters('password') unless Net::DRI::Util::xml_is_token($pass,6,32);
101              
102 0           my $mes=$rri->message();
103 0           $mes->command(['login']);
104 0           my @d;
105 0           push @d,['user',$id];
106 0           push @d,['password',$pass];
107 0           $mes->cltrid(undef); # login fails with this
108 0           $mes->command_body(\@d);
109 0           return;
110             }
111              
112             ####################################################################################################
113             1;