Class: Sepa::NordeaResponse

Inherits:
Response show all
Includes:
Utilities
Defined in:
lib/sepa/banks/nordea/nordea_response.rb

Overview

Handles Nordea 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 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

Methods inherited from Response

#application_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

Constructor Details

This class inherits a constructor from Sepa::Response

Instance Method Details

#certificate_is_trusted?true, false

Checks whether the certificate embedded in the response soap has been signed with Nordea's root certificate.

Returns:

  • (true)

    if certificate is trusted

  • (false)

    if certificate fails to verify

See Also:



55
56
57
# File 'lib/sepa/banks/nordea/nordea_response.rb', line 55

def certificate_is_trusted?
  verify_certificate_against_root_certificate(certificate, NORDEA_ROOT_CERTIFICATE)
end

#own_signing_certificateString?

Extracts own signing certificate from the response.

Returns:

  • (String)

    own signing certificate as string it it is found

  • (nil)

    if the certificate cannot be found



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sepa/banks/nordea/nordea_response.rb', line 11

def own_signing_certificate
  application_response = extract_application_response(NORDEA_PKI)
  at = 'xmlns|Certificate > xmlns|Certificate'
  node = Nokogiri::XML(application_response).at(at, xmlns: NORDEA_XML_DATA)

  return unless node

  cert_value = process_cert_value node.content
  cert = x509_certificate cert_value
  cert.to_s
end

#response_codeString?

Returns the response code in the response. Overrides Response#response_code if Response#command is :get_certificate, because the namespace is different with that command.

Returns:

  • (String)

    response code if it is found

  • (nil)

    if response code cannot be found

See Also:



29
30
31
32
33
34
# File 'lib/sepa/banks/nordea/nordea_response.rb', line 29

def response_code
  return super unless [:get_certificate, :renew_certificate].include? command

  node = doc.at('xmlns|ResponseCode', xmlns: NORDEA_PKI)
  node.content if node
end

#response_textString?

Returns the response text in the response. Overrides Response#response_text if Response#command is :get_certificate, because the namespace is different with that command.

Returns:

  • (String)

    response text if it is found

  • (nil)

    if response text cannot be found

See Also:



42
43
44
45
46
47
# File 'lib/sepa/banks/nordea/nordea_response.rb', line 42

def response_text
  return super unless [:get_certificate, :renew_certificate].include? command

  node = doc.at('xmlns|ResponseText', xmlns: NORDEA_PKI)
  node.content if node
end