Fix more basestring py3k issues
basestring has been removed from python 3.
This commit is contained in:
@@ -6,6 +6,7 @@ import pprint
|
|||||||
import types
|
import types
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
import six
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import imp
|
import imp
|
||||||
@@ -356,7 +357,7 @@ class SAML2client(object):
|
|||||||
item = {"id": key, "name": val["name"]}
|
item = {"id": key, "name": val["name"]}
|
||||||
try:
|
try:
|
||||||
_desc = val["descr"]
|
_desc = val["descr"]
|
||||||
if isinstance(_desc, basestring):
|
if isinstance(_desc, six.string_types):
|
||||||
item["descr"] = _desc
|
item["descr"] = _desc
|
||||||
else:
|
else:
|
||||||
item["descr"] = "\n".join(_desc)
|
item["descr"] = "\n".join(_desc)
|
||||||
@@ -377,7 +378,7 @@ class SAML2client(object):
|
|||||||
item = {"id": key, "name": val["name"]}
|
item = {"id": key, "name": val["name"]}
|
||||||
try:
|
try:
|
||||||
_desc = val["descr"]
|
_desc = val["descr"]
|
||||||
if isinstance(_desc, basestring):
|
if isinstance(_desc, six.string_types):
|
||||||
item["descr"] = _desc
|
item["descr"] = _desc
|
||||||
else:
|
else:
|
||||||
item["descr"] = "\n".join(_desc)
|
item["descr"] = "\n".join(_desc)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ __author__ = 'rohe0002'
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import six
|
||||||
|
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@@ -34,7 +35,8 @@ def pick_interaction(interactions, _base="", content="", req=None):
|
|||||||
_match += 1
|
_match += 1
|
||||||
else:
|
else:
|
||||||
_c = _bs.title.contents
|
_c = _bs.title.contents
|
||||||
if isinstance(_c, list) and not isinstance(_c, basestring):
|
if isinstance(_c, list) and not isinstance(
|
||||||
|
_c, six.string_types):
|
||||||
for _line in _c:
|
for _line in _c:
|
||||||
if val in _line:
|
if val in _line:
|
||||||
_match += 1
|
_match += 1
|
||||||
@@ -165,7 +167,7 @@ def pick_form(response, url=None, **kwargs):
|
|||||||
_default = _ava["value"]
|
_default = _ava["value"]
|
||||||
try:
|
try:
|
||||||
orig_val = form[prop]
|
orig_val = form[prop]
|
||||||
if isinstance(orig_val, basestring):
|
if isinstance(orig_val, six.string_types):
|
||||||
if orig_val == _default:
|
if orig_val == _default:
|
||||||
_form = form
|
_form = form
|
||||||
elif _default in orig_val:
|
elif _default in orig_val:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import logging
|
|||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
import requests
|
import requests
|
||||||
|
import six
|
||||||
from saml2.metadata import ENDPOINTS
|
from saml2.metadata import ENDPOINTS
|
||||||
from saml2.profile import paos, ecp
|
from saml2.profile import paos, ecp
|
||||||
from saml2.soap import parse_soap_enveloped_saml_artifact_resolve
|
from saml2.soap import parse_soap_enveloped_saml_artifact_resolve
|
||||||
@@ -156,7 +157,7 @@ class Entity(HTTPBase):
|
|||||||
self.sec = security_context(self.config)
|
self.sec = security_context(self.config)
|
||||||
|
|
||||||
if virtual_organization:
|
if virtual_organization:
|
||||||
if isinstance(virtual_organization, basestring):
|
if isinstance(virtual_organization, six.string_types):
|
||||||
self.vorg = self.config.vorg[virtual_organization]
|
self.vorg = self.config.vorg[virtual_organization]
|
||||||
elif isinstance(virtual_organization, VirtualOrg):
|
elif isinstance(virtual_organization, VirtualOrg):
|
||||||
self.vorg = virtual_organization
|
self.vorg = virtual_organization
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import calendar
|
import calendar
|
||||||
|
import six
|
||||||
from six.moves import http_cookiejar
|
from six.moves import http_cookiejar
|
||||||
import copy
|
import copy
|
||||||
import re
|
import re
|
||||||
@@ -260,7 +261,7 @@ class HTTPBase(object):
|
|||||||
:param typ: Whether a Request, Response or Artifact
|
:param typ: Whether a Request, Response or Artifact
|
||||||
:return: dictionary
|
:return: dictionary
|
||||||
"""
|
"""
|
||||||
if not isinstance(message, basestring):
|
if not isinstance(message, six.string_types):
|
||||||
message = "%s" % (message,)
|
message = "%s" % (message,)
|
||||||
|
|
||||||
return http_form_post_message(message, destination, relay_state, typ)
|
return http_form_post_message(message, destination, relay_state, typ)
|
||||||
@@ -375,7 +376,7 @@ class HTTPBase(object):
|
|||||||
:param key: Key to use for signing
|
:param key: Key to use for signing
|
||||||
:return: dictionary
|
:return: dictionary
|
||||||
"""
|
"""
|
||||||
if not isinstance(message, basestring):
|
if not isinstance(message, six.string_types):
|
||||||
message = "%s" % (message,)
|
message = "%s" % (message,)
|
||||||
|
|
||||||
return http_redirect_message(message, destination, relay_state, typ,
|
return http_redirect_message(message, destination, relay_state, typ,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import copy
|
import copy
|
||||||
import shelve
|
import shelve
|
||||||
import logging
|
import logging
|
||||||
|
import six
|
||||||
|
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from urllib import quote
|
from urllib import quote
|
||||||
@@ -66,7 +67,7 @@ class IdentDB(object):
|
|||||||
Keeps a list of all nameIDs returned per SP
|
Keeps a list of all nameIDs returned per SP
|
||||||
"""
|
"""
|
||||||
def __init__(self, db, domain="", name_qualifier=""):
|
def __init__(self, db, domain="", name_qualifier=""):
|
||||||
if isinstance(db, basestring):
|
if isinstance(db, six.string_types):
|
||||||
self.db = shelve.open(db)
|
self.db = shelve.open(db)
|
||||||
else:
|
else:
|
||||||
self.db = db
|
self.db = db
|
||||||
@@ -94,7 +95,7 @@ class IdentDB(object):
|
|||||||
:param ident: user identifier
|
:param ident: user identifier
|
||||||
:param name_id: NameID instance
|
:param name_id: NameID instance
|
||||||
"""
|
"""
|
||||||
if isinstance(ident, unicode):
|
if isinstance(ident, six.string_types):
|
||||||
ident = ident.encode("utf-8")
|
ident = ident.encode("utf-8")
|
||||||
|
|
||||||
# One user may have more than one NameID defined
|
# One user may have more than one NameID defined
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import logging
|
|||||||
from saml2.sigver import REQ_ORDER
|
from saml2.sigver import REQ_ORDER
|
||||||
from saml2.sigver import RESP_ORDER
|
from saml2.sigver import RESP_ORDER
|
||||||
from saml2.sigver import SIGNER_ALGS
|
from saml2.sigver import SIGNER_ALGS
|
||||||
|
import six
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ def http_form_post_message(message, location, relay_state="",
|
|||||||
"""
|
"""
|
||||||
response = ["<head>", """<title>SAML 2.0 POST</title>""", "</head><body>"]
|
response = ["<head>", """<title>SAML 2.0 POST</title>""", "</head><body>"]
|
||||||
|
|
||||||
if not isinstance(message, basestring):
|
if not isinstance(message, six.string_types):
|
||||||
message = "%s" % (message,)
|
message = "%s" % (message,)
|
||||||
|
|
||||||
if typ == "SAMLRequest" or typ == "SAMLResponse":
|
if typ == "SAMLRequest" or typ == "SAMLResponse":
|
||||||
@@ -94,7 +95,7 @@ def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
|
|||||||
:return: A tuple containing header information and a HTML message.
|
:return: A tuple containing header information and a HTML message.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not isinstance(message, basestring):
|
if not isinstance(message, six.string_types):
|
||||||
message = "%s" % (message,)
|
message = "%s" % (message,)
|
||||||
|
|
||||||
_order = None
|
_order = None
|
||||||
@@ -163,7 +164,7 @@ def make_soap_enveloped_saml_thingy(thingy, header_parts=None):
|
|||||||
body.tag = '{%s}Body' % NAMESPACE
|
body.tag = '{%s}Body' % NAMESPACE
|
||||||
envelope.append(body)
|
envelope.append(body)
|
||||||
|
|
||||||
if isinstance(thingy, basestring):
|
if isinstance(thingy, six.string_types):
|
||||||
# remove the first XML version/encoding line
|
# remove the first XML version/encoding line
|
||||||
logger.debug("thingy0: %s" % thingy)
|
logger.debug("thingy0: %s" % thingy)
|
||||||
_part = thingy.split("\n")
|
_part = thingy.split("\n")
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import platform
|
|||||||
import shelve
|
import shelve
|
||||||
import traceback
|
import traceback
|
||||||
import saml2
|
import saml2
|
||||||
|
import six
|
||||||
from urlparse import parse_qs, urlparse
|
from urlparse import parse_qs, urlparse
|
||||||
from saml2.md import Extensions
|
from saml2.md import Extensions
|
||||||
from saml2 import xmldsig as ds
|
from saml2 import xmldsig as ds
|
||||||
@@ -555,7 +556,7 @@ class SAML2Plugin(object):
|
|||||||
def add_metadata(self, environ, identity):
|
def add_metadata(self, environ, identity):
|
||||||
""" Add information to the knowledge I have about the user """
|
""" Add information to the knowledge I have about the user """
|
||||||
name_id = identity['repoze.who.userid']
|
name_id = identity['repoze.who.userid']
|
||||||
if isinstance(name_id, basestring):
|
if isinstance(name_id, six.string_types):
|
||||||
try:
|
try:
|
||||||
# Make sure that userids authenticated by another plugin
|
# Make sure that userids authenticated by another plugin
|
||||||
# don't cause problems here.
|
# don't cause problems here.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import urllib
|
|||||||
|
|
||||||
from time import mktime
|
from time import mktime
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
import six
|
||||||
|
|
||||||
from Crypto.PublicKey.RSA import importKey
|
from Crypto.PublicKey.RSA import importKey
|
||||||
from Crypto.Signature import PKCS1_v1_5
|
from Crypto.Signature import PKCS1_v1_5
|
||||||
@@ -728,7 +729,7 @@ class CryptoBackendXmlSec1(CryptoBackend):
|
|||||||
|
|
||||||
def __init__(self, xmlsec_binary, **kwargs):
|
def __init__(self, xmlsec_binary, **kwargs):
|
||||||
CryptoBackend.__init__(self, **kwargs)
|
CryptoBackend.__init__(self, **kwargs)
|
||||||
assert (isinstance(xmlsec_binary, basestring))
|
assert (isinstance(xmlsec_binary, six.string_types))
|
||||||
self.xmlsec = xmlsec_binary
|
self.xmlsec = xmlsec_binary
|
||||||
if os.environ.get('PYSAML2_KEEP_XMLSEC_TMP', None):
|
if os.environ.get('PYSAML2_KEEP_XMLSEC_TMP', None):
|
||||||
self._xmlsec_delete_tmpfiles = False
|
self._xmlsec_delete_tmpfiles = False
|
||||||
@@ -1353,7 +1354,7 @@ class SecurityContext(object):
|
|||||||
_certs = []
|
_certs = []
|
||||||
certs = []
|
certs = []
|
||||||
for cert in _certs:
|
for cert in _certs:
|
||||||
if isinstance(cert, basestring):
|
if isinstance(cert, six.string_types):
|
||||||
certs.append(make_temp(pem_format(cert), suffix=".pem",
|
certs.append(make_temp(pem_format(cert), suffix=".pem",
|
||||||
decode=False,
|
decode=False,
|
||||||
delete=self._xmlsec_delete_tmpfiles))
|
delete=self._xmlsec_delete_tmpfiles))
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
|
import six
|
||||||
|
|
||||||
__author__ = 'rolandh'
|
__author__ = 'rolandh'
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ class ResponseInfo(Information):
|
|||||||
self._status = self.status
|
self._status = self.status
|
||||||
_msg = conv.last_content
|
_msg = conv.last_content
|
||||||
|
|
||||||
if isinstance(_msg, basestring):
|
if isinstance(_msg, six.string_types):
|
||||||
self._message = _msg
|
self._message = _msg
|
||||||
else:
|
else:
|
||||||
self._message = _msg.to_dict()
|
self._message = _msg.to_dict()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ __author__ = 'rohe0002'
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import six
|
||||||
|
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@@ -125,8 +126,8 @@ class Interaction(object):
|
|||||||
_match += 1
|
_match += 1
|
||||||
else:
|
else:
|
||||||
_c = _bs.title.contents
|
_c = _bs.title.contents
|
||||||
if isinstance(_c, list) and not isinstance(_c,
|
if isinstance(_c, list) and not isinstance(
|
||||||
basestring):
|
_c, six.string_types):
|
||||||
for _line in _c:
|
for _line in _c:
|
||||||
if val in _line:
|
if val in _line:
|
||||||
_match += 1
|
_match += 1
|
||||||
@@ -186,7 +187,7 @@ class Interaction(object):
|
|||||||
_default = _ava["value"]
|
_default = _ava["value"]
|
||||||
try:
|
try:
|
||||||
orig_val = form[prop]
|
orig_val = form[prop]
|
||||||
if isinstance(orig_val, basestring):
|
if isinstance(orig_val, six.string_types):
|
||||||
if orig_val == _default:
|
if orig_val == _default:
|
||||||
_form = form
|
_form = form
|
||||||
elif _default in orig_val:
|
elif _default in orig_val:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
import six
|
||||||
|
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ def pick_form(response, content, url=None, **kwargs):
|
|||||||
_default = _ava["value"]
|
_default = _ava["value"]
|
||||||
try:
|
try:
|
||||||
orig_val = form[prop]
|
orig_val = form[prop]
|
||||||
if isinstance(orig_val, basestring):
|
if isinstance(orig_val, six.string_types):
|
||||||
if orig_val == _default:
|
if orig_val == _default:
|
||||||
_form = form
|
_form = form
|
||||||
elif _default in orig_val:
|
elif _default in orig_val:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import sys
|
|||||||
import traceback
|
import traceback
|
||||||
import logging
|
import logging
|
||||||
from urlparse import parse_qs
|
from urlparse import parse_qs
|
||||||
|
import six
|
||||||
|
|
||||||
from saml2test.opfunc import Operation
|
from saml2test.opfunc import Operation
|
||||||
from saml2test import CheckError, FatalError
|
from saml2test import CheckError, FatalError
|
||||||
@@ -64,7 +65,7 @@ class Conversation(object):
|
|||||||
raise CheckError
|
raise CheckError
|
||||||
|
|
||||||
def do_check(self, test, **kwargs):
|
def do_check(self, test, **kwargs):
|
||||||
if isinstance(test, basestring):
|
if isinstance(test, six.string_types):
|
||||||
chk = self.check_factory(test)(**kwargs)
|
chk = self.check_factory(test)(**kwargs)
|
||||||
else:
|
else:
|
||||||
chk = test(**kwargs)
|
chk = test(**kwargs)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import os
|
|||||||
import traceback
|
import traceback
|
||||||
import urllib
|
import urllib
|
||||||
import sys
|
import sys
|
||||||
|
import six
|
||||||
|
|
||||||
from urlparse import parse_qs
|
from urlparse import parse_qs
|
||||||
from saml2 import BINDING_HTTP_REDIRECT, class_name
|
from saml2 import BINDING_HTTP_REDIRECT, class_name
|
||||||
@@ -93,7 +94,7 @@ class Conversation():
|
|||||||
raise CheckError
|
raise CheckError
|
||||||
|
|
||||||
def do_check(self, test, **kwargs):
|
def do_check(self, test, **kwargs):
|
||||||
if isinstance(test, basestring):
|
if isinstance(test, six.string_types):
|
||||||
chk = self.check_factory(test)(**kwargs)
|
chk = self.check_factory(test)(**kwargs)
|
||||||
else:
|
else:
|
||||||
chk = test(**kwargs)
|
chk = test(**kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user