 xmlenc        = require 'xml-encryption'
 zlib          = require 'zlib'
 
+xmlns =
+  saml: 'urn:oasis:names:tc:SAML:2.0:assertion'
+  samlp: 'urn:oasis:names:tc:SAML:2.0:protocol'
+  md: 'urn:oasis:names:tc:SAML:2.0:metadata'
+  ds: 'http://www.w3.org/2000/09/xmldsig#'
+  xenc: 'http://www.w3.org/2001/04/xmlenc#'
+
 # Creates an AuthnRequest and returns it as a string of xml along with the randomly generated ID for the created
 # request.
 create_authn_request = (issuer, assert_endpoint, destination) ->
   id = '_' + crypto.randomBytes(21).toString('hex')
   xml = xmlbuilder.create
     AuthnRequest:
-      '@xmlns': 'urn:oasis:names:tc:SAML:2.0:protocol'
-      '@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion'
+      '@xmlns': xmlns.samlp
+      '@xmlns:saml': xmlns.saml
       '@Version': '2.0'
       '@ID': id
       '@IssueInstant': (new Date()).toISOString()

  {
    '@use': use
    'ds:KeyInfo':
      '@xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#'
      'ds:X509Data':
        'ds:X509Certificate':
          cert_data.replace(/[\r\n|\n]/g, '')

          setImmediate cb_wf, null, raw
        (response_buffer, cb_wf) ->
          saml_response = (new xmldom.DOMParser()).parseFromString(response_buffer.toString())
          console.log response_buffer.toString()
          async.lift(parse_response_header) saml_response, cb_wf
        (response_header, cb_wf) =>
          response = { response_header }
          cb_wf new Error("SAML Response was not success!") unless check_status_success(saml_response)
          switch
            when saml_response.getElementsByTagNameNS(xmlns.samlp, 'Response').length is 1
              response.type = 'authn_response'
              parse_authn_response saml_response, @private_key, identity_provider.certificate, cb_wf
            when saml_response.getElementsByTagNameNS(xmlns.samlp, 'LogoutResponse').length is 1
              response.type = 'logout_response'
              setImmediate cb_wf, null, {}
        (result, cb_wf) ->
