r1.8 adding documentation
[sfa.git] / sfa / trust / auth.py
index efec640..d217b1c 100644 (file)
@@ -4,7 +4,7 @@
 import sys
 
 from sfa.util.faults import InsufficientRights, MissingCallerGID, MissingTrustedRoots, PermissionError, \
-    BadRequestHash, ConnectionKeyGIDMismatch, SfaPermissionDenied, CredentialNotVerifiable, Forbidden,
+    BadRequestHash, ConnectionKeyGIDMismatch, SfaPermissionDenied, CredentialNotVerifiable, Forbidden, \
     BadArgs
 from sfa.util.sfalogging import logger
 from sfa.util.config import Config
@@ -36,6 +36,13 @@ class Auth:
         self.trusted_cert_file_list = TrustedRoots(self.config.get_trustedroots_dir()).get_file_list()
 
     def checkCredentials(self, creds, operation, xrns=[], check_sliver_callback=None):
+        # if xrns are specified they cannot be None or empty string
+        if xrns:
+            for xrn in xrns:
+                if not xrn:
+                    raise BadArgs("Invalid urn or hrn")
+
+        
         if not isinstance(xrns, list):
             xrns = [xrns]
 
@@ -54,10 +61,6 @@ class Auth:
         if not hrns: hrns = [None]
         for cred in creds:
             for hrn in hrns:
-                # if an hrn is specified it cannot be None or empty string
-                if not hrn:
-                    raise BadArgs("Invalid urn or hrn: %s" % hrn)
-                    
                 try:
                     self.check(cred, operation, hrn)
                     valid.append(cred)