Mojo/SAML/Document/Signature.pm untested

filter: Statementstmt 0.0% 0 / 15 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 21 CC 2 SCAR 13.9
CC
2
Cov
0%
before_render
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.0
1 package Mojo::SAML::Document::Signature;
2  
3 use Mojo::Base 'Mojo::SAML::Document';
4  
5 use Mojo::SAML::Document::KeyInfo;
6  
7 has template => sub { shift->build_template(<<'XML') };
8 <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
9 <ds:SignedInfo>
10 <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
11 <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
12 % for my $ref (@{ $self->references }) {
13 %= tag 'ds:Reference' => URI => "#$ref" => begin
14 <ds:Transforms>
15 <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
16 <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
17 </ds:Transforms>
18 <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
19 <ds:DigestValue></ds:DigestValue>
20 </ds:Reference>
21 % end
22 % }
23 </ds:SignedInfo>
24 <ds:SignatureValue></ds:SignatureValue>
25 % if (my $info = $self->key_info) {
26 <%= $info %>
27 % }
28 </ds:Signature>
29 XML
30  
31 has 'key_info';
32 has references => sub { [] };
33  
34  
35 sub before_render {
36 my $self = shift;
37 for my $method (qw/references/) {
38 Carp::croak "$method cannot be empty" unless @{$self->$method};
39 }
40 }
41  
42 1;
43  
44 =head1 NAME
45  
46 Mojo::SAML::Document::Signature
47  
48 =head1 DESCRIPTION
49  
50 Represents an Signature XML-Sig tag
51  
52 =head1 ATTRIBUTES
53  
54 L<Mojo::SAML::Document::Signature> inherits all attributes from L<Mojo::SAML::Document> and implements the following new ones.
55  
56 =head2 key_info
57  
58 Optional.
59 An instance of L<Mojo::SAML::Document::KeyInfo> to be included in the signature.
60  
61 =head2 references
62  
63 An array reference of C<ID> attributes of elements to be referenced (and thus signed) by the signature.
64 Must not be empty at render time.
65  
66 =head2 template
67  
68 A template specific to the document type.
69  
70 =head1 METHODS
71  
72 L<Mojo::SAML::Document::Signature> inherits all methods from L<Mojo::SAML::Document> and implements the following new ones.
73  
74 =head2 before_render
75  
76 Enforces that L</references> is not empty at render time.
77