line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2015 Jerry Lundström |
2
|
|
|
|
|
|
|
# Copyright (c) 2015 .SE (The Internet Infrastructure Foundation) |
3
|
|
|
|
|
|
|
# All rights reserved. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without |
6
|
|
|
|
|
|
|
# modification, are permitted provided that the following conditions |
7
|
|
|
|
|
|
|
# are met: |
8
|
|
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright |
9
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer. |
10
|
|
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright |
11
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the |
12
|
|
|
|
|
|
|
# documentation and/or other materials provided with the distribution. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
15
|
|
|
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
16
|
|
|
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
17
|
|
|
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
18
|
|
|
|
|
|
|
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
19
|
|
|
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
20
|
|
|
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21
|
|
|
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22
|
|
|
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23
|
|
|
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24
|
|
|
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Crypt::PKCS11::Attribute::AttributeArray; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
11
|
use common::sense; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
29
|
2
|
|
|
2
|
|
86
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
114
|
|
30
|
2
|
|
|
2
|
|
8
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
78
|
|
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
2
|
|
8
|
use base qw(Crypt::PKCS11::Attribute); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1230
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub push { |
35
|
3
|
|
|
3
|
1
|
10
|
my ($self) = CORE::shift; |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
7
|
CORE::foreach (@_) { |
38
|
3
|
100
|
100
|
|
|
25
|
unless (blessed($_) and $_->isa('Crypt::PKCS11::Attribute')) { |
39
|
2
|
|
|
|
|
203
|
confess 'Value to push is not a Crypt::PKCS11::Attribute object'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
1
|
|
|
|
|
3
|
CORE::push(@{$self->{attributes}}, @_); |
|
1
|
|
|
|
|
7
|
|
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
5
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub pop { |
48
|
1
|
|
|
1
|
1
|
2
|
return CORE::pop(@{$_[0]->{attributes}}); |
|
1
|
|
|
|
|
5
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub shift { |
52
|
1
|
|
|
1
|
1
|
2
|
return CORE::shift(@{$_[0]->{attributes}}); |
|
1
|
|
|
|
|
5
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub unshift { |
56
|
3
|
|
|
3
|
1
|
4
|
my ($self) = CORE::shift; |
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
7
|
CORE::foreach (@_) { |
59
|
3
|
100
|
100
|
|
|
26
|
unless (blessed($_) and $_->isa('Crypt::PKCS11::Attribute')) { |
60
|
2
|
|
|
|
|
200
|
confess 'Value to unshift is not a Crypt::PKCS11::Attribute object'; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
1
|
|
|
|
|
2
|
CORE::unshift(@{$self->{attributes}}, @_); |
|
1
|
|
|
|
|
4
|
|
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
3
|
return $self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub foreach { |
69
|
2
|
|
|
2
|
1
|
297
|
my ($self, $cb) = @_; |
70
|
|
|
|
|
|
|
|
71
|
2
|
100
|
|
|
|
7
|
unless (ref($cb) eq 'CODE') { |
72
|
1
|
|
|
|
|
136
|
confess '$cb argument is not CODE'; |
73
|
|
|
|
|
|
|
} |
74
|
1
|
|
|
|
|
2
|
CORE::foreach (@{$self->{attributes}}) { |
|
1
|
|
|
|
|
3
|
|
75
|
1
|
|
|
|
|
3
|
$cb->($_); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
5
|
return $self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub toArray { |
82
|
2
|
|
|
2
|
1
|
5
|
my ($self) = @_; |
83
|
2
|
|
|
|
|
3
|
my @array; |
84
|
|
|
|
|
|
|
|
85
|
2
|
|
|
|
|
3
|
CORE::foreach (@{$self->{attributes}}) { |
|
2
|
|
|
|
|
4
|
|
86
|
2
|
|
|
|
|
16
|
CORE::push(@array, { type => $_->type, pValue => $_->pValue }); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
2
|
|
|
|
|
9
|
return \@array; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub set { |
93
|
3
|
|
|
3
|
1
|
4
|
my $self = CORE::shift; |
94
|
|
|
|
|
|
|
|
95
|
3
|
|
|
|
|
5
|
foreach (@_) { |
96
|
3
|
100
|
100
|
|
|
24
|
unless (blessed($_) and $_->isa('Crypt::PKCS11::Attribute')) { |
97
|
2
|
|
|
|
|
201
|
confess 'Value to set is not a Crypt::PKCS11::Attribute object'; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
3
|
$self->{attributes} = [ @_ ]; |
102
|
|
|
|
|
|
|
|
103
|
1
|
|
|
|
|
4
|
return $self; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub pValue { |
107
|
1
|
|
|
1
|
1
|
5
|
return $_[0]->toArray; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |