Class: NemID::XMLDSig::Document

Inherits:
Xmldsig::SignedDocument
  • Object
show all
Defined in:
lib/nemid/xmldsig/document.rb

Instance Method Summary collapse

Constructor Details

#initialize(document, options = {}) ⇒ Document

Returns a new instance of Document.



6
7
8
9
10
11
# File 'lib/nemid/xmldsig/document.rb', line 6

def initialize(document, options = {})
  super
  @store = OpenSSL::X509::Store.new
  @user_certificate = nil
  extract_and_store_certificates
end

Instance Method Details

#extract_pid_or_ridObject



13
14
15
# File 'lib/nemid/xmldsig/document.rb', line 13

def extract_pid_or_rid
  return @user_certificate.subject.to_a.assoc("serialNumber")[1]
end

#get_user_certificateObject



17
18
19
# File 'lib/nemid/xmldsig/document.rb', line 17

def get_user_certificate
  return @user_certificate
end

#user_certificate_expired?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/nemid/xmldsig/document.rb', line 21

def user_certificate_expired?
  @user_certificate.not_after < Time.now.utc
end

#user_certificate_revoked?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
# File 'lib/nemid/xmldsig/document.rb', line 25

def user_certificate_revoked?
  ocsp.request(
    subject: @user_certificate,
    issuer: @intermediate_cert,
    ca: @root_cert
  )
rescue NemID::OCSP::Error
  return true
end

#validate_certificate_chainObject



35
36
37
# File 'lib/nemid/xmldsig/document.rb', line 35

def validate_certificate_chain
  @store.verify(@user_certificate)
end

#validate_signatureObject



39
40
41
# File 'lib/nemid/xmldsig/document.rb', line 39

def validate_signature
  validate(@user_certificate)
end