Class: Saml2::AuthnRequest
- Inherits:
-
Object
- Object
- Saml2::AuthnRequest
- Defined in:
- lib/saml2/authn_request.rb
Instance Attribute Summary collapse
-
#assertion_consumer_service_url ⇒ Object
readonly
Returns the value of attribute assertion_consumer_service_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#issue_instant ⇒ Object
readonly
Returns the value of attribute issue_instant.
-
#issuer ⇒ Object
readonly
Returns the value of attribute issuer.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ AuthnRequest
constructor
A new instance of AuthnRequest.
- #to_xml ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ AuthnRequest
Returns a new instance of AuthnRequest.
5 6 7 8 9 10 |
# File 'lib/saml2/authn_request.rb', line 5 def initialize(attrs = {}) @issuer = attrs.fetch(:issuer) @id = SecureRandom.uuid @issue_instant = Time.now.utc.strftime('%FT%TZ') @assertion_consumer_service_url = attrs[:assertion_consumer_service_url] end |
Instance Attribute Details
#assertion_consumer_service_url ⇒ Object (readonly)
Returns the value of attribute assertion_consumer_service_url.
3 4 5 |
# File 'lib/saml2/authn_request.rb', line 3 def assertion_consumer_service_url @assertion_consumer_service_url end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/saml2/authn_request.rb', line 3 def id @id end |
#issue_instant ⇒ Object (readonly)
Returns the value of attribute issue_instant.
3 4 5 |
# File 'lib/saml2/authn_request.rb', line 3 def issue_instant @issue_instant end |
#issuer ⇒ Object (readonly)
Returns the value of attribute issuer.
3 4 5 |
# File 'lib/saml2/authn_request.rb', line 3 def issuer @issuer end |
Instance Method Details
#to_xml ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/saml2/authn_request.rb', line 12 def to_xml Nokogiri::XML::Builder.new do |xml| xml.AuthnRequest('xmlns:samlp' => 'urn:oasis:names:tc:SAML:2.0:protocol', 'xmlns:saml' => 'urn:oasis:names:tc:SAML:2.0:assertion', 'ID' => id, 'Version' => '2.0', 'IssueInstant' => issue_instant, 'AssertionConsumerServiceURL' => assertion_consumer_service_url) do xml.parent.namespace = xml.parent.namespace_definitions.find {|ns| ns.prefix == 'samlp'} # Necessary to output namespace prefix on root element. xml['saml'].Issuer issuer end end.to_xml end |