diff options
author | Martin Basti <mbasti@redhat.com> | 2017-01-13 14:50:11 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-01-31 18:33:27 +0100 |
commit | 1023cfebff99af165212dee94290a05754297270 (patch) | |
tree | 85168105b947f5bc1cafaa8c73eddd3ac785635f /ipapython/kerberos.py | |
parent | deaf9ae2473833dacb64c4961db3ae9f7c570ebd (diff) | |
download | freeipa-1023cfebff99af165212dee94290a05754297270.tar.gz freeipa-1023cfebff99af165212dee94290a05754297270.tar.xz freeipa-1023cfebff99af165212dee94290a05754297270.zip |
Principal: validate type of input parameter
Bytes are unsupported and we should raise a TypeError from Principal
__init__ method otherwise we get hard to debug result
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Diffstat (limited to 'ipapython/kerberos.py')
-rw-r--r-- | ipapython/kerberos.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ipapython/kerberos.py b/ipapython/kerberos.py index 3d3530c9c..9b02790be 100644 --- a/ipapython/kerberos.py +++ b/ipapython/kerberos.py @@ -66,7 +66,12 @@ class Principal(object): Container for the principal name and realm according to RFC 1510 """ def __init__(self, components, realm=None): - if isinstance(components, six.string_types): + if isinstance(components, six.binary_type): + raise TypeError( + "Cannot create a principal object from bytes: {!r}".format( + components) + ) + elif isinstance(components, six.string_types): # parse principal components from realm self.components, self.realm = self._parse_from_text( components, realm) |