Class: EtFakeAcasServer::InternalErrorXmlBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/et_fake_acas_server/xml_builders/internal_error_xml_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(form, rsa_et_certificate_path:) ⇒ InternalErrorXmlBuilder

Returns a new instance of InternalErrorXmlBuilder.



7
8
9
10
# File 'lib/et_fake_acas_server/xml_builders/internal_error_xml_builder.rb', line 7

def initialize(form, rsa_et_certificate_path:)
  self.form = form
  self.rsa_et_certificate = OpenSSL::X509::Certificate.new File.read(rsa_et_certificate_path)
end

Instance Method Details

#builderObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/et_fake_acas_server/xml_builders/internal_error_xml_builder.rb', line 20

def builder
  Nokogiri::XML::Builder.new do |xml|
    namespaces = {
        'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope',
        'xmlns:u' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'
    }
    xml['s'].Envelope(namespaces) do
      xml['s'].Header do
        xml.ActivityId("e67a4d86-e096-4a35-aa3a-2b3a8ffaaa54", 'CorrelationId': '03973d23-3c39-4359-aa69-4d37b922fb60', xmlns: 'http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics')
        xml['o'].Security('s:mustUnderstand': '1', 'xmlns:o': 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd') do
          xml['u'].Timestamp('u:Id': '_0') do
            xml['u'].Created '2014-03-03T10:15.01.251Z'
            xml['u'].Expires '2014-03-03T10:20:01.251Z'
          end
        end
      end
      xml['s'].Body do
        xml.GetECCertificateResponse(xmlns: 'https://ec.acas.org.uk/lookup/') do
          xml.GetECCertificateResult('xmlns:a': 'http://schemas.datacontract.org/2004/07/Acas.CertificateLookup.EcLookupService', 'xmlns:i': 'http://www.w3.org/2001/XMLSchema-instance') do
            xml['a'].CurrentDateTime Base64.encode64(aes_encrypt(Time.now.strftime('%d/%m/%Y %H:%M:%S')))
            xml['a'].IV Base64.encode64(rsa_encrypt(Base64.encode64(iv)))
            xml['a'].Key Base64.encode64(rsa_encrypt(Base64.encode64(key)))
            xml['a'].Message Base64.encode64(aes_encrypt('An internal error has occured in ACAS'))
            xml['a'].ResponseCode Base64.encode64(aes_encrypt('500'))
            xml['a'].ServiceVersion Base64.encode64(aes_encrypt('1.0'))
          end
        end
      end
    end
  end

end

#ivObject



16
17
18
# File 'lib/et_fake_acas_server/xml_builders/internal_error_xml_builder.rb', line 16

def iv
  @iv ||= '12345678901234567890123456789012'
end

#keyObject



12
13
14
# File 'lib/et_fake_acas_server/xml_builders/internal_error_xml_builder.rb', line 12

def key
  @key ||= '12345678901234567890123456789012'
end