| 1 | =encoding utf-8 | ||||||||||||||
| 2 | |||||||||||||||
| 3 | =head1 NAME | ||||||||||||||
| 4 | |||||||||||||||
| 5 | Business::cXML::Credential - cXML credential | ||||||||||||||
| 6 | |||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||
| 8 | |||||||||||||||
| 9 | use Business::cXML::Transmission; | ||||||||||||||
| 10 | $msg = new Business::cXML::Transmission $incoming_cxml_string; | ||||||||||||||
| 11 | print $msg->to->id; # Fetches Identity string from the To credential | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||
| 14 | |||||||||||||||
| 15 | Object representation of cXML C<To>, C<From> and C<Sender> (default). | ||||||||||||||
| 16 | |||||||||||||||
| 17 | =head1 METHODS | ||||||||||||||
| 18 | |||||||||||||||
| 19 | See L<Business::cXML::Object/COMMON METHODS>. | ||||||||||||||
| 20 | |||||||||||||||
| 21 | =head1 PROPERTY METHODS | ||||||||||||||
| 22 | |||||||||||||||
| 23 | See L<Business::cXML::Object/PROPERTY METHODS> for how the following operate. | ||||||||||||||
| 24 | |||||||||||||||
| 25 | =over | ||||||||||||||
| 26 | |||||||||||||||
| 27 | =cut | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 7 | ▶ | use 5.014; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 30 | 7 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 31 | |||||||||||||||
| 32 | package Business::cXML::Credential; | ||||||||||||||
| 33 | 7 | ▶ | use base qw(Business::cXML::Object); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 34 | |||||||||||||||
| 35 | 7 | ▶ | use constant NODENAME => 'Sender'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 36 | 7 | ▶ | use constant PROPERTIES => ( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 37 | _note => undef, | ||||||||||||||
| 38 | domain => 'NetworkId', | ||||||||||||||
| 39 | id => ' ', | ||||||||||||||
| 40 | secret => undef, | ||||||||||||||
| 41 | useragent => undef, | ||||||||||||||
| 42 | type => undef, | ||||||||||||||
| 43 | lang => undef, | ||||||||||||||
| 44 | contact => undef, | ||||||||||||||
| 45 | 7 | ); | |||||||||||||
| 46 | 7 | ▶ | use constant OBJ_PROPERTIES => ( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 47 | contact => 'Business::cXML::Contact', | ||||||||||||||
| 48 | 7 | ); | |||||||||||||
| 49 | |||||||||||||||
| 50 | 7 | ▶ | use Business::cXML; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 51 | 7 | ▶ | use Business::cXML::Contact; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 52 | 7 | ▶ | use XML::LibXML::Ferry; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 53 | |||||||||||||||
| 54 | 4 | ▶ | sub from_node { | ||||||||||||
|
Subroutine
from_node: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 55 | 4 | my ($self, $el) = @_; | |||||||||||||
| 56 | |||||||||||||||
| 57 | 4 | $el->ferry($self, { | |||||||||||||
| 58 | # domain attribute is implicit | ||||||||||||||
| 59 | # type attribute is implicit | ||||||||||||||
| 60 | Credential => { | ||||||||||||||
| 61 | # We will only consider the last Credential if there are multiples | ||||||||||||||
| 62 | Identity => 'id', | ||||||||||||||
| 63 | SharedSecret => 'secret', | ||||||||||||||
| 64 | DigitalSignature => '__OBSOLETE', | ||||||||||||||
| 65 | CredentialMac => '__UNIMPLEMENTED', | ||||||||||||||
| 66 | }, | ||||||||||||||
| 67 | Correspondent => { | ||||||||||||||
| 68 | preferredLanguage => 'lang', | ||||||||||||||
| 69 | # We will implicitly keep only the last Contact if there are multiples | ||||||||||||||
| 70 | Contact => [ 'contact', 'Business::cXML::Contact' ], | ||||||||||||||
| 71 | }, | ||||||||||||||
| 72 | }); | ||||||||||||||
| 73 | } | ||||||||||||||
| 74 | |||||||||||||||
| 75 | 4 | ▶ | sub to_node { | ||||||||||||
|
Subroutine
to_node: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 76 | 4 | my ($self, $doc) = @_; | |||||||||||||
| 77 | 4 | my $node = $doc->create($self->{_nodeName}); | |||||||||||||
| 78 | 4 | my $cred = $node->add('Credential', undef, domain => $self->{domain}, type => $self->{type}); | |||||||||||||
| 79 | 4 | $cred->add('Identity', $self->{id}); | |||||||||||||
| 80 | 4 | ▶ | $cred->add('SharedSecret', $self->{secret}) if $self->{secret}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 81 | # UNIMPLEMENTED: DigitalSignature CredentialMac | ||||||||||||||
| 82 | 4 | ▶ | if ($self->{_nodeName} eq 'Sender') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 83 | 1 | $node->add('UserAgent', $Business::cXML::USERAGENT); | |||||||||||||
| 84 | } elsif (ref $self->{contact}) { | ||||||||||||||
| 85 | $node->add('Correspondent', undef, preferredLanguage => $self->{lang}) | ||||||||||||||
| 86 | 1 | ->add($self->{contact}->to_node($node)) | |||||||||||||
| 87 | ; | ||||||||||||||
| 88 | }; | ||||||||||||||
| 89 | 4 | return $node; | |||||||||||||
| 90 | } | ||||||||||||||
| 91 | |||||||||||||||
| 92 | =item C<B<domain>> | ||||||||||||||
| 93 | |||||||||||||||
| 94 | Mandatory, default: C<NetworkId> | ||||||||||||||
| 95 | |||||||||||||||
| 96 | =item C<B<id>> | ||||||||||||||
| 97 | |||||||||||||||
| 98 | Mandatory | ||||||||||||||
| 99 | |||||||||||||||
| 100 | =item C<B<type>> | ||||||||||||||
| 101 | |||||||||||||||
| 102 | Optional, expected to be C<undef> (default) or C<marketplace> | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =item C<B<lang>> | ||||||||||||||
| 105 | |||||||||||||||
| 106 | Optional, in outgoing messages it is only used if contact information is defined. | ||||||||||||||
| 107 | |||||||||||||||
| 108 | =item C<B<contact>> | ||||||||||||||
| 109 | |||||||||||||||
| 110 | Optional, L<Business::cXML::Contact> object | ||||||||||||||
| 111 | |||||||||||||||
| 112 | =item C<B<_note>> | ||||||||||||||
| 113 | |||||||||||||||
| 114 | Private note. It will be lost in conversion back to cXML. Intended to help | ||||||||||||||
| 115 | you store your own representation of the remote company during processing. | ||||||||||||||
| 116 | |||||||||||||||
| 117 | =back | ||||||||||||||
| 118 | |||||||||||||||
| 119 | =head3 C<Sender> adds: | ||||||||||||||
| 120 | |||||||||||||||
| 121 | =over | ||||||||||||||
| 122 | |||||||||||||||
| 123 | =item C<B<useragent>> | ||||||||||||||
| 124 | |||||||||||||||
| 125 | Mandatory | ||||||||||||||
| 126 | |||||||||||||||
| 127 | =item C<B<secret>> | ||||||||||||||
| 128 | |||||||||||||||
| 129 | Optional | ||||||||||||||
| 130 | |||||||||||||||
| 131 | =back | ||||||||||||||
| 132 | |||||||||||||||
| 133 | =head1 AUTHOR | ||||||||||||||
| 134 | |||||||||||||||
| 135 | Stéphane Lavergne L<https://github.com/vphantom> | ||||||||||||||
| 136 | |||||||||||||||
| 137 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||
| 138 | |||||||||||||||
| 139 | Graph X Design Inc. L<https://www.gxd.ca/> sponsored this project. | ||||||||||||||
| 140 | |||||||||||||||
| 141 | =head1 COPYRIGHT & LICENSE | ||||||||||||||
| 142 | |||||||||||||||
| 143 | Copyright (c) 2017-2018 Stéphane Lavergne L<https://github.com/vphantom> | ||||||||||||||
| 144 | |||||||||||||||
| 145 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||||||||||
| 146 | of this software and associated documentation files (the "Software"), to deal | ||||||||||||||
| 147 | in the Software without restriction, including without limitation the rights | ||||||||||||||
| 148 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||||||||||
| 149 | copies of the Software, and to permit persons to whom the Software is | ||||||||||||||
| 150 | furnished to do so, subject to the following conditions: | ||||||||||||||
| 151 | |||||||||||||||
| 152 | The above copyright notice and this permission notice shall be included in all | ||||||||||||||
| 153 | copies or substantial portions of the Software. | ||||||||||||||
| 154 | |||||||||||||||
| 155 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||||||||||
| 156 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||||||||||
| 157 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||||||||||
| 158 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||||||||||
| 159 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||||||||||
| 160 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||||||||||
| 161 | SOFTWARE. | ||||||||||||||
| 162 | =cut | ||||||||||||||
| 163 | |||||||||||||||
| 164 | 7 | 1; | |||||||||||||