Class: HexaPDF::DigitalSignature::Handler
- Inherits:
-
Object
- Object
- HexaPDF::DigitalSignature::Handler
- Defined in:
- lib/hexapdf/digital_signature/handler.rb
Overview
The base signature handler providing common functionality.
Specific signature handlers need to override methods if necessary and implement the needed ones that don’t have a default implementation.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#signature_dict ⇒ Object
readonly
The signature dictionary used by the handler.
Instance Method Summary collapse
-
#certificate_chain ⇒ Object
Returns the certificate chain.
-
#initialize(signature_dict) ⇒ Handler
constructor
Creates a new signature handler for the given signature dictionary.
-
#signer_certificate ⇒ Object
Returns the certificate used for signing.
-
#signer_name ⇒ Object
Returns the common name of the signer (/Name field of the signature dictionary).
-
#signing_time ⇒ Object
Returns the time of signing (/M field of the signature dictionary).
-
#verify(store, allow_self_signed: false) ⇒ Object
Verifies general signature properties and prepares the provided OpenSSL::X509::Store object for use by concrete implementations.
Constructor Details
#initialize(signature_dict) ⇒ Handler
Creates a new signature handler for the given signature dictionary.
52 53 54 |
# File 'lib/hexapdf/digital_signature/handler.rb', line 52 def initialize(signature_dict) @signature_dict = signature_dict end |
Instance Attribute Details
#signature_dict ⇒ Object (readonly)
The signature dictionary used by the handler.
49 50 51 |
# File 'lib/hexapdf/digital_signature/handler.rb', line 49 def signature_dict @signature_dict end |
Instance Method Details
#certificate_chain ⇒ Object
Returns the certificate chain.
Needs to be implemented by specific handlers.
69 70 71 |
# File 'lib/hexapdf/digital_signature/handler.rb', line 69 def certificate_chain raise "Needs to be implemented by specific handlers" end |
#signer_certificate ⇒ Object
Returns the certificate used for signing.
Needs to be implemented by specific handlers.
76 77 78 |
# File 'lib/hexapdf/digital_signature/handler.rb', line 76 def signer_certificate raise "Needs to be implemented by specific handlers" end |
#signer_name ⇒ Object
Returns the common name of the signer (/Name field of the signature dictionary).
57 58 59 |
# File 'lib/hexapdf/digital_signature/handler.rb', line 57 def signer_name @signature_dict[:Name] end |
#signing_time ⇒ Object
Returns the time of signing (/M field of the signature dictionary).
62 63 64 |
# File 'lib/hexapdf/digital_signature/handler.rb', line 62 def signing_time @signature_dict[:M] end |
#verify(store, allow_self_signed: false) ⇒ Object
Verifies general signature properties and prepares the provided OpenSSL::X509::Store object for use by concrete implementations.
Needs to be called by specific handlers.
84 85 86 87 88 89 90 91 |
# File 'lib/hexapdf/digital_signature/handler.rb', line 84 def verify(store, allow_self_signed: false) result = VerificationResult.new check_certified_signature(result) verify_signing_time(result) store.verify_callback = store_verification_callback(result, allow_self_signed: allow_self_signed) result end |