edit error message
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 17 Jan 2013 19:41:05 +0000 (14:41 -0500)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 17 Jan 2013 19:41:05 +0000 (14:41 -0500)
sfa/trust/auth.py
sfa/util/faults.py

index fcd4f75..efec640 100644 (file)
@@ -4,7 +4,8 @@
 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
 from sfa.util.xrn import Xrn, get_authority
@@ -53,6 +54,10 @@ 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)
index e46b986..245d90c 100644 (file)
@@ -38,6 +38,12 @@ class Forbidden(SfaFault):
         faultString = "FORBIDDEN:" 
         SfaFault.__init__(self, GENICODE.FORBIDDEN, faultString, extra)   
 
+class BadArgs(SfaFault):
+    def __init__(self,  extra = None):
+        faultString = "BADARGS:"
+        SfaFault.__init__(self, GENICODE.BADARGS, faultString, extra)
+
+
 class CredentialMismatch(SfaFault):
     def __init__(self,  extra = None):
         faultString = "Credential mismatch"