File Coverage

blib/lib/Net/DRI/Protocol/RRP/Core/Session.pm
Criterion Covered Total %
statement 13 35 37.1
branch 0 8 0.0
condition 0 15 0.0
subroutine 4 8 50.0
pod 0 5 0.0
total 17 71 23.9


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, RRP Session commands
2             ##
3             ## Copyright (c) 2005,2013 Patrick Mevzek . All rights reserved.
4             ##
5             ## This file is part of Net::DRI
6             ##
7             ## Net::DRI is free software; you can redistribute it and/or modify
8             ## it under the terms of the GNU General Public License as published by
9             ## the Free Software Foundation; either version 2 of the License, or
10             ## (at your option) any later version.
11             ##
12             ## See the LICENSE file that comes with this distribution for more details.
13             #########################################################################################
14              
15             package Net::DRI::Protocol::RRP::Core::Session;
16              
17 2     2   2082 use strict;
  2         4  
  2         77  
18 2     2   9 use warnings;
  2         2  
  2         53  
19              
20 2     2   424 use Net::DRI::Exception;
  2         4  
  2         554  
21              
22             =pod
23              
24             =head1 NAME
25              
26             Net::DRI::Protocol::RRP::Core::Session - RRP Session commands for Net::DRI
27              
28             =head1 DESCRIPTION
29              
30             Please see the README file for details.
31              
32             =head1 SUPPORT
33              
34             For now, support questions should be sent to:
35              
36             Enetdri@dotandco.comE
37              
38             Please also see the SUPPORT file in the distribution.
39              
40             =head1 SEE ALSO
41              
42             Ehttp://www.dotandco.com/services/software/Net-DRI/E
43              
44             =head1 AUTHOR
45              
46             Patrick Mevzek, Enetdri@dotandco.comE
47              
48             =head1 COPYRIGHT
49              
50             Copyright (c) 2005,2013 Patrick Mevzek .
51             All rights reserved.
52              
53             This program is free software; you can redistribute it and/or modify
54             it under the terms of the GNU General Public License as published by
55             the Free Software Foundation; either version 2 of the License, or
56             (at your option) any later version.
57              
58             See the LICENSE file that comes with this distribution for more details.
59              
60             =cut
61              
62              
63             ###############################################################################
64              
65             sub register_commands
66             {
67 1     1 0 4 my ($class,$version)=@_;
68 1         7 my %tmp=( _describe => [ \&describe, \&describe_parse ],
69             logout => [ \&quit ],
70             login => [ \&session ],
71             );
72              
73 1         3 $tmp{noop}=$tmp{_describe}; ## alias for keepalive
74 1         6 return { 'session' => \%tmp };
75             }
76              
77             sub describe
78             {
79 0     0 0   my ($rrp,$what)=@_;
80 0           my $mes=$rrp->message();
81 0           $mes->command('describe');
82 0 0         $mes->options('Target',$what) if $what;
83 0           return;
84             }
85              
86             sub describe_parse
87             {
88 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
89 0           my $mes=$po->message();
90 0 0         return unless $mes->is_success();
91              
92 0           $rinfo->{session}->{describe}->{protocol}=$mes->entities('protocol');
93 0           return;
94             }
95              
96             sub quit
97             {
98 0     0 0   my ($rrp)=@_;
99 0           my $mes=$rrp->message();
100 0           $mes->command('quit');
101 0           return;
102             }
103              
104             sub session
105             {
106 0     0 0   my ($rrp,$id,$pass,$newpass)=@_;
107 0 0 0       Net::DRI::Exception::usererr_insufficient_parameters('login & password') unless (defined($id) && $id && defined($pass) && $pass);
      0        
      0        
108              
109 0           my $mes=$rrp->message();
110 0           $mes->command('session');
111 0           $mes->options('Id',$id);
112 0           $mes->options('Password',$pass);
113 0 0 0       $mes->options('NewPassword',$newpass) if (defined($newpass) && $newpass && ($newpass ne $pass));
      0        
114 0           return;
115             }
116              
117             ###############################################################################################
118             1;