| 1 | ## Domain Registry Interface, IRIS Message | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2008-2010,2013,2018 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::IRIS::Message; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use XML::LibXML (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Net::DRI::Protocol::ResultStatus; | ||||||||||||||||||||||||||
|
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::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use base qw(Class::Accessor::Chained::Fast Net::DRI::Protocol::Message); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 1 | __PACKAGE__->mk_accessors(qw/version tid authority options search results/); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =pod | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head1 NAME | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | Net::DRI::Protocol::IRIS::Message - IRIS Message for Net::DRI | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | Please see the README file for details. | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | Copyright (c) 2008-2010,2013,2018 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||
| 59 | All rights reserved. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 62 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 63 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 64 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | #################################################################################################### | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub new | ||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my $class=shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 0 | my $trid=shift; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my $self={ ns => {}, options => {} }; | |||||||||||||||||||||||||||
| 78 | 0 | bless($self,$class); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | $self->tid($trid) if defined $trid && length $trid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $trid and length $trid
MC/DC0%0/2
defined $trid and length $trid
defined $trid
length $trid
Truth table0%0/3
A and B
A= defined $tridB= length $trid
| |||||||||||||||||||||||||||||
| 81 | 0 | return $self; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | sub ns | ||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | my ($self,$what)=@_; | ||||||||||||||||||||||||||
|
Subroutine
ns: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | return $self->{ns} unless defined $what; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if (ref $what eq 'HASH') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | { | ||||||||||||||||||||||||||||
| 91 | 0 | $self->{ns}=$what; | |||||||||||||||||||||||||||
| 92 | 0 | return $what; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return unless exists $self->{ns}->{$what}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | return $self->{ns}->{$what}->[0]; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | sub nsattrs | ||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my ($self,$what)=@_; | ||||||||||||||||||||||||||
|
Subroutine
nsattrs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return unless defined $what && exists $self->{ns}->{$what}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $what and exists $self->{"ns"}{$what}
MC/DC0%0/2
defined $what and exists $self->{"ns"}{$what}
defined $what
exists $self->{"ns"}{$what}
Truth table0%0/3
A and B
A= defined $whatB= exists $self->{"ns"}{$what}
| |||||||||||||||||||||||||||||
| 102 | 0 | my @n=@{$self->{ns}->{$what}}; | |||||||||||||||||||||||||||
| 103 | 0 | return ($n[0],$n[0],$n[1]); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub is_success { return 1; } ## TODO | ||||||||||||||||||||||||||
|
Subroutine
is_success: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub result_status { return Net::DRI::Protocol::ResultStatus->new_success(); }; ## There is no message-level result_status, only at resultSet level, hence global success | ||||||||||||||||||||||||||
|
Subroutine
result_status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | sub as_string | ||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my ($self)=@_; | ||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | ## TODO : handle other top nodes, see RFC4991, + control node in <request> | ||||||||||||||||||||||||||||
| 115 | 0 | ▶ | Net::DRI::Exception::err_assert('Net::DRI::Protocol::IRIS::Message can only handle <request> operations for now') unless defined $self->search(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | my @d; | |||||||||||||||||||||||||||
| 117 | 0 | push @d,'<?xml version="1.0" encoding="UTF-8" standalone="no"?>'; | |||||||||||||||||||||||||||
| 118 | 0 | push @d,sprintf('<request xmlns="%s">',$self->nsattrs('iris1')); | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | foreach my $search (@{$self->search()}) ## $search is a refhash comme il faut | |||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||
| 122 | 0 | push @d,'<searchSet>'; | |||||||||||||||||||||||||||
| 123 | ## We do not handle bags for now | ||||||||||||||||||||||||||||
| 124 | ## Only lookupEntity is supported for now | ||||||||||||||||||||||||||||
| 125 | 0 | push @d,Net::DRI::Util::xml_write(['lookupEntity',$search]); | |||||||||||||||||||||||||||
| 126 | 0 | push @d,'</searchSet>'; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | push @d,'</request>'; | |||||||||||||||||||||||||||
| 130 | 0 | return join('',@d); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | # RFC3981 §4.2 | ||||||||||||||||||||||||||||
| 134 | sub parse | ||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | my ($self,$dc,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | my $parser=XML::LibXML->new(); | |||||||||||||||||||||||||||
| 139 | 0 | my $doc=$parser->parse_string($dc->as_string()); | |||||||||||||||||||||||||||
| 140 | 0 | my $root=$doc->getDocumentElement(); | |||||||||||||||||||||||||||
| 141 | ## TODO: handle RFC4991 other types of responses | ||||||||||||||||||||||||||||
| 142 | 0 | ▶ | Net::DRI::Exception->die(0,'protocol/IRIS',1,'Unsuccessfull parse, root element is not response') unless ($root->localname() eq 'response'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | ## We currently do not parse the <reaction> node (in reply to a <control> which we do never send for now, see §4.3.8) and <bags> (see §4.4) | ||||||||||||||||||||||||||||
| 145 | ## We take care only of the <resultSet> nodes | ||||||||||||||||||||||||||||
| 146 | 0 | $self->results(scalar($root->getChildrenByTagNameNS($self->ns('iris1'),'resultSet'))); | |||||||||||||||||||||||||||
| 147 | 0 | return; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | #################################################################################################### | ||||||||||||||||||||||||||||
| 151 | 1 | 1; | |||||||||||||||||||||||||||