Class: Facturae::Xades::ObjectInfo

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/facturae/xades/object_info.rb

Overview

This class is responsible for building the XAdES ObjectInfo element.

Constant Summary collapse

ALGORITHM_SHA1 =
"http://www.w3.org/2000/09/xmldsig#sha1"
ALGORITHM_SHA512 =
"http://www.w3.org/2001/04/xmlenc#sha512"
OBJECT_DESCRIPTION =
"Factura electrónica"
OBJECT_IDENTIFIER =
"urn:oid:1.2.840.10003.5.109.10"
OBJECT_QUALIFIER =
"OIDAsURN"
OBJECT_MIME_TYPE =
"text/xml"
SIG_POLICY_URL =
"http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf"
SIG_POLICY_DESCRIPTION =
"Política de Firma FacturaE v3.1"
SIG_POLICY_HASH_DIGEST =
"Ohixl6upD6av8N7pEvDABhEL6hM="
NAMESPACES =
{
  "ds" => "http://www.w3.org/2000/09/xmldsig#",
  "xades" => "http://uri.etsi.org/01903/v1.3.2#"
}.freeze

Instance Method Summary collapse

Methods included from Utils

#base64_encode, #base64_encode_raw, #calculate_sha512_digest, #create_xml_element, #create_xml_node_with_algorithm, #rand_id

Constructor Details

#initialize(doc, certificate, signing_ids) ⇒ ObjectInfo

Initializes a new instance of ObjectInfo.

Parameters:

  • doc (Nokogiri::XML::Document)

    The XML document to work with

  • certificate (OpenSSL::X509::Certificate)

    The X509 certificate used for signing

  • signing_ids (Hash)

    A hash containing the IDs used in the signature: - :signature_id [String] The ID of the signature element - :signed_properties_id [String] The ID of the signed properties element - :signature_object_id [String] The ID of the signature object element - :reference_id [String] The ID of the reference element



33
34
35
36
37
38
39
40
41
# File 'lib/facturae/xades/object_info.rb', line 33

def initialize(doc, certificate, signing_ids)
  @doc = doc
  @certificate = certificate

  @signature_id = signing_ids[:signature_id]
  @signed_properties_id = signing_ids[:signed_properties_id]
  @signature_object_id = signing_ids[:signature_object_id]
  @reference_id = signing_ids[:reference_id]
end

Instance Method Details

#buildObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/facturae/xades/object_info.rb', line 43

def build
  main_node = create_xml_element(@doc, "ds:Object", nil, { "Id" => @signature_object_id })

  qualifying_props_node = create_xml_element(@doc, "xades:QualifyingProperties", nil,
                                             { "Target" => "##{@signature_id}" })
  signed_properties_node = create_xml_element(@doc, "xades:SignedProperties", nil,
                                              { "Id" => @signed_properties_id })

  signed_properties_node.add_child(build_signed_signature_properties_node)
  signed_properties_node.add_child(build_signed_data_object_properties_node)

  qualifying_props_node.add_child(signed_properties_node)
  main_node.add_child(qualifying_props_node)

  main_node
end