lib/Crypt/Perl/PKCS10/Attributes.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 92.0% 46 / 50 CC 4 SCAR 7.1
CC
4
Cov
92%
new
4.1
__ANON__
1.0
BEGIN
1.0
CRAP 2.0
« lib/Crypt/Perl/X509/Name.pm ↑ Summary blib/lib/Crypt/Perl.pm »
1 package Crypt::Perl::PKCS10::Attributes;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 Crypt::Perl::PKCS10::Attributes - CSR “attributes” collection
11  
12 =head1 SYNOPSIS
13  
14 #Each object passed should be an instance of a subclass of
15 #Crypt::Perl::PKCS10::Attribute (NB: not this class!)
16 my $attrs = Crypt::Perl::PKCS10::Attributes->new( @ATTR_OBJS );
17  
18 #...or:
19  
20 my $attrs = Crypt::Perl::PKCS10::Attributes->new(
21 [ $attr_type1 => \@args1 ],
22 [ $attr_type2 => \@args2 ],
23 );
24  
25 #...for example:
26  
27 my $attrs = Crypt::Perl::PKCS10::Attributes->new(
28 [ challengePassword => 'iNsEcUrE' ],
29 );
30  
31 =head1 DESCRIPTION
32  
33 Instances of this class represent the “attributes” collection in a
34 PKCS #10 Certificate Signing Request.
35  
36 You probably don’t need to
37 instantiate this class directly; instead, you can instantiate it
38 implicitly by listing out arguments to
39 L<Crypt::Perl::PKCS10>’s constructor. See that module’s
40 L<SYNOPSIS|Crypt::Perl::PKCS10/SYNOPSIS> for an example.
41  
42 The following X.509 extensions are supported:
43  
44 =over 4
45  
46 =item * L<extensionRequest|Crypt::Perl::X509::Attribute::extensionRequest>
47  
48 =item * L<challengePassword|Crypt::Perl::X509::Attribute::challengePassword>
49 (Note that this attribute does B<NOT> encrypt anything; don’t encode any
50 values that are sensitive data!)
51  
52 =back
53  
54 =cut
55  
56 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 1 ▶use Crypt::Perl::X ();
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 1 use parent qw(
61 Crypt::Perl::ASN1::Encodee
62 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
63  
64 1 ▶use constant ASN1 => <<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 Attributes ::= SET OF Attribute
66 Attribute ::= SEQUENCE {
67 type OBJECT IDENTIFIER,
68 values SET OF ANY
69 }
70 END
71  
72 1 my $ATTR_BASE = 'Crypt::Perl::PCKS10::Attribute';
73  
74 sub new {
75 9 ▶ my ($class, @attrs) = @_;
Subroutine new: called CC=4 SCAR=14.1
Pod undocumented
76  
77 9 for my $attr (@attrs) {
78 18 ▶ if (!try { $attr->isa($ATTR_BASE) }) {
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
unless (&try(sub { $attr->isa($ATTR_BASE); } )) 18 0 18
79 18 ▶ if ( 'ARRAY' eq ref $attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('ARRAY' eq ref $attr) { } 18 0 18
80 18 my $module = $attr->[0];
81 18 my $class = "Crypt::Perl::PKCS10::Attribute::$module";
82 18 Module::Load::load($class);
83 18 $attr = $class->new( @{$attr}[ 1 .. $#$attr ] );
84 }
85 else {
86 0 die Crypt::Perl::X::create('Generic', "Attribute must be ARRAY reference or instance of $ATTR_BASE, not “$attr”!");
87 }
88 }
89 }
90  
91 9 return bless \@attrs, $class;
92 }
93  
94 1 *structure = \&_encode_params;
95  
96 sub _encode_params {
97 9 ▶ my ($self) = @_;
Subroutine _encode_params: called CC=1 SCAR=0.0
98  
99 return [
100 map {
101 9 {
102 18 type => $_->OID(),
103 values => [ $_->encode() ],
104 },
105 } @$self
106 ];
107 }
108  
109 1 1;
« lib/Crypt/Perl/X509/Name.pm ↑ Summary blib/lib/Crypt/Perl.pm »