Class: OpenTox::Authorization::AA

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

Overview

Helper Class AA to create and send default policies out of xml templates

Examples:

Creating a default policy to a URI

aa=OpenTox::Authorization::AA.new(tok)  
xml=aa.get_xml('http://uri....')
OpenTox::Authorization.create_policy(xml,tok)   

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subjectid) ⇒ AA

Generates AA object - requires subjectid

Parameters:



23
24
25
26
27
# File 'lib/authorization.rb', line 23

def initialize(subjectid)
  @user = Authorization.get_user(subjectid)
  @subjectid = subjectid
  @policy = Policies.new()
end

Instance Attribute Details

#policyObject

Returns the value of attribute policy.



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

def policy
  @policy
end

#subjectidObject

Returns the value of attribute subjectid.



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

def subjectid
  @subjectid
end

#userObject

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#get_xml(uri) ⇒ Object

Cleans AA Policies and loads default xml file into policy attribute set uri and user, returns Policyfile(XML) for open-sso

Parameters:

  • URI (String)

    to create a policy for



32
33
34
35
36
# File 'lib/authorization.rb', line 32

def get_xml(uri)
  @policy.drop_policies
  @policy.load_default_policy(@user, uri)
  return @policy.to_xml
end

#send(uri) ⇒ Object

Loads and sends Policyfile(XML) to open-sso server

Parameters:

  • URI (String)

    to create a policy for



40
41
42
43
44
45
46
47
48
49
# File 'lib/authorization.rb', line 40

def send(uri)
  xml = get_xml(uri)
  ret = false
  ret = Authorization.create_policy(xml, @subjectid)
  LOGGER.warn "Create policy on openSSO failed for URI: #{uri} subjectid: #{@subjectid}. Will try again." if !ret
  ret = Authorization.create_policy(xml, @subjectid) if !ret
  LOGGER.debug "Policy send with subjectid: #{@subjectid}"
  LOGGER.warn "Not created Policy is: #{xml}" if !ret
  ret
end