Class: Pdfrb::Model::Type::Dss

Inherits:
Cos::Dictionary show all
Defined in:
lib/pdfrb/model/type/dss.rb

Overview

DSS (Document Security Store) per ETSI EN 319 142-1 (PAdES) §B.5. Attached to the Catalog via the /DSS key. Holds the long-term validation material: certificates, CRLs, OCSP responses, and per-signature VRI dictionaries.

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, merged_field, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Dictionary

Instance Method Details

#certificates(document = nil) ⇒ Object

/Certs — array of indirect streams, each a DER-encoded X.509 certificate used by any signature in the document.



20
21
22
# File 'lib/pdfrb/model/type/dss.rb', line 20

def certificates(document = nil)
  resolve_streams(value[:Certs], document)
end

#crls(document = nil) ⇒ Object

/CRLs — array of indirect streams, each a DER-encoded certificate revocation list.



32
33
34
# File 'lib/pdfrb/model/type/dss.rb', line 32

def crls(document = nil)
  resolve_streams(value[:CRLs], document)
end

#each_vri(document = nil) ⇒ Object

Enumerate each (signature-hash, Vri) pair, resolving the VRI dicts to typed instances.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pdfrb/model/type/dss.rb', line 44

def each_vri(document = nil)
  return enum_for(:each_vri, document) unless block_given?

  map = vri_map
  return unless map

  raw = map.is_a?(Pdfrb::Model::Cos::Dictionary) ? map.value : map
  raw.each do |sig_hash, ref|
    resolved = if ref.is_a?(Pdfrb::Model::Reference) && document
                 document.object(ref)
               else
                 ref
               end
    next unless resolved && resolved.value.is_a?(::Hash)

    yield sig_hash.to_s, Vri.new(resolved.value)
  end
end

#ocsp_responses(document = nil) ⇒ Object

/OCSPs — array of indirect streams, each a DER-encoded OCSP response.



26
27
28
# File 'lib/pdfrb/model/type/dss.rb', line 26

def ocsp_responses(document = nil)
  resolve_streams(value[:OCSPs], document)
end

#typeObject

/Type — optional, fixed "DSS".



14
15
16
# File 'lib/pdfrb/model/type/dss.rb', line 14

def type
  value[:Type]&.to_sym
end

#vri_for(signature_sha1_hex, document = nil) ⇒ Object

Look up a VRI by the hex-encoded SHA-1 digest of the signature's DER bytes.



65
66
67
# File 'lib/pdfrb/model/type/dss.rb', line 65

def vri_for(signature_sha1_hex, document = nil)
  each_vri(document).find { |h, _v| h == signature_sha1_hex }&.last
end

#vri_mapObject

/VRI — optional map of SHA-1 hex digest -> VRI dict for each signature. Returns the raw Hash.



38
39
40
# File 'lib/pdfrb/model/type/dss.rb', line 38

def vri_map
  value[:VRI]
end