Class: OpenTox::Policy

Inherits:
Object show all
Defined in:
lib/policy.rb

Overview

single policy in a Policies instance

Defined Under Namespace

Classes: Rule, Subject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Policy


200
201
202
203
204
205
# File 'lib/policy.rb', line 200

def initialize(name)
  @name = name
  @rule = Rule.new("#{name}_rule", nil)
  @subject_group = "#{name}_subjects"
  @subject = Subject.new("#{name}_subject", nil, nil)
end

Instance Attribute Details

#groupObject

Get the groupname from within the LDAP Distinguished Name (DN)


243
244
245
# File 'lib/policy.rb', line 243

def group
  @group
end

#nameObject

Returns the value of attribute name


198
199
200
# File 'lib/policy.rb', line 198

def name
  @name
end

#ruleObject

Returns the value of attribute rule


198
199
200
# File 'lib/policy.rb', line 198

def rule
  @rule
end

#subjectObject

Returns the value of attribute subject


198
199
200
# File 'lib/policy.rb', line 198

def subject
  @subject
end

#subject_groupObject

Returns the value of attribute subject_group


198
199
200
# File 'lib/policy.rb', line 198

def subject_group
  @subject_group
end

#typeString

Subject type LDAPUsers or LDAPGroups


209
210
211
# File 'lib/policy.rb', line 209

def type
  @type
end

#uriString

uri affected by policy


232
233
234
# File 'lib/policy.rb', line 232

def uri
  @uri
end

#userObject

Get the username from within the LDAP Distinguished Name (DN)


249
250
251
# File 'lib/policy.rb', line 249

def user
  @user
end

#valueObject

returns LDAP Distinguished Name (DN) e.g. uid=username,ou=people,dc=opentox,dc=org or cn=membergroup,ou=groups,dc=opentox,dc=org


220
221
222
# File 'lib/policy.rb', line 220

def value
  @value
end

Instance Method Details

#set_ot_group(groupname) ⇒ Object


263
264
265
266
267
# File 'lib/policy.rb', line 263

def set_ot_group(groupname)
  self.value = "cn=#{groupname},ou=groups,dc=opentox,dc=org"
  self.type = "LDAPGroups"
  true
end

#set_ot_user(username) ⇒ Object

helper method sets value and type to opentox LDAP Distinguished Name (DN) of a user


256
257
258
259
260
# File 'lib/policy.rb', line 256

def set_ot_user(username)
  self.value = "uid=#{username},ou=people,dc=opentox,dc=org"
  self.type = "LDAPUsers"
  true
end