Class: OpenTox::Authorization::Helper

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

Overview

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

Examples:

Creating a default policy to a URI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHelper

Generates an AuthorizationHelper object - requires subjectid


30
31
32
33
# File 'lib/authorization.rb', line 30

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

Instance Attribute Details

#policyObject

Returns the value of attribute policy


26
27
28
# File 'lib/authorization.rb', line 26

def policy
  @policy
end

#userObject

Returns the value of attribute user


26
27
28
# File 'lib/authorization.rb', line 26

def user
  @user
end

Instance Method Details

#get_xml(uri) ⇒ Object

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


38
39
40
41
42
# File 'lib/authorization.rb', line 38

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


46
47
48
49
50
51
52
53
54
55
# File 'lib/authorization.rb', line 46

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