Class: HexaPDF::Type::Signature::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/type/signature/handler.rb

Overview

The base signature handler providing common functionality.

Specific signature handler need to override methods if necessary and implement the needed ones that don't have a default implementation.

Direct Known Subclasses

AdbePkcs7Detached, AdbeX509RsaSha1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(signature_dict) ⇒ Handler

Creates a new signature handler for the given signature dictionary.



53
54
55
# File 'lib/hexapdf/type/signature/handler.rb', line 53

def initialize(signature_dict)
  @signature_dict = signature_dict
end

Instance Attribute Details

#signature_dictObject (readonly)

The signature dictionary used by the handler.



50
51
52
# File 'lib/hexapdf/type/signature/handler.rb', line 50

def signature_dict
  @signature_dict
end

Instance Method Details

#certificate_chainObject

Returns the certificate chain.

Needs to be implemented by specific handlers.



70
71
72
# File 'lib/hexapdf/type/signature/handler.rb', line 70

def certificate_chain
  raise "Needs to be implemented by specific handlers"
end

#signer_certificateObject

Returns the certificate used for signing.

Needs to be implemented by specific handlers.



77
78
79
# File 'lib/hexapdf/type/signature/handler.rb', line 77

def signer_certificate
  raise "Needs to be implemented by specific handlers"
end

#signer_nameObject

Returns the common name of the signer (/Name field of the signature dictionary).



58
59
60
# File 'lib/hexapdf/type/signature/handler.rb', line 58

def signer_name
  @signature_dict[:Name]
end

#signing_timeObject

Returns the time of signing (/M field of the signature dictionary).



63
64
65
# File 'lib/hexapdf/type/signature/handler.rb', line 63

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.



85
86
87
88
89
90
91
92
# File 'lib/hexapdf/type/signature/handler.rb', line 85

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