blib/lib/Crypt/Perl/X509/Extension/policyMappings.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 2 SCAR 11.0
CC
2
Cov
0%
new
6.0
_encode_params
2.0
BEGIN
2.0
CRAP 3.0
1 package Crypt::Perl::X509::Extension::policyMappings;
2  
3 use strict;
4 use warnings;
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 Crypt::Perl::X509::Extension::policyMappings - X.509 policyMappings extension
11  
12 =head1 SEE ALSO
13  
14 L<https://tools.ietf.org/html/rfc5280#section-4.2.1.5>
15  
16 =cut
17  
18 use parent qw( Crypt::Perl::X509::Extension );
19  
20 use constant {
21 OID => '2.5.29.33',
22 OID_anyPolicy => '2.5.29.32.0',
23 CRITICAL => 1,
24 };
25  
26 use constant ASN1 => <<END;
27 policyMappings ::= SEQUENCE OF SEQUENCE {
28 issuerDomainPolicy OBJECT IDENTIFIER,
29 subjectDomainPolicy OBJECT IDENTIFIER
30 }
31 END
32  
33 sub new {
34 my ($class, @mappings) = @_;
35  
36 my @self;
37  
38 for my $m_hr (@mappings) {
39 my %cur;
40  
41 for my $k ( qw( issuer subject ) ) {
42 next if !defined $m_hr->{$k};
43  
44 my $oid = $class->can("OID_$m_hr->{$k}");
45 $oid &&= $oid->();
46 $oid ||= $m_hr->{$k};
47  
48 $cur{"${k}DomainPolicy"} = $oid;
49 }
50  
51 push @self, \%cur;
52 }
53  
54 return bless \@self, $class;
55 }
56  
57 sub _encode_params {
58 my ($self) = @_;
59  
60 return [ @$self ];
61 }
62  
63 1;