| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ## Domain Registry Interface, nic.at domain transactions extension | 
| 2 |  |  |  |  |  |  | ## Contributed by Michael Braunoeder from NIC.AT | 
| 3 |  |  |  |  |  |  | ## Extended by Tonnerre Lombard | 
| 4 |  |  |  |  |  |  | ## | 
| 5 |  |  |  |  |  |  | ## Copyright (c) 2006-2008,2010,2013 Patrick Mevzek . All rights reserved. | 
| 6 |  |  |  |  |  |  | ## | 
| 7 |  |  |  |  |  |  | ## This file is part of Net::DRI | 
| 8 |  |  |  |  |  |  | ## | 
| 9 |  |  |  |  |  |  | ## Net::DRI is free software; you can redistribute it and/or modify | 
| 10 |  |  |  |  |  |  | ## it under the terms of the GNU General Public License as published by | 
| 11 |  |  |  |  |  |  | ## the Free Software Foundation; either version 2 of the License, or | 
| 12 |  |  |  |  |  |  | ## (at your option) any later version. | 
| 13 |  |  |  |  |  |  | ## | 
| 14 |  |  |  |  |  |  | ## See the LICENSE file that comes with this distribution for more details. | 
| 15 |  |  |  |  |  |  | #################################################################################################### | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | package Net::DRI::Protocol::EPP::Extensions::AT::Message; | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 1 |  |  | 1 |  | 920 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 27 |  | 
| 20 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 1 |  |  | 1 |  | 4 | use Net::DRI::Exception; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 824 |  | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | our $NS='http://www.nic.at/xsd/at-ext-message-1.0'; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =pod | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =head1 NAME | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | Net::DRI::Protocol::EPP::Extensions::AT::Message - NIC.AT Message EPP Mapping for Net::DRI | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | Please see the README file for details. | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =head1 SUPPORT | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | For now, support questions should be sent to: | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | Enetdri@dotandco.comE | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | Please also see the SUPPORT file in the distribution. | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | Ehttp://www.dotandco.com/services/software/Net-DRI/E | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | =head1 AUTHOR | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | Patrick Mevzek, Enetdri@dotandco.comE | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | Copyright (c) 2006-2008,2010,2013 Patrick Mevzek . | 
| 55 |  |  |  |  |  |  | All rights reserved. | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify | 
| 58 |  |  |  |  |  |  | it under the terms of the GNU General Public License as published by | 
| 59 |  |  |  |  |  |  | the Free Software Foundation; either version 2 of the License, or | 
| 60 |  |  |  |  |  |  | (at your option) any later version. | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | See the LICENSE file that comes with this distribution for more details. | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =cut | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | #################################################################################################### | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | sub register_commands | 
| 69 |  |  |  |  |  |  | { | 
| 70 | 0 |  |  | 0 | 0 |  | my ($class,$version)=@_; | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 0 |  |  |  |  |  | my %tmp=( | 
| 73 |  |  |  |  |  |  | atretrieve => [ \&pollreq, \&parse_poll ], | 
| 74 |  |  |  |  |  |  | atdelete   => [ \&pollack, undef ], | 
| 75 |  |  |  |  |  |  | ); | 
| 76 |  |  |  |  |  |  |  | 
| 77 | 0 |  |  |  |  |  | return { 'message' => \%tmp }; | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | sub pollack | 
| 81 |  |  |  |  |  |  | { | 
| 82 | 0 |  |  | 0 | 0 |  | my ($epp,$msgid)=@_; | 
| 83 | 0 |  |  |  |  |  | my $mes=$epp->message(); | 
| 84 | 0 |  |  |  |  |  | $mes->command([['poll',{op=>'ack',msgID=>$msgid}]]); | 
| 85 | 0 |  |  |  |  |  | return; | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | sub pollreq | 
| 89 |  |  |  |  |  |  | { | 
| 90 | 0 |  |  | 0 | 0 |  | my ($epp,$msgid)=@_; | 
| 91 | 0 | 0 |  |  |  |  | Net::DRI::Exception::usererr_invalid_parameters('In EPP, you can not specify the message id you want to retrieve') if defined($msgid); | 
| 92 | 0 |  |  |  |  |  | my $mes=$epp->message(); | 
| 93 | 0 |  |  |  |  |  | $mes->command([['poll',{op=>'req'}]]); | 
| 94 | 0 |  |  |  |  |  | return; | 
| 95 |  |  |  |  |  |  | } | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | ## We take into account all parse functions, to be able to parse any result | 
| 99 |  |  |  |  |  |  | sub parse_poll | 
| 100 |  |  |  |  |  |  | { | 
| 101 | 0 |  |  | 0 | 0 |  | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | 
| 102 | 0 |  |  |  |  |  | my $mes=$po->message(); | 
| 103 | 0 |  |  |  |  |  | my $eppNS = $mes->ns('_main'); | 
| 104 | 0 |  |  |  |  |  | my $resNS = 'http://www.nic.at/xsd/at-ext-result-1.0'; | 
| 105 |  |  |  |  |  |  |  | 
| 106 | 0 | 0 |  |  |  |  | return unless $mes->is_success(); | 
| 107 | 0 | 0 |  |  |  |  | return if $mes->result_is('COMMAND_SUCCESSFUL_QUEUE_EMPTY'); | 
| 108 |  |  |  |  |  |  |  | 
| 109 | 0 |  |  |  |  |  | my $msgid=$mes->msg_id(); | 
| 110 | 0 |  |  |  |  |  | $rinfo->{message}->{session}->{last_id}=$msgid; | 
| 111 |  |  |  |  |  |  |  | 
| 112 | 0 |  |  |  |  |  | my $mesdata=$mes->get_response($NS,'message'); | 
| 113 | 0 |  |  |  |  |  | $rinfo->{$otype}->{$oname}->{message}=$mesdata; | 
| 114 | 0 | 0 |  |  |  |  | return unless $mesdata; | 
| 115 |  |  |  |  |  |  |  | 
| 116 | 0 |  |  |  |  |  | my ($epp,$rep,$ext,$ctag,@conds,@tags); | 
| 117 | 0 |  |  |  |  |  | my $command=$mesdata->getAttribute('type'); | 
| 118 | 0 |  |  |  |  |  | @tags = $mesdata->getElementsByTagNameNS($NS, 'desc'); | 
| 119 |  |  |  |  |  |  |  | 
| 120 | 0 | 0 |  |  |  |  | $rinfo->{message}->{$msgid}->{content} = $tags[0]->getFirstChild()->getData() if @tags; | 
| 121 | 0 |  |  |  |  |  | @tags = $mesdata->getElementsByTagNameNS($NS, 'data'); | 
| 122 | 0 | 0 |  |  |  |  | return unless @tags; | 
| 123 |  |  |  |  |  |  |  | 
| 124 | 0 |  |  |  |  |  | my $data = $tags[0]; | 
| 125 | 0 |  |  |  |  |  | @tags = $data->getElementsByTagNameNS($NS, 'entry'); | 
| 126 |  |  |  |  |  |  |  | 
| 127 | 0 |  |  |  |  |  | foreach my $entry (@tags) | 
| 128 |  |  |  |  |  |  | { | 
| 129 | 0 | 0 |  |  |  |  | next unless (defined($entry->getAttribute('name'))); | 
| 130 |  |  |  |  |  |  |  | 
| 131 | 0 | 0 |  |  |  |  | if ($entry->getAttribute('name') eq 'objecttype') | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | { | 
| 133 | 0 |  |  |  |  |  | $rinfo->{message}->{$msgid}->{object_type} = $entry->getFirstChild()->getData(); | 
| 134 |  |  |  |  |  |  | } | 
| 135 |  |  |  |  |  |  | elsif ($entry->getAttribute('name') eq 'command') | 
| 136 |  |  |  |  |  |  | { | 
| 137 | 0 |  |  |  |  |  | $rinfo->{message}->{$msgid}->{action} = $entry->getFirstChild()->getData(); | 
| 138 |  |  |  |  |  |  | } | 
| 139 |  |  |  |  |  |  | elsif ($entry->getAttribute('name') eq 'objectname') | 
| 140 |  |  |  |  |  |  | { | 
| 141 | 0 |  |  |  |  |  | $rinfo->{message}->{$msgid}->{object_id} = $entry->getFirstChild()->getData(); | 
| 142 |  |  |  |  |  |  | } | 
| 143 |  |  |  |  |  |  | elsif ($entry->getAttribute('name') =~ /^(domain|contact|host)$/) | 
| 144 |  |  |  |  |  |  | { | 
| 145 | 0 |  |  |  |  |  | my $text = $entry->getFirstChild(); | 
| 146 | 0 |  |  |  |  |  | $rinfo->{message}->{$msgid}->{object_type}=$1; | 
| 147 | 0 | 0 |  |  |  |  | $rinfo->{message}->{$msgid}->{object_id} = $text->getData() if (defined($text)); | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  | } | 
| 150 |  |  |  |  |  |  |  | 
| 151 | 0 |  | 0 |  |  |  | $rinfo->{message}->{$msgid}->{action} ||= $command; | 
| 152 | 0 |  |  |  |  |  | @tags = $data->getElementsByTagNameNS($eppNS, 'epp'); | 
| 153 | 0 | 0 |  |  |  |  | return unless (@tags); | 
| 154 | 0 |  |  |  |  |  | $epp = $tags[0]; | 
| 155 |  |  |  |  |  |  |  | 
| 156 | 0 |  |  |  |  |  | @tags = $epp->getElementsByTagNameNS($eppNS, 'response'); | 
| 157 | 0 | 0 |  |  |  |  | return unless (@tags); | 
| 158 | 0 |  |  |  |  |  | $rep = $tags[0]; | 
| 159 |  |  |  |  |  |  |  | 
| 160 | 0 |  |  |  |  |  | @tags = $rep->getElementsByTagNameNS($eppNS, 'extension'); | 
| 161 | 0 | 0 |  |  |  |  | return unless (@tags); | 
| 162 | 0 |  |  |  |  |  | $ext = $tags[0]; | 
| 163 |  |  |  |  |  |  |  | 
| 164 | 0 |  |  |  |  |  | foreach my $node ($ext->childNodes()) | 
| 165 |  |  |  |  |  |  | { | 
| 166 | 0 |  | 0 |  |  |  | my $name = $node->localName() || $node->nodeName(); | 
| 167 |  |  |  |  |  |  |  | 
| 168 | 0 | 0 |  |  |  |  | if ($name eq 'conditions') | 
|  |  | 0 |  |  |  |  |  | 
| 169 |  |  |  |  |  |  | { | 
| 170 | 0 |  |  |  |  |  | @tags = $node->getElementsByTagNameNS($resNS, 'condition'); | 
| 171 |  |  |  |  |  |  |  | 
| 172 | 0 |  |  |  |  |  | foreach my $cond (@tags) | 
| 173 |  |  |  |  |  |  | { | 
| 174 | 0 |  |  |  |  |  | my %con; | 
| 175 | 0 |  |  |  |  |  | my $c = $cond->getFirstChild(); | 
| 176 |  |  |  |  |  |  |  | 
| 177 | 0 | 0 |  |  |  |  | $con{code} = $cond->getAttribute('code') if ($cond->getAttribute('code')); | 
| 178 | 0 | 0 |  |  |  |  | $con{severity} = $cond->getAttribute('severity') if ($cond->getAttribute('severity')); | 
| 179 |  |  |  |  |  |  |  | 
| 180 | 0 |  |  |  |  |  | while ($c) | 
| 181 |  |  |  |  |  |  | { | 
| 182 | 0 | 0 |  |  |  |  | next unless ($c->nodeType() == 1); ## only for element nodes | 
| 183 | 0 |  | 0 |  |  |  | my $cname = $c->localname() || $c->nodeName(); | 
| 184 | 0 | 0 |  |  |  |  | next unless $cname; | 
| 185 |  |  |  |  |  |  |  | 
| 186 | 0 | 0 |  |  |  |  | if ($cname =~ m/^(msg|details)$/) | 
|  |  | 0 |  |  |  |  |  | 
| 187 |  |  |  |  |  |  | { | 
| 188 | 0 |  |  |  |  |  | $con{$1} = $c->getFirstChild()->getData(); | 
| 189 |  |  |  |  |  |  | } | 
| 190 |  |  |  |  |  |  | elsif ($cname eq 'attributes') | 
| 191 |  |  |  |  |  |  | { | 
| 192 | 0 |  |  |  |  |  | foreach my $attr ($c->getChildrenByTagNameNS($NS,'attr')) | 
| 193 |  |  |  |  |  |  | { | 
| 194 | 0 |  |  |  |  |  | my $attrname = $attr->getAttribute('name'); | 
| 195 | 0 |  |  |  |  |  | $con{'attr ' . $attrname} = $attr->getFirstChild()->getData(); | 
| 196 |  |  |  |  |  |  | } | 
| 197 |  |  |  |  |  |  | } | 
| 198 | 0 |  |  |  |  |  | } continue { $c = $c->getNextSibling(); } | 
| 199 |  |  |  |  |  |  |  | 
| 200 | 0 |  |  |  |  |  | push(@conds, \%con); | 
| 201 |  |  |  |  |  |  | } | 
| 202 |  |  |  |  |  |  | } | 
| 203 |  |  |  |  |  |  | elsif ($name eq 'keydate') | 
| 204 |  |  |  |  |  |  | { | 
| 205 | 0 |  |  |  |  |  | $rinfo->{message}->{$msgid}->{keydate} = $node->getFirstChild()->getData(); | 
| 206 |  |  |  |  |  |  | } | 
| 207 |  |  |  |  |  |  | } | 
| 208 |  |  |  |  |  |  |  | 
| 209 | 0 |  |  |  |  |  | $rinfo->{message}->{$msgid}->{conditions} = \@conds; | 
| 210 | 0 |  |  |  |  |  | return; | 
| 211 |  |  |  |  |  |  | } | 
| 212 |  |  |  |  |  |  |  | 
| 213 |  |  |  |  |  |  | #################################################################################################### | 
| 214 |  |  |  |  |  |  | 1; |