Class: Principal

Inherits:
ACL_Object show all
Defined in:
lib/principal.rb

Direct Known Subclasses

Group, Individual

Instance Attribute Summary

Attributes inherited from ACL_Object

#col_path, #doc

Instance Method Summary collapse

Methods inherited from ACL_Object

#create_new, #del_membership, #find_parents, #ge, #rename

Constructor Details

#initialize(connector, col_path, report = false) ⇒ Principal

Returns a new instance of Principal.



2
3
4
5
# File 'lib/principal.rb', line 2

def initialize(connector, col_path, report = false)
  super(connector, col_path, report)
  @doc = "doc(\"#{@col_path}Principals.xml\")"
end

Instance Method Details

#add_membership(name, groups, ob_exists = false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/principal.rb', line 29

def add_membership(name, groups, ob_exists = false)
  ok = true
  #Make sure that group is really group and not individual
  for group in groups
    if(!exists?(group, "#{@doc}//Group[@id=\"#{group}\"]"))
      ok = false;
    end
  end
  if(ok)
    super(name, groups, ob_exists)
  else
    raise RubyACLException.new(self.class.name, __method__, 
      "Failed to add membership. Group \"#{group}\" does not exist.", 113), caller
  end
end

#delete(name) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/principal.rb', line 19

def delete(name)
  super(name)
  
  expr = "#{@doc}//node()[@idref=\"#{name}\"]/parent::node()"
  @connector.update_delete(expr)
  return name
rescue => e
  raise e
end

#eq(temp_ace, final_ace) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/principal.rb', line 7

def eq (temp_ace, final_ace)
  if(temp_ace.prin == final_ace.prin)
    return true
  else 
    return false
  end
end

#ne(temp_ace, final_ace) ⇒ Object



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

def ne (temp_ace, final_ace)
  return !eq(temp_ace, final_ace)
end