class RestPki::XmlSignatureStarter

Public Class Methods

new(restpki_client) click to toggle source
Calls superclass method RestPki::SignatureStarter::new
# File lib/rest_pki/xml_signature_starter.rb, line 6
def initialize(restpki_client)
    super(restpki_client)
    @xml_content_base64 = nil
    @signature_element_id = nil
    @xpath = nil
    @insertion_option = nil
    @namespace_manager = nil
end

Public Instance Methods

set_signature_element_location(xpath, insertion_option, namespace_manager=nil) click to toggle source

endregion

# File lib/rest_pki/xml_signature_starter.rb, line 43
def set_signature_element_location(xpath, insertion_option, namespace_manager=nil)
    @xpath = xpath
    @insertion_option = insertion_option
    @namespace_manager = namespace_manager
end
set_xml_content_tosign(content_raw) click to toggle source
# File lib/rest_pki/xml_signature_starter.rb, line 33
def set_xml_content_tosign(content_raw)
    set_xml_tosign_from_raw(content_raw)
end
set_xml_file_tosign(xml_path) click to toggle source
# File lib/rest_pki/xml_signature_starter.rb, line 37
def set_xml_file_tosign(xml_path)
    set_xml_tosign_from_path(xml_path)
end
set_xml_tosign_from_base64(content_base64) click to toggle source
# File lib/rest_pki/xml_signature_starter.rb, line 29
def set_xml_tosign_from_base64(content_base64)
    @xml_content_base64 = content_base64
end
set_xml_tosign_from_path(xml_path) click to toggle source

region set_xml_tosign

# File lib/rest_pki/xml_signature_starter.rb, line 17
def set_xml_tosign_from_path(xml_path)
    file = File.open(xml_path, 'rb')
    @xml_content_base64 = Base64.encode64(file.read)
    file.close

    @xml_content_base64
end
set_xml_tosign_from_raw(content_raw) click to toggle source
# File lib/rest_pki/xml_signature_starter.rb, line 25
def set_xml_tosign_from_raw(content_raw)
    @xml_content_base64 = Base64.encode64(content_raw)
end

Protected Instance Methods

get_request() click to toggle source
# File lib/rest_pki/xml_signature_starter.rb, line 62
def get_request
    request = {
        signatureElementId: @signature_element_id,
        signaturePolicyId: @signature_policy_id,
        securityContextId: @security_context_id,
        ignoreRevocationStatusUnknown: @ignore_revocation_status_unknown
    }
    unless @xml_content_base64.to_s.blank?
        request['xml'] = @xml_content_base64
    end
    unless @xpath.nil? or @insertion_option.nil?
        request['signatureElementLocation'] = {
            xPath: @xpath,
            insertionOption: @insertion_option
        }
        unless @namespace_manager.nil?
            request['signatureElementLocation']['namespaces'] = @namespace_manager.namespaces
        end
    end
    request
end
verify_common_parameters(is_with_webpki=false) click to toggle source
# File lib/rest_pki/xml_signature_starter.rb, line 50
def verify_common_parameters(is_with_webpki=false)
    unless is_with_webpki
        if @signer_certificate_base64.to_s.blank?
            raise 'The certificate was not set'
        end
    end

    if @signature_policy_id.to_s.blank?
        raise 'The signature policy was not set'
    end
end