File Coverage

lib/Crypt/Perl/X509/GeneralName.pm
Criterion Covered Total %
statement 21 24 87.5
branch 4 6 66.6
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 32 38 84.2


line stmt bran cond sub pod time code
1             package Crypt::Perl::X509::GeneralName;
2              
3 4     4   22 use strict;
  4         10  
  4         106  
4 4     4   28 use warnings;
  4         5  
  4         87  
5              
6 4     4   754 use Crypt::Perl::X509::Name ();
  4         8  
  4         79  
7              
8 4     4   25 use parent qw( Crypt::Perl::ASN1::Encodee );
  4         8  
  4         16  
9              
10 4     4   339 use constant ASN1 => Crypt::Perl::X509::Name::ASN1() . <
  4         7  
  4         788  
11             AnotherName ::= SEQUENCE {
12             type OBJECT IDENTIFIER,
13             value [0] EXPLICIT ANY
14             }
15              
16             EDIPartyName ::= SEQUENCE {
17             nameAssigner [0] DirectoryString OPTIONAL,
18             partyName [1] DirectoryString
19             }
20              
21             -- No support for “compound” values until there’s a use case
22             -- that can verify functionality. (OpenSSL’s parse doesn’t know
23             -- what to do with the compound values as of 1.0.1j.)
24             GeneralName ::= CHOICE {
25             -- otherName [0] AnotherName,
26             rfc822Name [1] IA5String,
27             dNSName [2] IA5String,
28             -- x400Address [3] ORAddress,
29             directoryName [4] EXPLICIT ANY,
30              
31             -- I’ve not figured out how to get OpenSSL to create this,
32             -- and OpenSSL 1.0.1j doesn’t parse output from the below correctly.
33             -- ediPartyName [5] EDIPartyName,
34              
35             uniformResourceIdentifier [6] IA5String,
36             iPAddress [7] OCTET STRING,
37             registeredID [8] OBJECT IDENTIFIER
38             }
39             END
40              
41             sub new {
42 140     140 0 362 my ($class, $type, $value) = @_;
43              
44 140 50       488 if ($type eq 'otherName') {
    100          
    50          
45 0         0 $value = {
46             type => $value->[0],
47             value => $value->[1],
48             };
49             }
50             elsif ($type eq 'directoryName') {
51 30         186 $value = Crypt::Perl::X509::Name->new(@$value)->encode();
52             #substr( $value, 0, 1 ) = "\xa4";
53             }
54             elsif ($type eq 'ediPartyName') {
55 0         0 $value = { %$value };
56 0         0 $_ = { utf8String => $_ } for values %$value;
57             }
58              
59 140         4061 return bless [ $type => $value ], $class;
60             }
61              
62             sub _encode_params {
63 140     140   317 my ($self) = @_;
64              
65 140         514 return { @$self }; #“de-bless”
66             }
67              
68             1;