Class: SAML::Core::RequestAbstract

Inherits:
Object
  • Object
show all
Defined in:
lib/saml/core/request_abstract.rb

Direct Known Subclasses

AuthnRequest, LogoutRequest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clock_class = Time) ⇒ RequestAbstract

Returns a new instance of RequestAbstract.



13
14
15
16
17
# File 'lib/saml/core/request_abstract.rb', line 13

def initialize(clock_class=Time)
  @id            = UUID.new.generate
  @version       = '2.0'
  @issue_instant = clock_class.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/saml/core/request_abstract.rb', line 7

def id
  @id
end

#issue_instantObject (readonly)

Returns the value of attribute issue_instant.



9
10
11
# File 'lib/saml/core/request_abstract.rb', line 9

def issue_instant
  @issue_instant
end

#issuerObject

Returns the value of attribute issuer.



11
12
13
# File 'lib/saml/core/request_abstract.rb', line 11

def issuer
  @issuer
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/saml/core/request_abstract.rb', line 8

def version
  @version
end

Instance Method Details

#to_xmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/saml/core/request_abstract.rb', line 25

def to_xml
  xml = xml_document
  root = xml.root
  root.attributes['ID']           = @id
  root.attributes['IssueInstant'] = @issue_instant
  root.attributes['Version']      = @version

  unless @issuer.nil?
    issuer_node = root.add_element("saml:Issuer")
    issuer_node.text = @issuer
  end
  
  xml
end

#xml_documentObject



19
20
21
22
# File 'lib/saml/core/request_abstract.rb', line 19

def xml_document
  xml = Document.new
  root = xml.add_element("samlp:RequestAbstract")
end