},
)
+class AuthError(Exception):
+ """
+ Raised when the client could not authenticate against the hub
+ """
+ pass
+
+
class Hub(object):
def __init__(self, url, keytab=None):
self.url = url
# Validate the server response
result = kerberos.authGSSClientStep(krb5_context, krb5_server_response)
if not result == kerberos.AUTH_GSS_COMPLETE:
- raise RuntimeError("Could not verify the Kerberos server response")
+ raise AuthError("Could not verify the Kerberos server response")
log.debug("Kerberos Server Response validating succeeded")
# If there were no headers
else:
- raise RuntimeError("Mutual authentication failed")
+ raise AuthError("Mutual authentication failed")
# Decode JSON response
if res.body:
result, krb5_context = kerberos.authGSSClientInit("HTTP@%s" % url.hostname)
if not result == kerberos.AUTH_GSS_COMPLETE:
- raise RuntimeError("Could not create Kerberos Client context")
+ raise AuthError("Could not create Kerberos Client context")
# Next step...
try:
except kerberos.GSSError as e:
log.error("Kerberos authentication failed: %s" % e)
- raise e
+
+ raise AuthError("%s" % e) from e
if not result == kerberos.AUTH_GSS_CONTINUE:
- raise RuntimeError("Cloud not continue Kerberos authentication")
+ raise AuthError("Cloud not continue Kerberos authentication")
return krb5_context