SAML2/Protocol/Artifact.pm

filter: Statementstmt 100% 48 / 48 Branchbran 91.6% 11 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 98.6% 72 / 73 CC 7 SCAR 11.4
CC
7
Cov
98%
new_from_xml
6.0
get_response
2.0
BEGIN
1.0
CRAP 3.1
« SAML2/Protocol/LogoutRequest.pm ↑ Summary SAML2/Binding/SOAP.pm »
1 package Net::SAML2::Protocol::Artifact;
2 32 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 32 our $VERSION = '0.89'; # VERSION
4  
5 32 ▶use MooseX::Types::DateTime qw/ DateTime /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 32 ▶use DateTime::Format::XSD;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 32 ▶use Net::SAML2::XML::Util qw/ no_comments /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 32 ▶use XML::LibXML::XPathContext;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 32 with 'Net::SAML2::Role::ProtocolMessage';
11  
12 # ABSTRACT: SAML2 artifact object
13  
14  
15 32 has 'issue_instant' => (isa => DateTime, is => 'ro', required => 1);
16 32 has '+in_response_to' => (required => 1);
17 32 has 'issuer' => (isa => 'Str', is => 'ro', required => 1);
18 32 has 'status' => (isa => 'Str', is => 'ro', required => 1);
19 32 has 'logoutresponse_object' => (
20 isa => 'XML::LibXML::Element',
21 is => 'ro',
22 required => 0,
23 init_arg => 'logout_response',
24 predicate => 'has_logout_response'
25 );
26 32 has 'response_object' => (
27 isa => 'XML::LibXML::Element',
28 is => 'ro',
29 required => 0,
30 init_arg => 'response',
31 predicate => 'has_response'
32 );
33  
34  
35  
36 2 ▶sub new_from_xml {
Subroutine new_from_xml: called CC=6 SCAR=17.9
Pod documented
37 2 my($class, %args) = @_;
38  
39 2 my $dom = no_comments($args{xml});
40 2 my $key_file = $args{key_file};
41 2 my $cacert = $args{cacert};
42  
43 2 my $xpath = XML::LibXML::XPathContext->new($dom);
44 2 $xpath->registerNs('saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
45 2 $xpath->registerNs('samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
46  
47 2 my $response;
48 2 ▶ if (my $node = $xpath->findnodes('/samlp:ArtifactResponse/samlp:Response')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $node = $xpath->findnodes("/samlp:ArtifactResponse/samlp:Response")) 1 1 2
49 1 $response = $node->get_node(1)->cloneNode( 1 );
50 }
51 2 my $logoutresponse;
52 2 ▶ if (my $node = $xpath->findnodes('/samlp:ArtifactResponse/samlp:LogoutResponse')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $node = $xpath->findnodes("/samlp:ArtifactResponse/samlp:LogoutResponse")) 1 1 2
53 1 $logoutresponse = $node->get_node(1)->cloneNode( 1 );
54 }
55  
56 2 my $issue_instant;
57 2 ▶ if (my $value = $xpath->findvalue('/samlp:ArtifactResponse/@IssueInstant')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $value = $xpath->findvalue("/samlp:ArtifactResponse/\@IssueInstant")) 2 0 2
58 2 $issue_instant = DateTime::Format::XSD->parse_datetime($value);
59 }
60  
61 2 ▶ return $class->new(
Branch: 2 branches
BranchTrueFalseTotal
$response ? : 1 1 2
$logoutresponse ? : 1 1 2
62 id => $xpath->findvalue('/samlp:ArtifactResponse/@ID'),
63 in_response_to => $xpath->findvalue('/samlp:ArtifactResponse/@InResponseTo'),
64 issue_instant => $issue_instant,
65 issuer => $xpath->findvalue('/samlp:ArtifactResponse/saml:Issuer'),
66 status => $xpath->findvalue('/samlp:ArtifactResponse/samlp:Status/samlp:StatusCode/@Value'),
67 $response ? (response => $response) : (),
68 $logoutresponse ? (logout_response => $logoutresponse) : (),
69 );
70 }
71  
72  
73 2 ▶sub response {
Subroutine response: called CC=1 SCAR=0.0
Pod documented
74 2 my $self = shift;
75 2 return $self->response_object->toString;
76 }
77  
78  
79 2 ▶sub logout_response {
Subroutine logout_response: called CC=1 SCAR=0.0
Pod documented
80 2 my $self = shift;
81 2 return $self->logoutresponse_object->toString;
82 }
83  
84  
85 2 ▶sub get_response {
Subroutine get_response: called CC=2 SCAR=6.9
Pod documented
86 2 my ($self) = @_;
87 2 ▶ return $self->logout_response if $self->has_logout_response;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_logout_response 1 1 2
88 1 return $self->response
89 }
90  
91 32 1;
92  
93 __END__
« SAML2/Protocol/LogoutRequest.pm ↑ Summary SAML2/Binding/SOAP.pm »