Class: ZATCA::UBL::Signing::Signature

Inherits:
BaseComponent show all
Defined in:
lib/zatca/ubl/signing/signature.rb

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ArrayOfBaseComponentOrNil

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#index, #value

Instance Method Summary collapse

Methods inherited from BaseComponent

#[], build, #build_xml, #dig, #find_nested_element_by_path, #generate_xml, #schema, #to_h, #to_xml

Constructor Details

#initialize(invoice_hash:, signed_properties_hash:, signature_value:, certificate:, signing_time:, cert_digest_value:, cert_issuer_name:, cert_serial_number:) ⇒ Signature

Returns a new instance of Signature.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zatca/ubl/signing/signature.rb', line 4

def initialize(
  invoice_hash:, signed_properties_hash:, signature_value:,
  certificate:, signing_time:, cert_digest_value:, cert_issuer_name:,
  cert_serial_number:
)
  super()

  @invoice_digest = invoice_hash
  @signed_properties_hash = signed_properties_hash
  @signature_value = signature_value
  @certificate = certificate
  @signing_time = signing_time
  @cert_digest_value = cert_digest_value
  @cert_issuer_name = cert_issuer_name
  @cert_serial_number = cert_serial_number
end

Instance Attribute Details

#cert_digest_valueObject (readonly)

Returns the value of attribute cert_digest_value.



2
3
4
# File 'lib/zatca/ubl/signing/signature.rb', line 2

def cert_digest_value
  @cert_digest_value
end

#cert_issuer_nameObject (readonly)

Returns the value of attribute cert_issuer_name.



2
3
4
# File 'lib/zatca/ubl/signing/signature.rb', line 2

def cert_issuer_name
  @cert_issuer_name
end

#cert_serial_numberObject (readonly)

Returns the value of attribute cert_serial_number.



2
3
4
# File 'lib/zatca/ubl/signing/signature.rb', line 2

def cert_serial_number
  @cert_serial_number
end

#signing_timeObject (readonly)

Returns the value of attribute signing_time.



2
3
4
# File 'lib/zatca/ubl/signing/signature.rb', line 2

def signing_time
  @signing_time
end

Instance Method Details

#attributesObject



21
22
23
24
25
26
# File 'lib/zatca/ubl/signing/signature.rb', line 21

def attributes
  {
    "xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
    "Id" => "signature"
  }
end

#elementsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zatca/ubl/signing/signature.rb', line 32

def elements
  [
    ZATCA::UBL::Signing::SignedInfo.new(
      invoice_digest: @invoice_digest,
      signed_properties_hash: @signed_properties_hash
    ),

    ZATCA::UBL::BaseComponent.new(name: "ds:SignatureValue", value: @signature_value),
    ZATCA::UBL::Signing::KeyInfo.new(certificate: @certificate),

    ZATCA::UBL::Signing::Object.new(
      signing_time: @signing_time,
      cert_digest_value: @cert_digest_value,
      cert_issuer_name: @cert_issuer_name,
      cert_serial_number: @cert_serial_number
    )
  ]
end

#nameObject



28
29
30
# File 'lib/zatca/ubl/signing/signature.rb', line 28

def name
  "ds:Signature"
end