class RestPki::XmlElementSignatureStarter

Attributes

element_tosign_id[RW]
id_resolution_table[RW]

Public Class Methods

new(restpki_client) click to toggle source
Calls superclass method
# File lib/rest_pki/xml_element_signature_starter.rb, line 5
def initialize(restpki_client)
    super(restpki_client)
    @element_tosign_id = nil
    @id_resolution_table = nil
end

Public Instance Methods

start() click to toggle source
# File lib/rest_pki/xml_element_signature_starter.rb, line 36
def start
    verify_common_parameters(true)
    if @xml_content_base64.to_s.blank?
        raise 'The XML was not set'
    end
    if @element_tosign_id.to_s.blank?
        raise 'The XML element id to sign was not set'
    end

    request = get_request
    request['elementToSignId'] = @element_tosign_id
    unless @id_resolution_table.nil?
        request['idResolutionTable'] = @id_resolution_table.to_model
    end

    response = @restpki_client.post('Api/XmlSignatures/XmlElementSignature', request, 'xml_model')

    unless response['certificate'].nil?
        @certificate = response['certificate']
    end
    @done = true

    {
        :token => response['token'],
        :to_sign_data => response['toSignData'],
        :to_sign_hash => response['toSignHash'],
        :digest_algorithm_oid => response['digestAlgorithmOid'],
        :signature_algorithm => get_signature_algorithm(response['digestAlgorithmOid'])
    }
end
start_with_webpki() click to toggle source
# File lib/rest_pki/xml_element_signature_starter.rb, line 11
def start_with_webpki
    verify_common_parameters(true)
    if @xml_content_base64.to_s.blank?
        raise 'The XML was not set'
    end
    if @element_tosign_id.to_s.blank?
        raise 'The XML element id to sign was not set'
    end

    request = get_request
    request['elementToSignId'] = @element_tosign_id
    unless @id_resolution_table.nil?
        request['idResolutionTable'] = @id_resolution_table.to_model
    end

    response = @restpki_client.post('Api/XmlSignatures/XmlElementSignature', request, 'xml_model')

    unless response['certificate'].nil?
        @certificate = response['certificate']
    end
    @done = true

    response['token']
end