Merged trunk in from 17245:17645
[sfa.git] / sfa / trust / rights.py
index 1c08a1e..e3d110f 100644 (file)
@@ -11,6 +11,7 @@
 ##
 
 
+
 ##
 # privilege_table is a list of priviliges and what operations are allowed
 # per privilege.
@@ -29,6 +30,7 @@ privilege_table = {"authority": ["register", "remove", "update", "resolve", "lis
                    "operator": ["gettrustedcerts", "getgids"]}
 
 
+
 ##
 # Determine tje rights that an object should have. The rights are entirely
 # dependent on the type of the object. For example, users automatically
@@ -51,11 +53,15 @@ def determine_rights(type, name):
         rl.add("resolve")
         rl.add("info")
     elif type == "sa":
-        rl.add("authority,sa")
+        rl.add("authority")
+        rl.add("sa")
     elif type == "ma":
-        rl.add("authority,ma")
+        rl.add("authority")
+        rl.add("ma")
     elif type == "authority":
-        rl.add("authority,sa,ma")
+        rl.add("authority")
+        rl.add("sa")
+        rl.add("ma")
     elif type == "slice":
         rl.add("refresh")
         rl.add("embed")
@@ -146,7 +152,7 @@ class RightList:
 
     def add(self, right, delegate=False):
         if isinstance(right, str):
-            right = Right(kind = right, delegate=delegate)
+            right = Right(right, delegate)
         self.rights.append(right)
 
     ##
@@ -163,10 +169,10 @@ class RightList:
         for part in parts:
             if ':' in part:
                 spl = part.split(':')
-                kind = spl[0]
-                delegate = int(spl[1])
+                kind = spl[0].strip()
+                delegate = bool(int(spl[1]))
             else:
-                kind = part
+                kind = part.strip()
                 delegate = 0
             self.rights.append(Right(kind, bool(delegate)))
 
@@ -177,7 +183,7 @@ class RightList:
     def save_to_string(self):        
         right_names = []
         for right in self.rights:
-            right_names.append('%s:%d' % (right.kind, right.delegate))
+            right_names.append('%s:%d' % (right.kind.strip(), right.delegate))
 
         return ",".join(right_names)