File Coverage

blib/lib/STIX/Observable/X509Certificate.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod n/a
total 43 43 100.0


line stmt bran cond sub pod time code
1             package STIX::Observable::X509Certificate;
2              
3 24     24   546 use 5.010001;
  24         113  
4 24     24   151 use strict;
  24         53  
  24         677  
5 24     24   134 use warnings;
  24         47  
  24         1463  
6 24     24   4613 use utf8;
  24         4559  
  24         210  
7              
8 24     24   1320 use Types::Standard qw(Str Int InstanceOf Bool);
  24         95  
  24         266  
9              
10 24     24   94174 use Moo;
  24         68  
  24         215  
11 24     24   11633 use namespace::autoclean;
  24         63  
  24         276  
12              
13             extends 'STIX::Observable';
14              
15 24         2743 use constant SCHEMA =>
16 24     24   2826 'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/x509-certificate.json';
  24         64  
17              
18 24         1849 use constant PROPERTIES => (
19             qw(type id),
20             qw(spec_version object_marking_refs granular_markings defanged extensions),
21             qw(is_self_signed hashes version serial_number signature_algorithm issuer validity_not_before validity_not_after subject subject_public_key_algorithm subject_public_key_modulus subject_public_key_exponent x509_v3_extensions),
22 24     24   191 );
  24         66  
23              
24 24     24   154 use constant STIX_OBJECT => 'SCO';
  24         56  
  24         1329  
25 24     24   170 use constant STIX_OBJECT_TYPE => 'x509-certificate';
  24         92  
  24         11167  
26              
27             has is_self_signed => (is => 'rw', isa => Bool);
28             has hashes => (is => 'rw', isa => InstanceOf ['STIX::Common::Hashes']);
29             has version => (is => 'rw', isa => Str);
30             has serial_number => (is => 'rw', isa => Str);
31             has signature_algorithm => (is => 'rw', isa => Str);
32             has issuer => (is => 'rw', isa => Str);
33              
34             has validity_not_before => (
35             is => 'rw',
36             isa => InstanceOf ['STIX::Common::Timestamp'],
37             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
38             );
39              
40             has validity_not_after => (
41             is => 'rw',
42             isa => InstanceOf ['STIX::Common::Timestamp'],
43             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
44             );
45              
46             has subject => (is => 'rw', isa => Str);
47             has subject_public_key_algorithm => (is => 'rw', isa => Str);
48             has subject_public_key_modulus => (is => 'rw', isa => Str);
49             has subject_public_key_exponent => (is => 'rw', isa => Int);
50             has x509_v3_extensions => (is => 'rw', isa => InstanceOf ['STIX::Observable::Type::X509V3Extensions']);
51              
52             1;
53              
54             =encoding utf-8
55              
56             =head1 NAME
57              
58             STIX::Observable::X509Certificate - STIX Cyber-observable Object (SCO) - X.509 Certificate
59              
60             =head1 SYNOPSIS
61              
62             use STIX::Observable::X509Certificate;
63              
64             my $x509_certificate = STIX::Observable::X509Certificate->new();
65              
66              
67             =head1 DESCRIPTION
68              
69             The X509 Certificate Object represents the properties of an X.509
70             certificate.
71              
72              
73             =head2 METHODS
74              
75             L inherits all methods from L
76             and implements the following new ones.
77              
78             =over
79              
80             =item STIX::Observable::X509Certificate->new(%properties)
81              
82             Create a new instance of L.
83              
84             =item $x509_certificate->hashes
85              
86             Specifies any hashes that were calculated for the entire contents of the
87             certificate.
88              
89             =item $x509_certificate->id
90              
91             =item $x509_certificate->is_self_signed
92              
93             Specifies whether the certificate is self-signed, i.e., whether it is
94             signed by the same entity whose identity it certifies.
95              
96             =item $x509_certificate->issuer
97              
98             Specifies the name of the Certificate Authority that issued the
99             certificate.
100              
101             =item $x509_certificate->serial_number
102              
103             Specifies the unique identifier for the certificate, as issued by a
104             specific Certificate Authority.
105              
106             =item $x509_certificate->signature_algorithm
107              
108             Specifies the name of the algorithm used to sign the certificate.
109              
110             =item $x509_certificate->subject
111              
112             Specifies the name of the entity associated with the public key stored in
113             the subject public key field of the certificate.
114              
115             =item $x509_certificate->subject_public_key_algorithm
116              
117             Specifies the name of the algorithm with which to encrypt data being sent
118             to the subject.
119              
120             =item $x509_certificate->subject_public_key_exponent
121              
122             Specifies the exponent portion of the subject’s public RSA key, as an
123             integer.
124              
125             =item $x509_certificate->subject_public_key_modulus
126              
127             Specifies the modulus portion of the subject’s public RSA key.
128              
129             =item $x509_certificate->type
130              
131             The value of this property MUST be C.
132              
133             =item $x509_certificate->validity_not_after
134              
135             Specifies the date on which the certificate validity period ends.
136              
137             =item $x509_certificate->validity_not_before
138              
139             Specifies the date on which the certificate validity period begins.
140              
141             =item $x509_certificate->version
142              
143             Specifies the version of the encoded certificate.
144              
145             =item $x509_certificate->x509_v3_extensions
146              
147             Specifies any standard X.509 v3 extensions that may be used in the
148             certificate.
149              
150             =back
151              
152              
153             =head2 HELPERS
154              
155             =over
156              
157             =item $x509_certificate->TO_JSON
158              
159             Encode the object in JSON.
160              
161             =item $x509_certificate->to_hash
162              
163             Return the object HASH.
164              
165             =item $x509_certificate->to_string
166              
167             Encode the object in JSON.
168              
169             =item $x509_certificate->validate
170              
171             Validate the object using JSON Schema
172             (see L).
173              
174             =back
175              
176              
177             =head1 SUPPORT
178              
179             =head2 Bugs / Feature Requests
180              
181             Please report any bugs or feature requests through the issue tracker
182             at L.
183             You will be notified automatically of any progress on your issue.
184              
185             =head2 Source Code
186              
187             This is open source software. The code repository is available for
188             public review and contribution under the terms of the license.
189              
190             L
191              
192             git clone https://github.com/giterlizzi/perl-STIX.git
193              
194              
195             =head1 AUTHOR
196              
197             =over 4
198              
199             =item * Giuseppe Di Terlizzi
200              
201             =back
202              
203              
204             =head1 LICENSE AND COPYRIGHT
205              
206             This software is copyright (c) 2024 by Giuseppe Di Terlizzi.
207              
208             This is free software; you can redistribute it and/or modify it under
209             the same terms as the Perl 5 programming language system itself.
210              
211             =cut