File Coverage

blib/lib/Net/SAML2/Protocol/ArtifactResolve.pm
Criterion Covered Total %
statement 14 14 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package Net::SAML2::Protocol::ArtifactResolve;
2 4     4   5135 use Moose;
  4         10  
  4         31  
3             our $VERSION = '0.74'; # VERSION
4              
5 4     4   28484 use MooseX::Types::URI qw/ Uri /;
  4         8  
  4         56  
6 4     4   8171 use URN::OASIS::SAML2 qw(:urn);
  4         9  
  4         1885  
7              
8             with 'Net::SAML2::Role::ProtocolMessage';
9              
10             # ABSTRACT: ArtifactResolve protocol class
11              
12              
13              
14             has 'issuer' => (isa => 'Str', is => 'ro', required => 1);
15             has 'destination' => (isa => 'Str', is => 'ro', required => 1);
16             has 'artifact' => (isa => 'Str', is => 'ro', required => 1);
17             has 'provider' => (
18             isa => 'Str',
19             is => 'ro',
20             required => 0,
21             predicate => 'has_provider',
22             );
23              
24              
25             sub as_xml {
26 2     2 1 1325 my $self = shift;
27              
28 2         19 my $x = XML::Generator->new(':pretty');
29 2         284 my $saml = ['saml' => URN_ASSERTION ];
30 2         8 my $samlp = ['samlp' => URN_PROTOCOL ];
31              
32 2 100       13 $x->xml(
33             $x->ArtifactResolve(
34             $samlp,
35             { ID => $self->id,
36             IssueInstant => $self->issue_instant,
37             Destination => $self->destination,
38             $self->has_provider ? (
39             ProviderName => $self->provider,
40             ) : (),
41             Version => '2.0' },
42             $x->Issuer(
43             $saml,
44             $self->issuer,
45             ),
46             $x->Artifact(
47             $samlp,
48             $self->artifact,
49             ),
50             )
51             );
52             }
53              
54             __PACKAGE__->meta->make_immutable;
55              
56             __END__
57              
58             =pod
59              
60             =encoding UTF-8
61              
62             =head1 NAME
63              
64             Net::SAML2::Protocol::ArtifactResolve - ArtifactResolve protocol class
65              
66             =head1 VERSION
67              
68             version 0.74
69              
70             =head1 SYNOPSIS
71              
72             my $resolver = Net::SAML2::Protocol::ArtifactResolve->new(
73             artifact => 'yourartifact',
74             destination => $idp->art_url('urn:oasis:names:tc:SAML:2.0:bindings:SOAP'), # https://idp.example.net/idp
75             issuer => $sp->id, # https://you.example.com/auth/saml
76             );
77              
78             my $binding = Net::SAML2::Binding::SOAP->new(...);
79             $binding->request($resolved->as_xml);
80              
81             =head1 NAME
82              
83             Net::SAML2::Protocol::ArtifactResolve - ArtifactResolve protocol class.
84              
85             =head1 METHODS
86              
87             =head2 new(%args)
88              
89             my $resolver = Net::SAML2::Protocol::ArtifactResolve->new(
90             artifact => 'yourartifact',
91             destination => $idp->art_url('urn:oasis:names:tc:SAML:2.0:bindings:SOAP'), # https://idp.example.net/idp
92             issuer => $sp->id, # https://you.example.com/auth/saml
93             );
94              
95             Constructor. Returns an instance of the ArtifactResolve request for
96             the given issuer and artifact.
97              
98             Arguments:
99              
100             =over
101              
102             =item B<issuer>
103              
104             Issuing SP's identity URI
105              
106             =item B<artifact>
107              
108             Artifact to be resolved
109              
110             =item B<destination>
111              
112             IdP's identity URI
113              
114             =item B<provider>
115              
116             IdP's provider name
117              
118             =back
119              
120             =head2 as_xml()
121              
122             Returns the ArtifactResolve request as XML.
123              
124             =head1 AUTHORS
125              
126             =over 4
127              
128             =item *
129              
130             Chris Andrews <chrisa@cpan.org>
131              
132             =item *
133              
134             Timothy Legge <timlegge@gmail.com>
135              
136             =back
137              
138             =head1 COPYRIGHT AND LICENSE
139              
140             This software is copyright (c) 2023 by Venda Ltd, see the CONTRIBUTORS file for others.
141              
142             This is free software; you can redistribute it and/or modify it under
143             the same terms as the Perl 5 programming language system itself.
144              
145             =cut