Class: Sepa::SamlinkResponse

Inherits:
Response show all
Defined in:
lib/sepa/banks/samlink/samlink_response.rb

Overview

Handles Samlink specific response logic. Mainly certificate specific stuff.

Constant Summary

Constants included from ErrorMessages

ErrorMessages::CONTENT_ERROR_MESSAGE, ErrorMessages::CUSTOMER_ID_ERROR_MESSAGE, ErrorMessages::DECRYPTION_ERROR_MESSAGE, ErrorMessages::ENCRYPTION_CERT_ERROR_MESSAGE, ErrorMessages::ENCRYPTION_CERT_REQUEST_ERROR_MESSAGE, ErrorMessages::ENCRYPTION_PRIVATE_KEY_ERROR_MESSAGE, ErrorMessages::ENVIRONMENT_ERROR_MESSAGE, ErrorMessages::FILE_REFERENCE_ERROR_MESSAGE, ErrorMessages::FILE_TYPE_ERROR_MESSAGE, ErrorMessages::HASH_ERROR_MESSAGE, ErrorMessages::NOT_OK_RESPONSE_CODE_ERROR_MESSAGE, ErrorMessages::PIN_ERROR_MESSAGE, ErrorMessages::SIGNATURE_ERROR_MESSAGE, ErrorMessages::SIGNING_CERT_REQUEST_ERROR_MESSAGE, ErrorMessages::STATUS_ERROR_MESSAGE, ErrorMessages::TARGET_ID_ERROR_MESSAGE

Instance Attribute Summary

Attributes inherited from Response

#command, #environment, #error, #soap

Instance Method Summary collapse

Methods inherited from Response

#bank_encryption_certificate, #bank_root_certificate, #bank_signing_certificate, #ca_certificate, #certificate, #client_errors, #content, #doc, #document_must_validate_against_schema, #error_doc, #extract_application_response, #file_references, #find_digest_values, #find_node_by_uri, #find_nodes_to_verify, #hashes_match?, #initialize, #own_encryption_certificate, #response_code_is_ok?, #signature_is_valid?, #to_s, #validate_hashes, #validate_response_code, #verify_certificate, #verify_signature

Methods included from Utilities

#calculate_digest, #canonicalize_exclusively, #canonicalized_node, #cert_request_valid?, #check_validity_against_schema, #csr_to_binary, #decode, #encode, #extract_cert, #format_cert, #format_cert_request, #hmac, #iso_time, #load_body_template, #process_cert_value, #rsa_key, #set_node_id, #validate_signature, #verify_certificate_against_root_certificate, #x509_certificate, #xml_doc

Constructor Details

This class inherits a constructor from Sepa::Response

Instance Method Details

#application_responseObject



14
15
16
# File 'lib/sepa/banks/samlink/samlink_response.rb', line 14

def application_response
  [:get_certificate, :renew_certificate].include?(command) ? super(namespace: SAMLINK_PKI) : super
end

#certificate_is_trusted?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
# File 'lib/sepa/banks/samlink/samlink_response.rb', line 24

def certificate_is_trusted?
  case environment
  when :production
    # Samlink doesn't provide a CA certificate for production environment and that's why we check that the
    #   certificate provided is equal to the known trusted certificate.
    certificate.to_s == SAMLINK_CERTIFICATE.to_s
  when :test
    verify_certificate_against_root_certificate(certificate, SAMLINK_ROOT_CERTIFICATE)
  end
end

#own_signing_certificateObject



18
19
20
21
22
# File 'lib/sepa/banks/samlink/samlink_response.rb', line 18

def own_signing_certificate
  (node = Nokogiri::XML(application_response).at('xmlns|Certificate > xmlns|Certificate', xmlns: OP_XML_DATA)) &&
    (content = node.content) &&
    x509_certificate(decode(content)).to_s
end

#response_codeObject



5
6
7
# File 'lib/sepa/banks/samlink/samlink_response.rb', line 5

def response_code
  [:get_certificate, :renew_certificate].include?(command) ? super(namespace: SAMLINK_PKI) : super
end

#response_textObject



10
11
12
# File 'lib/sepa/banks/samlink/samlink_response.rb', line 10

def response_text
  [:get_certificate, :renew_certificate].include?(command) ? super(namespace: SAMLINK_PKI) : super
end