initial checkin of get_trusted_certs method
authorTony Mack <tmack@cs.princeton.edu>
Mon, 23 Nov 2009 02:16:53 +0000 (02:16 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Mon, 23 Nov 2009 02:16:53 +0000 (02:16 +0000)
sfa/methods/__init__.py
sfa/methods/get_trusted_certs.py [new file with mode: 0644]

index 2835411..1f62101 100644 (file)
@@ -11,6 +11,7 @@ get_resources
 get_self_credential
 get_slices
 get_ticket
+get_trusted_certs
 list
 register
 register_peer_object
diff --git a/sfa/methods/get_trusted_certs.py b/sfa/methods/get_trusted_certs.py
new file mode 100644 (file)
index 0000000..628950b
--- /dev/null
@@ -0,0 +1,37 @@
+### $Id: reset_slices.py 15428 2009-10-23 15:28:03Z tmack $
+### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/reset_slices.py $
+
+from sfa.util.faults import *
+from sfa.util.misc import *
+from sfa.util.method import Method
+from sfa.util.parameter import Parameter, Mixed
+from sfa.trust.auth import Auth
+
+class get_trusted_certs(Method):
+    """
+    @param cred credential string specifying the rights of the caller
+    @param request_hash hash of the request
+    @return 1 is successful, faults otherwise  
+    """
+
+    interfaces = ['registry']
+    
+    accepts = [
+        Parameter(str, "Credential string"),
+        Mixed(Parameter(str, "Request hash"),
+              Parameter(None, "Request hash not specified"))
+        ]
+
+    returns = Parameter(int, "1 if successful")
+    
+    def call(self, cred, request_hash=None):
+        # authenticate the cred
+        client_gid = Credential(string=cred).get_gid_caller()
+        client_gid_str = client_gid.save_to_string(save_parents=True)
+        self.api.auth.authenticateGid(client_gid_str, [cred, hrn], request_hash) 
+        self.api.auth.check(cred, 'gettrustedcerts')
+
+        trusted_cert_strings = [gid.save_to_string(save_parents=True) for \
+                                gid in self.api.auth.trusted_cert_list] 
+        
+        return trusted_cert_strings