Class: HexaPDF::Type::DocumentSecurityStore
- Inherits:
-
Dictionary
- Object
- Object
- Dictionary
- HexaPDF::Type::DocumentSecurityStore
- Defined in:
- lib/hexapdf/type/document_security_store.rb
Overview
The document security store (DSS) dictionary contains data needed for verifying digital signatures.
See: PDF2.0 s12.8.4.3
Defined Under Namespace
Classes: ValidationRelatedInformation
Constant Summary
Constants included from DictionaryFields
DictionaryFields::Boolean, DictionaryFields::PDFByteString, DictionaryFields::PDFDate
Instance Method Summary collapse
-
#add_cert(cert_der) ⇒ Object
Adds the DER-encoded certificate to the /Certs array if not already present and returns the stream object containing it.
-
#add_crl(crl_der) ⇒ Object
Adds the DER-encoded CRL to the /CRLs array if not already present and returns the stream object containing it.
-
#add_ocsp(ocsp_der) ⇒ Object
Adds the DER-encoded OCSP response to the /OCSPs array if not already present and returns the stream object containing it.
-
#add_vri(signature, certs: [], ocsps: [], crls: []) ⇒ Object
Adds validation data for a single signature to the /VRI dictionary and to the various arrays, and returns the new VRI entry.
Methods inherited from Dictionary
#[], #[]=, define_field, define_type, #delete, #each, each_field, #empty?, field, #key?, #to_hash, type, #type
Instance Method Details
#add_cert(cert_der) ⇒ Object
Adds the DER-encoded certificate to the /Certs array if not already present and returns the stream object containing it.
99 100 101 |
# File 'lib/hexapdf/type/document_security_store.rb', line 99 def add_cert(cert_der) add_data_as_stream_to_field(cert_der, :Certs) end |
#add_crl(crl_der) ⇒ Object
Adds the DER-encoded CRL to the /CRLs array if not already present and returns the stream object containing it.
111 112 113 |
# File 'lib/hexapdf/type/document_security_store.rb', line 111 def add_crl(crl_der) add_data_as_stream_to_field(crl_der, :CRLs) end |
#add_ocsp(ocsp_der) ⇒ Object
Adds the DER-encoded OCSP response to the /OCSPs array if not already present and returns the stream object containing it.
105 106 107 |
# File 'lib/hexapdf/type/document_security_store.rb', line 105 def add_ocsp(ocsp_der) add_data_as_stream_to_field(ocsp_der, :OCSPs) end |
#add_vri(signature, certs: [], ocsps: [], crls: []) ⇒ Object
Adds validation data for a single signature to the /VRI dictionary and to the various arrays, and returns the new VRI entry.
signatureThe signature for which the validation data should be added.
certsArray of DER-encoded certificates.
ocspsArray of DER-encoded OCSP responses.
crlsArray of DER-encoded CRLs.
88 89 90 91 92 93 94 95 |
# File 'lib/hexapdf/type/document_security_store.rb', line 88 def add_vri(signature, certs: [], ocsps: [], crls: []) key = OpenSSL::Digest::SHA1.hexdigest(signature.contents).upcase.to_sym vri = {Type: :VRI} vri[:Cert] = certs.map {|der| add_cert(der) } unless certs.empty? vri[:OCSP] = ocsps.map {|der| add_ocsp(der) } unless ocsps.empty? vri[:CRL] = crls.map {|der| add_crl(der) } unless crls.empty? (self[:VRI] ||= {})[key] = document.add(vri) end |