Class: Saml::Kit::Builders::LogoutRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/saml/kit/builders/logout_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, configuration: Saml::Kit.configuration, sign: true) ⇒ LogoutRequest

Returns a new instance of LogoutRequest.



9
10
11
12
13
14
15
16
17
# File 'lib/saml/kit/builders/logout_request.rb', line 9

def initialize(user, configuration: Saml::Kit.configuration, sign: true)
  @user = user
  @id = "_#{SecureRandom.uuid}"
  @issuer = configuration.issuer
  @name_id_format = Saml::Kit::Namespaces::PERSISTENT
  @now = Time.now.utc
  @version = "2.0"
  @sign = sign
end

Instance Attribute Details

#destination ⇒ Object

Returns the value of attribute destination.



5
6
7
# File 'lib/saml/kit/builders/logout_request.rb', line 5

def destination
  @destination
end

#id ⇒ Object

Returns the value of attribute id.



5
6
7
# File 'lib/saml/kit/builders/logout_request.rb', line 5

def id
  @id
end

#issuer ⇒ Object

Returns the value of attribute issuer.



5
6
7
# File 'lib/saml/kit/builders/logout_request.rb', line 5

def issuer
  @issuer
end

#name_id_format ⇒ Object

Returns the value of attribute name_id_format.



5
6
7
# File 'lib/saml/kit/builders/logout_request.rb', line 5

def name_id_format
  @name_id_format
end

#now ⇒ Object

Returns the value of attribute now.



5
6
7
# File 'lib/saml/kit/builders/logout_request.rb', line 5

def now
  @now
end

#sign ⇒ Object

Returns the value of attribute sign.



6
7
8
# File 'lib/saml/kit/builders/logout_request.rb', line 6

def sign
  @sign
end

#user ⇒ Object (readonly)

Returns the value of attribute user.



7
8
9
# File 'lib/saml/kit/builders/logout_request.rb', line 7

def user
  @user
end

#version ⇒ Object

Returns the value of attribute version.



6
7
8
# File 'lib/saml/kit/builders/logout_request.rb', line 6

def version
  @version
end

Instance Method Details

#build ⇒ Object



30
31
32
# File 'lib/saml/kit/builders/logout_request.rb', line 30

def build
  Saml::Kit::LogoutRequest.new(to_xml)
end

#to_xml ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/saml/kit/builders/logout_request.rb', line 19

def to_xml
  Signature.sign(sign: sign) do |xml, signature|
    xml.instruct!
    xml.LogoutRequest logout_request_options do
      xml.Issuer({ xmlns: Namespaces::ASSERTION }, issuer)
      signature.template(id)
      xml.NameID name_id_options, user.name_id_for(name_id_format)
    end
  end
end