summaryrefslogtreecommitdiff
path: root/src/saml2/pack.py
diff options
context:
space:
mode:
authorScott Koranda <skoranda@gmail.com>2018-04-26 14:47:55 -0500
committerIvan Kanakarakis <ivan.kanak@gmail.com>2018-05-25 16:33:03 +0300
commit9ae25908b66c1937ed3268661a7f3a33cd779047 (patch)
tree86f4acf65008f5e3dbe417e2411a9b07cabc305a /src/saml2/pack.py
parentbffcefb305ade4365089aae387671edf05c8af94 (diff)
downloadpysaml2-9ae25908b66c1937ed3268661a7f3a33cd779047.tar.gz
Reformat using flake8 recommendations
Diffstat (limited to 'src/saml2/pack.py')
-rw-r--r--src/saml2/pack.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/saml2/pack.py b/src/saml2/pack.py
index 501b693c..c60ee5ad 100644
--- a/src/saml2/pack.py
+++ b/src/saml2/pack.py
@@ -1,7 +1,3 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-
"""Contains classes and functions that are necessary to implement
different bindings.
@@ -10,24 +6,21 @@ Bindings normally consists of three parts:
- how to package the information
- which protocol to use
"""
+
+import base64
import html
-from six.moves.urllib.parse import urlparse, urlencode
+import logging
+
import saml2
-import base64
from saml2.s_utils import deflate_and_base64_encode
-from saml2.s_utils import Unsupported
-import logging
-from saml2.sigver import REQ_ORDER
-from saml2.sigver import RESP_ORDER
-from saml2.sigver import SIGNER_ALGS
-import six
+from saml2.sigver import REQ_ORDER, RESP_ORDER
from saml2.xmldsig import SIG_ALLOWED_ALG
-logger = logging.getLogger(__name__)
+import six
+from six.moves.urllib.parse import urlencode, urlparse
try:
from xml.etree import cElementTree as ElementTree
-
if ElementTree.VERSION < '1.3.0':
# cElementTree has no support for register_namespace
# neither _namespace_map, thus we sacrify performance
@@ -40,6 +33,9 @@ except ImportError:
from elementtree import ElementTree
import defusedxml.ElementTree
+
+logger = logging.getLogger(__name__)
+
NAMESPACE = "http://schemas.xmlsoap.org/soap/envelope/"
HTML_INPUT_ELEMENT_SPEC = '<input type="{type}" name="{name}" value="{val}"/>'
@@ -67,6 +63,7 @@ HTML_FORM_SPEC = """<!DOCTYPE html>
</body>
</html>"""
+
def http_form_post_message(message, location, relay_state="",
typ="SAMLRequest", **kwargs):
"""The HTTP POST binding defines a mechanism by which SAML protocol
@@ -108,6 +105,7 @@ def http_form_post_message(message, location, relay_state="",
return {"headers": [("Content-type", "text/html")], "data": response}
+
def http_post_message(message, relay_state="", typ="SAMLRequest", **kwargs):
"""
@@ -273,7 +271,8 @@ def parse_soap_enveloped_saml(text, body_class, header_class=None):
if part.tag == '{%s}Body' % NAMESPACE:
for sub in part:
try:
- body = saml2.create_class_from_element_tree(body_class, sub)
+ body = saml2.create_class_from_element_tree(
+ body_class, sub)
except Exception:
raise Exception(
"Wrong body type (%s) in SOAP envelope" % sub.tag)