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

index ea67201..6f9778c 100644 (file)
@@ -6,6 +6,7 @@ delete_slice
 get_aggregates
 get_credential
 get_gid
+get_gids
 get_registries
 get_resources
 get_self_credential
diff --git a/sfa/methods/get_gids.py b/sfa/methods/get_gids.py
new file mode 100644 (file)
index 0000000..359a947
--- /dev/null
@@ -0,0 +1,45 @@
+# * require certificate as an argument
+# * lookup gid in db
+# * get pubkey from gid
+# * if certifacate matches pubkey from gid, return gid, else raise exception
+#  if not peer.is_pubkey(gid.get_pubkey()):
+#            raise ConnectionKeyGIDMismatch(gid.get_subject())
+
+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
+from sfa.trust.gid import GID
+from sfa.trust.certificate import Certificate
+from sfa.util.genitable import GeniTable
+
+class get_gids(Method):
+    """
+    Get a list of record information (hrn, gid and type) for 
+    the specified hrns.
+
+    @param cred credential string 
+    @param cert certificate string 
+    @return    
+    """
+
+    interfaces = ['registry']
+    
+    accepts = [
+        Parameter(str, "Certificate string"),
+        Mixed(Paramter(str, "Human readable name (hrn)"), 
+              Parameter([str], "List of Human readable names (hrn)")), 
+        Mixed(Parameter(str, "Request hash"),
+              Parameter(None, "Request hash not specified")) 
+        ]
+
+    returns = [Parameter(dict, "Dictionary of gids keyed on hrn")]
+    
+    def call(self, cred, hrns, request_hash=None):
+        self.api.auth.authenticateCred(cred, [cred, hrns], request_hash)
+        self.api.auth.check(cred, 'getgids')
+        table = GeniTable()
+        records = table.find({'hrn': [hrns]}, columns=['hrn','type','gid'])
+        
+        return records