mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-22 15:13:50 -06:00
ipalib/x509.py: get rid of unicode helper
Pylint started to complain that 'unicode' variable is accessed before definition. This is clearly a bug in how 'six' and pylint are working together. Replace use of 'unicode()' by 'str()'. Fixes: https://pagure.io/freeipa/issue/9644 Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
531bd05de9
commit
7f9c890c04
@ -60,9 +60,6 @@ except ImportError:
|
|||||||
from ipalib import errors
|
from ipalib import errors
|
||||||
from ipapython.dnsutil import DNSName
|
from ipapython.dnsutil import DNSName
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
PEM = 0
|
PEM = 0
|
||||||
DER = 1
|
DER = 1
|
||||||
|
|
||||||
@ -371,13 +368,14 @@ class IPACertificate(crypto_x509.Certificate):
|
|||||||
gns = self.__pyasn1_get_san_general_names()
|
gns = self.__pyasn1_get_san_general_names()
|
||||||
|
|
||||||
GENERAL_NAME_CONSTRUCTORS = {
|
GENERAL_NAME_CONSTRUCTORS = {
|
||||||
'rfc822Name': lambda x: crypto_x509.RFC822Name(unicode(x)),
|
'rfc822Name': lambda x: crypto_x509.RFC822Name(str(x)),
|
||||||
'dNSName': lambda x: crypto_x509.DNSName(unicode(x)),
|
'dNSName': lambda x: crypto_x509.DNSName(str(x)),
|
||||||
'directoryName': _pyasn1_to_cryptography_directoryname,
|
'directoryName': _pyasn1_to_cryptography_directoryname,
|
||||||
'registeredID': _pyasn1_to_cryptography_registeredid,
|
'registeredID': _pyasn1_to_cryptography_registeredid,
|
||||||
'iPAddress': _pyasn1_to_cryptography_ipaddress,
|
'iPAddress': _pyasn1_to_cryptography_ipaddress,
|
||||||
'uniformResourceIdentifier':
|
'uniformResourceIdentifier':
|
||||||
lambda x: crypto_x509.UniformResourceIdentifier(unicode(x)),
|
lambda x: crypto_x509.UniformResourceIdentifier(
|
||||||
|
str(x)),
|
||||||
'otherName': _pyasn1_to_cryptography_othername,
|
'otherName': _pyasn1_to_cryptography_othername,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +413,7 @@ class IPACertificate(crypto_x509.Certificate):
|
|||||||
|
|
||||||
for gn in gns:
|
for gn in gns:
|
||||||
if gn.getName() == 'dNSName':
|
if gn.getName() == 'dNSName':
|
||||||
result.append(unicode(gn.getComponent()))
|
result.append(str(gn.getComponent()))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -688,10 +686,10 @@ class _KRB5PrincipalName(univ.Sequence):
|
|||||||
|
|
||||||
def _decode_krb5principalname(data):
|
def _decode_krb5principalname(data):
|
||||||
principal = decoder.decode(data, asn1Spec=_KRB5PrincipalName())[0]
|
principal = decoder.decode(data, asn1Spec=_KRB5PrincipalName())[0]
|
||||||
realm = (unicode(principal['realm']).replace('\\', '\\\\')
|
realm = (str(principal['realm']).replace('\\', '\\\\')
|
||||||
.replace('@', '\\@'))
|
.replace('@', '\\@'))
|
||||||
name = principal['principalName']['name-string']
|
name = principal['principalName']['name-string']
|
||||||
name = u'/'.join(unicode(n).replace('\\', '\\\\')
|
name = u'/'.join(str(n).replace('\\', '\\\\')
|
||||||
.replace('/', '\\/')
|
.replace('/', '\\/')
|
||||||
.replace('@', '\\@') for n in name)
|
.replace('@', '\\@') for n in name)
|
||||||
name = u'%s@%s' % (name, realm)
|
name = u'%s@%s' % (name, realm)
|
||||||
@ -707,7 +705,7 @@ class KRB5PrincipalName(crypto_x509.general_name.OtherName):
|
|||||||
class UPN(crypto_x509.general_name.OtherName):
|
class UPN(crypto_x509.general_name.OtherName):
|
||||||
def __init__(self, type_id, value):
|
def __init__(self, type_id, value):
|
||||||
super(UPN, self).__init__(type_id, value)
|
super(UPN, self).__init__(type_id, value)
|
||||||
self.name = unicode(
|
self.name = str(
|
||||||
decoder.decode(value, asn1Spec=char.UTF8String())[0])
|
decoder.decode(value, asn1Spec=char.UTF8String())[0])
|
||||||
|
|
||||||
|
|
||||||
@ -741,7 +739,7 @@ def _pyasn1_to_cryptography_directoryname(dn):
|
|||||||
for ava in rdn:
|
for ava in rdn:
|
||||||
attr = crypto_x509.NameAttribute(
|
attr = crypto_x509.NameAttribute(
|
||||||
_pyasn1_to_cryptography_oid(ava['type']),
|
_pyasn1_to_cryptography_oid(ava['type']),
|
||||||
unicode(decoder.decode(ava['value'])[0])
|
str(decoder.decode(ava['value'])[0])
|
||||||
)
|
)
|
||||||
attrs.append(attr)
|
attrs.append(attr)
|
||||||
|
|
||||||
@ -806,7 +804,7 @@ class UTC(datetime.tzinfo):
|
|||||||
def format_datetime(t):
|
def format_datetime(t):
|
||||||
if t.tzinfo is None:
|
if t.tzinfo is None:
|
||||||
t = t.replace(tzinfo=UTC())
|
t = t.replace(tzinfo=UTC())
|
||||||
return unicode(t.strftime("%a %b %d %H:%M:%S %Y %Z"))
|
return str(t.strftime("%a %b %d %H:%M:%S %Y %Z"))
|
||||||
|
|
||||||
|
|
||||||
class ExternalCAType(enum.Enum):
|
class ExternalCAType(enum.Enum):
|
||||||
|
Loading…
Reference in New Issue
Block a user