Class: SamlIdp::AssertionBuilder

Inherits:
Object
  • Object
show all
Includes:
Algorithmable, Signable
Defined in:
lib/saml_idp/assertion_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Signable

included, #sign, #signed

Constructor Details

#initialize(reference_id, issuer_uri, principal, audience_uri, saml_request_id, saml_acs_url, raw_algorithm, authn_context_classref, expiry = 60*60, encryption_opts = nil, session_expiry = nil, name_id_formats_opts = nil, asserted_attributes_opts = nil) ⇒ AssertionBuilder

Returns a new instance of AssertionBuilder.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/saml_idp/assertion_builder.rb', line 24

def initialize(
    reference_id,
    issuer_uri,
    principal,
    audience_uri,
    saml_request_id,
    saml_acs_url,
    raw_algorithm,
    authn_context_classref,
    expiry=60*60,
    encryption_opts=nil,
    session_expiry=nil,
    name_id_formats_opts = nil,
    asserted_attributes_opts = nil
)
  self.reference_id = reference_id
  self.issuer_uri = issuer_uri
  self.principal = principal
  self.audience_uri = audience_uri
  self.saml_request_id = saml_request_id
  self.saml_acs_url = saml_acs_url
  self.raw_algorithm = raw_algorithm
  self.authn_context_classref = authn_context_classref
  self.expiry = expiry
  self.encryption_opts = encryption_opts
  self.session_expiry = session_expiry.nil? ? config.session_expiry : session_expiry
  self.name_id_formats_opts = name_id_formats_opts
  self.asserted_attributes_opts = asserted_attributes_opts
end

Instance Attribute Details

#asserted_attributes_optsObject

Returns the value of attribute asserted_attributes_opts.



20
21
22
# File 'lib/saml_idp/assertion_builder.rb', line 20

def asserted_attributes_opts
  @asserted_attributes_opts
end

#audience_uriObject

Returns the value of attribute audience_uri.



11
12
13
# File 'lib/saml_idp/assertion_builder.rb', line 11

def audience_uri
  @audience_uri
end

#authn_context_classrefObject

Returns the value of attribute authn_context_classref.



15
16
17
# File 'lib/saml_idp/assertion_builder.rb', line 15

def authn_context_classref
  @authn_context_classref
end

#encryption_optsObject

Returns the value of attribute encryption_opts.



17
18
19
# File 'lib/saml_idp/assertion_builder.rb', line 17

def encryption_opts
  @encryption_opts
end

#expiryObject

Returns the value of attribute expiry.



16
17
18
# File 'lib/saml_idp/assertion_builder.rb', line 16

def expiry
  @expiry
end

#issuer_uriObject

Returns the value of attribute issuer_uri.



9
10
11
# File 'lib/saml_idp/assertion_builder.rb', line 9

def issuer_uri
  @issuer_uri
end

#name_id_formats_optsObject

Returns the value of attribute name_id_formats_opts.



19
20
21
# File 'lib/saml_idp/assertion_builder.rb', line 19

def name_id_formats_opts
  @name_id_formats_opts
end

#principalObject

Returns the value of attribute principal.



10
11
12
# File 'lib/saml_idp/assertion_builder.rb', line 10

def principal
  @principal
end

#raw_algorithmObject

Returns the value of attribute raw_algorithm.



14
15
16
# File 'lib/saml_idp/assertion_builder.rb', line 14

def raw_algorithm
  @raw_algorithm
end

#reference_idObject

Returns the value of attribute reference_id.



8
9
10
# File 'lib/saml_idp/assertion_builder.rb', line 8

def reference_id
  @reference_id
end

#saml_acs_urlObject

Returns the value of attribute saml_acs_url.



13
14
15
# File 'lib/saml_idp/assertion_builder.rb', line 13

def saml_acs_url
  @saml_acs_url
end

#saml_request_idObject

Returns the value of attribute saml_request_id.



12
13
14
# File 'lib/saml_idp/assertion_builder.rb', line 12

def saml_request_id
  @saml_request_id
end

#session_expiryObject

Returns the value of attribute session_expiry.



18
19
20
# File 'lib/saml_idp/assertion_builder.rb', line 18

def session_expiry
  @session_expiry
end

Instance Method Details

#encrypt(opts = {}) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/saml_idp/assertion_builder.rb', line 110

def encrypt(opts = {})
  raise "Must set encryption_opts to encrypt" unless encryption_opts
  raw_xml = opts[:sign] ? signed : raw
  require 'saml_idp/encryptor'
  encryptor = Encryptor.new encryption_opts
  encryptor.encrypt(raw_xml)
end