| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ## Domain Registry Interface, .PL Contact EPP extension commands | 
| 2 |  |  |  |  |  |  | ## | 
| 3 |  |  |  |  |  |  | ## Copyright (c) 2006,2008,2011,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::EPP::Extensions::PL::Contact; | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 1 |  |  | 1 |  | 926 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 27 |  | 
| 18 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 1 |  |  | 1 |  | 3 | use Net::DRI::Util; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 547 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =pod | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =head1 NAME | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | Net::DRI::Protocol::EPP::Extensions::PL::Contact - .PL EPP Contact extension 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) 2006,2008,2011,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 |  |  |  |  |  |  | sub register_commands | 
| 65 |  |  |  |  |  |  | { | 
| 66 | 0 |  |  | 0 | 0 |  | my ($class,$version)=@_; | 
| 67 | 0 |  |  |  |  |  | my %tmp=( | 
| 68 |  |  |  |  |  |  | create => [ \&create, undef ], | 
| 69 |  |  |  |  |  |  | info   => [ \&info, \&info_parse ], | 
| 70 |  |  |  |  |  |  | update => [ \&update, undef ], | 
| 71 |  |  |  |  |  |  | ); | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 0 |  |  |  |  |  | return { 'contact' => \%tmp }; | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | #################################################################################################### | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | sub build_command_extension | 
| 79 |  |  |  |  |  |  | { | 
| 80 | 0 |  |  | 0 | 0 |  | my ($mes,$epp,$tag)=@_; | 
| 81 | 0 |  |  |  |  |  | return $mes->command_extension_register($tag,sprintf('xmlns:extcon="%s" xsi:schemaLocation="%s %s"',$mes->nsattrs('pl_contact'))); | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | sub add_individual_and_consent | 
| 85 |  |  |  |  |  |  | { | 
| 86 | 0 |  |  | 0 | 0 |  | my ($epp,$contact,$op)=@_; | 
| 87 | 0 |  |  |  |  |  | my $mes=$epp->message(); | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | ## validate() has already been called | 
| 90 | 0 |  |  |  |  |  | my $ind=$contact->individual(); | 
| 91 | 0 |  |  |  |  |  | my $cfp=$contact->consent_for_publishing(); | 
| 92 |  |  |  |  |  |  |  | 
| 93 | 0 | 0 | 0 |  |  |  | return unless (defined($ind) || defined($cfp)); | 
| 94 | 0 |  |  |  |  |  | my $eid=build_command_extension($mes,$epp,'extcon:'.$op); | 
| 95 | 0 |  |  |  |  |  | my @e; | 
| 96 | 0 | 0 |  |  |  |  | push @e,['extcon:individual',$ind]           if defined($ind); | 
| 97 | 0 | 0 |  |  |  |  | push @e,['extcon:consentForPublishing',$cfp] if defined($cfp); | 
| 98 |  |  |  |  |  |  |  | 
| 99 | 0 |  |  |  |  |  | $mes->command_extension($eid,\@e); | 
| 100 | 0 |  |  |  |  |  | return; | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | sub create | 
| 104 |  |  |  |  |  |  | { | 
| 105 | 0 |  |  | 0 | 0 |  | my ($epp,$contact)=@_; | 
| 106 | 0 |  |  |  |  |  | return add_individual_and_consent($epp,$contact,'create'); | 
| 107 |  |  |  |  |  |  | } | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | sub update | 
| 110 |  |  |  |  |  |  | { | 
| 111 | 0 |  |  | 0 | 0 |  | my ($epp,$contact,$todo)=@_; | 
| 112 | 0 |  |  |  |  |  | my $newc=$todo->set('info'); | 
| 113 | 0 | 0 |  |  |  |  | return unless $newc; | 
| 114 | 0 |  |  |  |  |  | return add_individual_and_consent($epp,$newc,'update'); | 
| 115 |  |  |  |  |  |  | } | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | sub info | 
| 118 |  |  |  |  |  |  | { | 
| 119 | 0 |  |  | 0 | 0 |  | my ($epp,$contact,$ep)=@_; | 
| 120 | 0 |  |  |  |  |  | my $mes=$epp->message(); | 
| 121 |  |  |  |  |  |  |  | 
| 122 | 0 | 0 | 0 |  |  |  | return unless (Net::DRI::Util::has_auth($ep) && exists $ep->{auth}->{pw}); | 
| 123 |  |  |  |  |  |  |  | 
| 124 | 0 |  |  |  |  |  | my $eid=build_command_extension($mes,$epp,'extcon:info'); | 
| 125 | 0 | 0 |  |  |  |  | if (Net::DRI::Util::has_key($ep->{auth},'roid')) | 
| 126 |  |  |  |  |  |  | { | 
| 127 | 0 |  |  |  |  |  | $mes->command_extension($eid,[['extcon:authInfo',['extcon:pw',{roid=>$ep->{auth}->{roid}},$ep->{auth}->{pw}]]]); | 
| 128 |  |  |  |  |  |  | } else { | 
| 129 | 0 |  |  |  |  |  | $mes->command_extension($eid,[['extcon:authInfo',['extcon:pw',$ep->{auth}->{pw}]]]); | 
| 130 |  |  |  |  |  |  | } | 
| 131 | 0 |  |  |  |  |  | return; | 
| 132 |  |  |  |  |  |  | } | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | sub info_parse | 
| 135 |  |  |  |  |  |  | { | 
| 136 | 0 |  |  | 0 | 0 |  | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | 
| 137 | 0 |  |  |  |  |  | my $mes=$po->message(); | 
| 138 | 0 | 0 |  |  |  |  | return unless $mes->is_success(); | 
| 139 |  |  |  |  |  |  |  | 
| 140 | 0 |  |  |  |  |  | my $infdata=$mes->get_extension('pl_contact','infData'); | 
| 141 | 0 | 0 |  |  |  |  | return unless defined $infdata; | 
| 142 |  |  |  |  |  |  |  | 
| 143 | 0 |  |  |  |  |  | my $contact=$rinfo->{contact}->{$oname}->{self}; | 
| 144 |  |  |  |  |  |  |  | 
| 145 | 0 |  |  |  |  |  | foreach my $el (Net::DRI::Util::xml_list_children($infdata)) | 
| 146 |  |  |  |  |  |  | { | 
| 147 | 0 |  |  |  |  |  | my ($name,$c)=@$el; | 
| 148 | 0 | 0 |  |  |  |  | if ($name eq 'individual') | 
|  |  | 0 |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | { | 
| 150 | 0 |  |  |  |  |  | $contact->individual(Net::DRI::Util::xml_parse_boolean($c->textContent())); | 
| 151 |  |  |  |  |  |  | } elsif ($name eq 'consentForPublishing') | 
| 152 |  |  |  |  |  |  | { | 
| 153 | 0 |  |  |  |  |  | $contact->consent_for_publishing(Net::DRI::Util::xml_parse_boolean($c->textContent())); | 
| 154 |  |  |  |  |  |  | } | 
| 155 |  |  |  |  |  |  | } | 
| 156 | 0 |  |  |  |  |  | return; | 
| 157 |  |  |  |  |  |  | } | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | #################################################################################################### | 
| 160 |  |  |  |  |  |  | 1; |