Class: FakeIdp::SamlResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_idp/saml_response.rb

Constant Summary collapse

DSIG =
"http://www.w3.org/2000/09/xmldsig#"
SAML_VERSION =
"2.0"
ASSERTION_NAMESPACE =
"urn:oasis:names:tc:SAML:2.0:assertion"
ENTITY_FORMAT =
"urn:oasis:names:SAML:2.0:nameid-format:entity"
BEARER_FORMAT =
"urn:oasis:names:tc:SAML:2.0:cm:bearer"
ENVELOPE_SCHEMA =
"http://www.w3.org/2000/09/xmldsig#enveloped-signature"
STATUS_CODE_VALUE =
"urn:oasis:names:tc:SAML:2.0:status:Success"
FEDERATION_SOURCE =
"urn:federation:authentication:windows"
EMAIL_ADDRESS_FORMAT =
"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
CANONICAL_VALUE =

For the time being we’re only supporting a single canonical schema since supporting multiple is inconsequential for our immediate need.

1
CANONICAL_SCHEMA =
"http://www.w3.org/2001/10/xml-exc-c14n#"

Instance Method Summary collapse

Constructor Details

#initialize(name_id:, issuer_uri:, saml_acs_url:, saml_request_id:, user_attributes:, algorithm_name:, certificate:, secret_key:, encryption_enabled: false) ⇒ SamlResponse

Returns a new instance of SamlResponse.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fake_idp/saml_response.rb', line 25

def initialize(
  name_id:,
  issuer_uri:,
  saml_acs_url:,
  saml_request_id:,
  user_attributes:,
  algorithm_name:,
  certificate:,
  secret_key:,
  encryption_enabled: false
)
  @name_id = name_id
  @issuer_uri = issuer_uri
  @saml_acs_url = saml_acs_url
  @saml_request_id = saml_request_id
  @user_attributes = user_attributes
  @algorithm_name = algorithm_name
  @certificate = certificate
  @secret_key = secret_key
  @encryption_enabled = encryption_enabled
  @builder = Nokogiri::XML::Builder.new
  @timestamp = Time.now
end

Instance Method Details

#buildObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fake_idp/saml_response.rb', line 49

def build
  @builder[:samlp].Response(root_namespace_attributes) do |response|
    build_issuer_segment(response)
    build_status_segment(response)
    build_assertion_segment(response)
  end

  document_with_digest = replace_digest_value(@builder.to_xml)
  document = replace_signature_value(document_with_digest)
  encrypt_assertion!(document)
end