again getting away with caller_cred and passing just the hrn of the initial caller
authorAnil-Kumar Vengalil <Anil-Kumar.Vengalil@sophia.inria.fr>
Tue, 15 Dec 2009 12:30:58 +0000 (12:30 +0000)
committerAnil-Kumar Vengalil <Anil-Kumar.Vengalil@sophia.inria.fr>
Tue, 15 Dec 2009 12:30:58 +0000 (12:30 +0000)
sfa/methods/list.py
sfa/methods/register.py
sfa/methods/remove.py
sfa/methods/remove_peer_object.py
sfa/methods/resolve.py
sfa/methods/update.py

index 90a7b8b..a139704 100644 (file)
@@ -58,7 +58,7 @@ class list(Method):
             credential = self.api.getCredential()
             try:
                request_hash=None
-                record_list = registries[registry_hrn].list(credential, hrn, request_hash, caller_cred)
+                record_list = registries[registry_hrn].list(credential, hrn, request_hash, origin_hrn)
                 records = [GeniRecord(dict=record).as_dict() for record in record_list]
             except:
                 arg_list = [credential, hrn]
index 68b3841..ac05303 100644 (file)
@@ -38,7 +38,7 @@ class register(Method):
 
     returns = Parameter(int, "String representation of gid object")
     
-    def call(self, cred, record_dict, request_hash=None, caller_cred=None):
+    def call(self, cred, record_dict, request_hash=None, origin_hrn=None):
         # This cred will be an authority cred, not a user, so we cant use it to 
         # authenticate the caller's request_hash. Let just get the caller's gid
         # from the cred and authenticate using that 
@@ -46,11 +46,11 @@ class register(Method):
         client_gid_str = client_gid.save_to_string(save_parents=True)
         self.api.auth.authenticateGid(client_gid_str, [cred], request_hash)
         self.api.auth.check(cred, "register")
-        if caller_cred==None:
-               caller_cred=cred
+        if origin_hrn==None:
+               origin_hrn=Credential(string=cred).get_gid_caller().get_hrn()
        
         #log the call
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), None, self.name))
+        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, None, self.name))
         record = GeniRecord(dict = record_dict)
         record['authority'] = get_authority(record['hrn'])
         type = record['type']
index fb8f820..3d7d5d3 100644 (file)
@@ -35,12 +35,12 @@ class remove(Method):
 
     returns = Parameter(int, "1 if successful")
     
-    def call(self, cred, type, hrn, request_hash=None, caller_cred=None):
+    def call(self, cred, type, hrn, request_hash=None, origin_hrn=None):
 
-        if caller_cred==None:
-            caller_cred=cred
+        if origin_hrn==None:
+            origin_hrn=Credential(string=cred).get_gid_caller().get_hrn()
         #log the call
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), hrn, self.name))
+        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
         # This cred will be an authority cred, not a user, so we cant use it to 
         # authenticate the caller's request_hash. Let just get the caller's gid
         # from the cred and authenticate using that
@@ -68,7 +68,8 @@ class remove(Method):
             for registry in registries:
                 if registry not in [self.api.hrn]:
                     try:
-                        result=registries[registry].remove_peer_object(credential, record)
+                       request_hash=None
+                        result=registries[registry].remove_peer_object(credential, record, request_hash, origin_hrn)
                     except:
                         pass
         if type == "user":
index 51fb658..81a9e53 100644 (file)
@@ -33,11 +33,11 @@ class remove_peer_object(Method):
 
     returns = Parameter(int, "1 if successful")
     
-    def call(self, cred, record, request_hash=None, caller_cred=None):
-        if caller_cred==None:
-            caller_cred=cred
+    def call(self, cred, record, request_hash=None, origin_hrn=None):
+        if origin_hrn==None:
+            origin_hrn=Credential(string=cred).get_gid_caller().get_hrn()
         #log the call
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), record['hrn'], self.name))
+        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, record['hrn'], self.name))
         self.api.auth.authenticateCred(cred, [cred], request_hash) 
         self.api.auth.check(cred, "remove")
 
index cdf148f..4a5f560 100644 (file)
@@ -66,7 +66,7 @@ class resolve(Method):
             except:
                 arg_list = [credential, hrn]
                 request_hash=self.api.key.compute_hash(arg_list)                
-                records = registries[registry_hrn].resolve(credential, hrn, request_hash, caller_cred)
+                records = registries[registry_hrn].resolve(credential, hrn, request_hash, origin_hrn)
                 good_records = [GeniRecord(dict=record).as_dict() for record in records]
                 
         if good_records:
index 4076e97..01ef639 100644 (file)
@@ -36,12 +36,12 @@ class update(Method):
 
     returns = Parameter(int, "1 if successful")
     
-    def call(self, cred, record_dict, request_hash=None, caller_cred=None):
-        if caller_cred==None:
-               caller_cred=cred
+    def call(self, cred, record_dict, request_hash=None, origin_hrn=None):
+        if origin_hrn==None:
+               origin_hrn=Credential(string=cred).get_gid_caller().get_hrn()
 
            #log the call
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), None, self.name))
+        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, None, self.name))
         # This cred might be an authority cred, not a user, so we cant use it to 
         # authenticate the caller's request_hash. Let just get the caller's gid
         # from the cred and authenticate using that