File Coverage

blib/lib/SBOM/CycloneDX/CryptoProperties/CertificateProperties.pm
Criterion Covered Total %
statement 26 51 50.9
branch 0 38 0.0
condition n/a
subroutine 9 10 90.0
pod 1 1 100.0
total 36 100 36.0


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::CryptoProperties::CertificateProperties;
2              
3 1     1   22 use 5.010001;
  1         4  
4 1     1   9 use strict;
  1         2  
  1         46  
5 1     1   7 use warnings;
  1         2  
  1         62  
6 1     1   6 use utf8;
  1         3  
  1         9  
7              
8 1     1   32 use SBOM::CycloneDX::Timestamp;
  1         4  
  1         38  
9              
10 1     1   5 use Types::Standard qw(Str InstanceOf);
  1         3  
  1         10  
11 1     1   3705 use Types::TypeTiny qw(ArrayLike);
  1         2  
  1         10  
12              
13 1     1   1013 use Moo;
  1         3  
  1         27  
14 1     1   499 use namespace::autoclean;
  1         3  
  1         12  
15              
16             extends 'SBOM::CycloneDX::Base';
17              
18             has serial_number => (is => 'rw', isa => Str);
19             has subject_name => (is => 'rw', isa => Str);
20             has issuer_name => (is => 'rw', isa => Str);
21              
22             has not_valid_before => (
23             is => 'rw',
24             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
25             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
26             );
27              
28             has not_valid_after => (
29             is => 'rw',
30             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
31             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
32             );
33              
34             has signature_algorithm_ref => (is => 'rw', isa => Str); # [DEPRECATED 1.7] Bom-ref like
35             has subject_public_key_ref => (is => 'rw', isa => Str); # [DEPRECATED 1.7] Bom-ref like
36             has certificate_format => (is => 'rw', isa => Str);
37             has certificate_extension => (is => 'rw', isa => Str); # [DEPRECATED 1.7]
38             has certificate_file_extension => (is => 'rw', isa => Str);
39              
40             has fingerprint => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Hash']);
41              
42             has certificate_state => (
43             is => 'rw',
44             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::CryptoProperties::CertificateState']],
45             default => sub { SBOM::CycloneDX::List->new }
46             );
47              
48             has creation_date => (
49             is => 'rw',
50             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
51             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
52             );
53              
54             has activation_date => (
55             is => 'rw',
56             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
57             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
58             );
59              
60             has deactivation_date => (
61             is => 'rw',
62             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
63             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
64             );
65              
66             has revocation_date => (
67             is => 'rw',
68             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
69             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
70             );
71              
72             has destruction_date => (
73             is => 'rw',
74             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
75             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
76             );
77              
78             has certificate_extensions => (
79             is => 'rw',
80             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::CryptoProperties::CertificateExtension']],
81             default => sub { SBOM::CycloneDX::List->new }
82             );
83              
84             has related_cryptographic_assets => (
85             is => 'rw',
86             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::CryptoProperties::RelatedCryptographicAsset']],
87             default => sub { SBOM::CycloneDX::List->new }
88             );
89              
90             sub TO_JSON {
91              
92 0     0 1   my $self = shift;
93              
94 0           my $json = {};
95              
96 0 0         $json->{serialNumber} = $self->serial_number if $self->serial_number;
97 0 0         $json->{subjectName} = $self->subject_name if $self->subject_name;
98 0 0         $json->{issuerName} = $self->issuer_name if $self->issuer_name;
99 0 0         $json->{notValidBefore} = $self->not_valid_before if $self->not_valid_before;
100 0 0         $json->{notValidAfter} = $self->not_valid_after if $self->not_valid_after;
101 0 0         $json->{signatureAlgorithmRef} = $self->signature_algorithm_ref if $self->signature_algorithm_ref;
102 0 0         $json->{subjectPublicKeyRef} = $self->subject_public_key_ref if $self->subject_public_key_ref;
103 0 0         $json->{certificateFormat} = $self->certificate_format if $self->certificate_format;
104 0 0         $json->{certificateExtension} = $self->certificate_extension if $self->certificate_extension;
105 0 0         $json->{certificateFileExtension} = $self->certificate_file_extension if $self->certificate_file_extension;
106 0 0         $json->{fingerprint} = $self->fingerprint if $self->fingerprint;
107 0 0         $json->{certificateState} = $self->certificate_state if @{$self->certificate_state};
  0            
108 0 0         $json->{creationDate} = $self->creation_date if $self->creation_date;
109 0 0         $json->{activationDate} = $self->activation_date if $self->activation_date;
110 0 0         $json->{deactivationDate} = $self->deactivation_date if $self->deactivation_date;
111 0 0         $json->{revocationDate} = $self->revocation_date if $self->revocation_date;
112 0 0         $json->{destructionDate} = $self->destruction_date if $self->destruction_date;
113 0 0         $json->{certificateExtensions} = $self->certificate_extensions if @{$self->certificate_extensions};
  0            
114 0 0         $json->{relatedCryptographicAssets} = $self->related_cryptographic_assets if @{$self->related_cryptographic_assets};
  0            
115              
116 0           return $json;
117              
118             }
119              
120             1;
121              
122             =encoding utf-8
123              
124             =head1 NAME
125              
126             SBOM::CycloneDX::CryptoProperties::CertificateProperties - Properties for cryptographic
127             assets of asset type 'certificate'
128              
129             =head1 SYNOPSIS
130              
131             SBOM::CycloneDX::CryptoProperties::CertificateProperties->new();
132              
133              
134             =head1 DESCRIPTION
135              
136             L specifies the properties for
137             cryptographic assets of asset type 'certificate'.
138              
139             =head2 METHODS
140              
141             L inherits all methods from L
142             and implements the following new ones.
143              
144             =over
145              
146             =item SBOM::CycloneDX::CryptoProperties::CertificateProperties->new( %PARAMS )
147              
148             Properties:
149              
150             =over
151              
152             =item * C, The date and time (timestamp) when the certificate was activated.
153              
154             =item * C, [DEPRECATED] This will be removed in a future version.
155             Use C instead. The file extension of the certificate.
156              
157             =item * C, A certificate extension is a field that
158             provides additional information about the certificate or its use. Extensions
159             are used to convey additional information beyond the standard fields.
160              
161             See L
162              
163             =item * C, The file extension of the certificate
164              
165             =item * C, The format of the certificate
166              
167             =item * C, Certificate Lifecycle State
168              
169             The certificate lifecycle is a comprehensive process that manages digital
170             certificates from their initial creation to eventual expiration or revocation.
171             It typically involves several stages.
172              
173             See L
174              
175             =item * C, The date and time (timestamp) when the certificate was created or pre-activated.
176              
177             =item * C, The date and time (timestamp) when the related certificate was deactivated.
178              
179             =item * C, The date and time (timestamp) when the certificate was destroyed.
180              
181             =item * C, The fingerprint is a cryptographic hash of the certificate excluding it's signature.
182              
183             See L
184              
185             =item * C, The issuer name for the certificate
186              
187             =item * C, The date and time according to ISO-8601 standard
188             from which the certificate is not valid anymore
189              
190             =item * C, The date and time according to ISO-8601 standard
191             from which the certificate is valid
192              
193             =item * C,
194              
195             =item * C, The date and time (timestamp) when the certificate was revoked.
196              
197             =item * C, The serial number is a unique identifier for the certificate issued by a CA.
198              
199             =item * C, [DEPRECATED] This will be removed in a future version. Use C instead.
200             The bom-ref to signature algorithm used by the certificate.
201              
202             =item * C, The subject name for the certificate
203              
204             =item * C, [DEPRECATED] This will be removed in a future version. Use C instead.
205             The bom-ref to the public key of the subject.
206              
207             =back
208              
209             =item $certificate_properties->activation_date
210              
211             =item $certificate_properties->certificate_extension
212              
213             =item $certificate_properties->certificate_extensions
214              
215             =item $certificate_properties->certificate_format
216              
217             =item $certificate_properties->certificate_state
218              
219             =item $certificate_properties->creation_date
220              
221             =item $certificate_properties->deactivation_date
222              
223             =item $certificate_properties->destruction_date
224              
225             =item $certificate_properties->fingerprint
226              
227             =item $certificate_properties->issuer_name
228              
229             =item $certificate_properties->not_valid_after
230              
231             =item $certificate_properties->not_valid_before
232              
233             =item $certificate_properties->related_cryptographic_assets
234              
235             =item $certificate_properties->revocation_date
236              
237             =item $certificate_properties->serial_number
238              
239             =item $certificate_properties->signature_algorithm_ref
240              
241             =item $certificate_properties->subject_name
242              
243             =item $certificate_properties->subject_public_key_ref
244              
245             =back
246              
247              
248              
249             =head1 SUPPORT
250              
251             =head2 Bugs / Feature Requests
252              
253             Please report any bugs or feature requests through the issue tracker
254             at L.
255             You will be notified automatically of any progress on your issue.
256              
257             =head2 Source Code
258              
259             This is open source software. The code repository is available for
260             public review and contribution under the terms of the license.
261              
262             L
263              
264             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
265              
266              
267             =head1 AUTHOR
268              
269             =over 4
270              
271             =item * Giuseppe Di Terlizzi
272              
273             =back
274              
275              
276             =head1 LICENSE AND COPYRIGHT
277              
278             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
279              
280             This is free software; you can redistribute it and/or modify it under
281             the same terms as the Perl 5 programming language system itself.
282              
283             =cut