| 1 | ## Domain Registry Interface, OpenSRS XCP Connection handling | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2008-2010,2013 Patrick Mevzek <netdri@dotandco.com>. 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::OpenSRS::XCP::Connection; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Digest::MD5 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use HTTP::Request (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Net::DRI::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Net::DRI::Data::Raw; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Net::DRI::Protocol::ResultStatus; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =pod | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | Net::DRI::Protocol::OpenSRS::XCP::Connection - OpenSRS XCP Connection handling for Net::DRI | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | Please see the README file for details. | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | Copyright (c) 2008-2010,2013 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||
| 57 | All rights reserved. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 60 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 61 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 62 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | #################################################################################################### | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | sub init | ||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my ($class,$to)=@_; | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 0 | my $t=$to->transport_data(); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | foreach my $p (qw/client_login client_password remote_url/) | |||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | Net::DRI::Exception::usererr_insufficient_parameters($p.' must be defined') unless (exists($t->{$p}) && $t->{$p}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $t->{$p} and $t->{$p}
MC/DC0%0/2
exists $t->{$p} and $t->{$p}
exists $t->{$p}
$t->{$p}
Truth table0%0/3
A and B
A= exists $t->{$p}B= $t->{$p}
| |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | 0 | return; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | ## From Protocol Message object to something suitable for transport (various types) | ||||||||||||||||||||||||||||
| 83 | sub write_message | ||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my ($class,$to,$msg)=@_; | ||||||||||||||||||||||||||
|
Subroutine
write_message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 0 | my $t=$to->transport_data(); | |||||||||||||||||||||||||||
| 87 | 0 | my $req=HTTP::Request->new('POST',$t->{remote_url}); | |||||||||||||||||||||||||||
| 88 | 0 | $req->header('Content-Type','text/xml'); | |||||||||||||||||||||||||||
| 89 | 0 | $req->header('X-Username',$t->{client_login}); | |||||||||||||||||||||||||||
| 90 | 0 | my $body=Net::DRI::Util::encode_utf8($msg->get_body()); | |||||||||||||||||||||||||||
| 91 | 0 | $req->header('X-Signature',Digest::MD5::md5_hex(Digest::MD5::md5_hex($body,$t->{client_password}),$t->{client_password})); ## client_password is in fact the reseller key | |||||||||||||||||||||||||||
| 92 | 0 | $req->content($body); | |||||||||||||||||||||||||||
| 93 | ## Content-Length will be automatically computed during Transport by LWP::UserAgent | ||||||||||||||||||||||||||||
| 94 | 0 | return $req; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | ## From transport (various types) to Net::DRI::Data::Raw object (which will be parsed inside Protocol::reaction) | ||||||||||||||||||||||||||||
| 98 | sub read_data | ||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my ($class,$to,$res)=@_; | ||||||||||||||||||||||||||
|
Subroutine
read_data: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_FAILED_CLOSING',sprintf('Got unsuccessfull HTTP response: %d %s',$res->code(),$res->message()),'en')) unless $res->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | return Net::DRI::Data::Raw->new_from_xmlstring($res->decoded_content()); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | #################################################################################################### | ||||||||||||||||||||||||||||
| 106 | 1 | 1; | |||||||||||||||||||||||||||