Rewrap errors in get_principal to CCacheError

Causes nicer error message when kerberos credentials are not available.

https://fedorahosted.org/freeipa/ticket/5272

Reviewed-By: David Kupka <dkupka@redhat.com>
Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Michael Simacek
2015-08-31 14:04:33 +02:00
committed by Jan Cholasta
parent cfeea91828
commit bdccebbcdb
4 changed files with 16 additions and 8 deletions

View File

@@ -173,9 +173,15 @@ def get_principal(ccache_name=None):
default
:returns:
Default principal name as string
:raises:
errors.CCacheError if the principal cannot be retrieved from given
ccache
'''
creds = get_credentials(ccache_name=ccache_name)
return unicode(creds.name)
try:
creds = get_credentials(ccache_name=ccache_name)
return unicode(creds.name)
except gssapi.exceptions.GSSError as e:
raise errors.CCacheError(message=unicode(e))
def get_credentials_if_valid(name=None, ccache_name=None):
'''