no more __init__ created for now
[sfa.git] / geni / methods / get_credential.py
index 0bb698d..aa9b25f 100644 (file)
@@ -1,11 +1,13 @@
+### $Id$
+### $URL$
+
+from geni.trust.credential import *
+from geni.trust.rights import *
 from geni.util.faults import *
-from geni.util.excep import *
 from geni.util.method import Method
 from geni.util.parameter import Parameter, Mixed
 from geni.util.auth import Auth
 from geni.util.record import GeniRecord
-from geni.util.credential import *
-from geni.util.rights import *
 from geni.util.debug import log
 
 class get_credential(Method):
@@ -102,6 +104,8 @@ class get_credential(Method):
         for rec in records:
             if type in ['*'] or rec.get_type() in [type]:
                 record = rec
+        if not record:
+            raise RecordNotFound(hrn)
         gid = record.get_gid_object()
         peer_cert = self.api.auth.peer_cert
         if not peer_cert.is_pubkey(gid.get_pubkey()):
@@ -109,7 +113,7 @@ class get_credential(Method):
 
         rights = self.api.auth.determine_user_rights(None, record)
         if rights.is_empty():
-            raise PermissionError(self.api.auth.client_cred.get_gid_object().get_hrn() + " has no rights to " + record.get_name())
+            raise PermissionError(gid.get_hrn() + " has no rights to " + record.get_name())
 
         # create the credential
         gid = record.get_gid_object()