From beb859496d3cfe9205673c37261822c02df868cc Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Thu, 17 Jan 2013 14:41:05 -0500 Subject: [PATCH] edit error message --- sfa/trust/auth.py | 7 ++++++- sfa/util/faults.py | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sfa/trust/auth.py b/sfa/trust/auth.py index fcd4f753..efec640b 100644 --- a/sfa/trust/auth.py +++ b/sfa/trust/auth.py @@ -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) diff --git a/sfa/util/faults.py b/sfa/util/faults.py index e46b986c..245d90c2 100644 --- a/sfa/util/faults.py +++ b/sfa/util/faults.py @@ -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" -- 2.43.0