Class: ZATCA::UBL::Signing::Cert

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

Constant Summary

Constants inherited from BaseComponent

BaseComponent::ArrayOfBaseComponentOrNil

Instance Attribute Summary

Attributes inherited from BaseComponent

#attributes, #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(cert_digest_value:, cert_issuer_name:, cert_serial_number:) ⇒ Cert

<xades:Cert>

<xades:CertDigest>
  <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
  <ds:DigestValue>NjlhOTVmYzIzN2I0MjcxNGRjNDQ1N2EzM2I5NGNjNDUyZmQ5ZjExMDUwNGM2ODNjNDAxMTQ0ZDk1NDQ4OTRmYg==</ds:DigestValue>
</xades:CertDigest>
<xades:IssuerSerial>
  <ds:X509IssuerName>CN=TSZEINVOICE-SubCA-1, DC=extgazt, DC=gov, DC=local</ds:X509IssuerName>
  <ds:X509SerialNumber>2475382876776561391517206651645660279462721580</ds:X509SerialNumber>
</xades:IssuerSerial>

</xades:Cert>



13
14
15
16
17
18
19
# File 'lib/zatca/ubl/signing/cert.rb', line 13

def initialize(cert_digest_value:, cert_issuer_name:, cert_serial_number:)
  super()

  @cert_digest_value = cert_digest_value
  @cert_issuer_name = cert_issuer_name
  @cert_serial_number = cert_serial_number
end

Instance Method Details

#elementsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zatca/ubl/signing/cert.rb', line 25

def elements
  [
    ZATCA::UBL::BaseComponent.new(name: "xades:CertDigest", elements: [
      ZATCA::UBL::BaseComponent.new(
        name: "ds:DigestMethod",
        attributes: {
          "Algorithm" => "http://www.w3.org/2001/04/xmlenc#sha256"
        }
      ),
      ZATCA::UBL::BaseComponent.new(name: "ds:DigestValue", value: @cert_digest_value)
    ]),
    ZATCA::UBL::BaseComponent.new(name: "xades:IssuerSerial", elements: [
      ZATCA::UBL::BaseComponent.new(
        name: "ds:X509IssuerName",
        value: @cert_issuer_name
      ),
      ZATCA::UBL::BaseComponent.new(
        name: "ds:X509SerialNumber",
        value: @cert_serial_number
      )
    ])
  ]
end

#nameObject



21
22
23
# File 'lib/zatca/ubl/signing/cert.rb', line 21

def name
  "xades:Cert"
end