| 1 | ## Domain Registry Interface, Verification Code Extension Mapping for EPP | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2016,2018,2019 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::EPP::Extensions::VerificationCode; | ||||||||||||||||||||||||||||
| 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 | 1 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | #################################################################################################### | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub register_commands | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($class,$version)=@_; | |||||||||||||||||||||||||||
| 28 | 0 | state $ractions = { 'info' => [ \&info_build, \&info_parse ], | |||||||||||||||||||||||||||
| 29 | 'create' => [ \&create_build, undef ], | ||||||||||||||||||||||||||||
| 30 | 'delete' => [ \&create_build, undef ], | ||||||||||||||||||||||||||||
| 31 | 'renew' => [ \&create_build, undef ], | ||||||||||||||||||||||||||||
| 32 | 'transfer_request' => [ \&create_build, undef ], | ||||||||||||||||||||||||||||
| 33 | 'update' => [ \&create_build, undef ], | ||||||||||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||||||||||
| 35 | 0 | state $rcmds = { 'domain' => $ractions, | |||||||||||||||||||||||||||
| 36 | 'contact' => $ractions, | ||||||||||||||||||||||||||||
| 37 | 'host' => $ractions, | ||||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||
| 39 | 0 | return $rcmds; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub setup | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | my ($class,$po,$version)=@_; | |||||||||||||||||||||||||||
| 45 | 0 | state $rns = { 'verificationCode' => 'urn:ietf:params:xml:ns:verificationCode-1.0' }; | |||||||||||||||||||||||||||
| 46 | 0 | $po->ns($rns); | |||||||||||||||||||||||||||
| 47 | 0 | return; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub implements { return 'https://tools.ietf.org/html/draft-ietf-regext-verificationcode-06'; } | ||||||||||||||||||||||||||
|
Subroutine
implements: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | #################################################################################################### | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub is_verification_code | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
is_verification_code: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | my ($code) = @_; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | return defined $code && $code =~m/^\d+-[0-9a-z]+$/i ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $code and $code =~ /^\d+-[0-9a-z]+$/i
MC/DC0%0/2
defined $code and $code =~ /^\d+-[0-9a-z]+$/i
defined $code
$code =~ /^\d+-[0-9a-z]+$/i
Truth table0%0/3
A and B
A= defined $codeB= $code =~ /^\d+-[0-9a-z]+$/i
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | #################################################################################################### | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub info_build | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
info_build: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 0 | my ($epp, $oname, $rd)=@_; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return unless Net::DRI::Util::has_key($rd, 'verification_code') && $rd->{'verification_code'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
Net::DRI::Util::has_key($rd, "verification_code")
$rd->{"verification_code"}
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "verification_code")B= $rd->{"verification_code"}
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my %attrs; | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (Net::DRI::Util::has_key($rd, 'verification_code_profile')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('verification_code_profile must be an XML token') unless Net::DRI::Util::xml_is_token($rd->{verification_code_profile}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | $attrs{profile} = $rd->{verification_code_profile}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | $epp->message()->command_extension('verificationCode', ['info', \%attrs]); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | return; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | sub info_parse | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
info_parse: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 0 | my ($po, $otype, $oaction, $oname, $rinfo)=@_; | |||||||||||||||||||||||||||
| 83 | 0 | my $mes = $po->message(); | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | my $data = $mes->get_extension('verificationCode', 'infData'); | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | my %v; | |||||||||||||||||||||||||||
| 90 | 0 | foreach my $el (Net::DRI::Util::xml_list_children($data)) | |||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||
| 92 | 0 | my ($name, $node)=@$el; | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ($name eq 'status') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||
| 95 | 0 | $v{status} = $node->textContent(); | |||||||||||||||||||||||||||
| 96 | } elsif ($name eq 'profile') | ||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||
| 98 | 0 | my $pname = $node->getAttribute('name'); | |||||||||||||||||||||||||||
| 99 | 0 | my %p; | |||||||||||||||||||||||||||
| 100 | 0 | foreach my $subel (Net::DRI::Util::xml_list_children($node)) | |||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||
| 102 | 0 | my ($subname, $subnode) = @$subel; | |||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ($subname eq 'status') | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||
| 105 | 0 | $p{status} = $subnode->textContent(); | |||||||||||||||||||||||||||
| 106 | } elsif ($subname eq 'missing') | ||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||
| 108 | 0 | foreach my $code (Net::DRI::Util::xml_list_children($subnode, 'code')) | |||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | 0 | my %a = ( type => $code->getAttribute('type'), | |||||||||||||||||||||||||||
| 111 | due => $po->parse_iso8601($code->getAttribute('due')), | ||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||
| 113 | 0 | push @{$p{missing}}, \%a; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | } elsif ($subname eq 'set') | ||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||
| 117 | 0 | foreach my $code (Net::DRI::Util::xml_list_children($subnode, 'code')) | |||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||
| 119 | 0 | my %a = ( type => $code->getAttribute('type'), | |||||||||||||||||||||||||||
| 120 | date => $po->parse_iso8601($code->getAttribute('date')), | ||||||||||||||||||||||||||||
| 121 | code => $code->textContent(), | ||||||||||||||||||||||||||||
| 122 | ); | ||||||||||||||||||||||||||||
| 123 | 0 | push @{$p{set}}, \%a; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | 0 | $v{profiles}->{$pname} = \%p; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | $rinfo->{$otype}->{$oname}->{verification}=\%v; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | return; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | sub create_build | ||||||||||||||||||||||||||||
| 137 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create_build: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 138 | 0 | my ($epp, $oname, $rd)=@_; | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return unless Net::DRI::Util::has_key($rd, 'verification_code') && $rd->{'verification_code'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
Net::DRI::Util::has_key($rd, "verification_code")
$rd->{"verification_code"}
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "verification_code")B= $rd->{"verification_code"}
| |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | my $vc = $rd->{verification_code}; | |||||||||||||||||||||||||||
| 143 | 0 | ▶ | $vc = [ $vc ] unless ref $vc eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | ## TODO: handle other encoding than base64 | ||||||||||||||||||||||||||||
| 146 | 0 | foreach my $code (@$vc) | |||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||
| 148 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('verification code must be BASE64 formatted') unless Net::DRI::Util::verify_base64($code); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 0 | $epp->message()->command_extension('verificationCode', ['encodedSignedCode', map { ['verificationCode:code', $_] } @$vc]); | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | return; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | #################################################################################################### | ||||||||||||||||||||||||||||
| 157 | 1 | 1; | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | __END__ | ||||||||||||||||||||||||||||