summaryrefslogtreecommitdiff
path: root/src/saml2/pack.py
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2014-10-02 16:04:41 +0200
committerRoland Hedberg <roland.hedberg@adm.umu.se>2014-10-02 16:04:41 +0200
commit13fdda52ab3367d4ebb2e9c5888bea74ac0f081b (patch)
treeb00bbd5868ce65bc637feef35ecaee7b14c178e0 /src/saml2/pack.py
parent095f8dbe1d4de3519a7e244233aa2b38ed420d9f (diff)
downloadpysaml2-13fdda52ab3367d4ebb2e9c5888bea74ac0f081b.tar.gz
PEP-8
Diffstat (limited to 'src/saml2/pack.py')
-rw-r--r--src/saml2/pack.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/saml2/pack.py b/src/saml2/pack.py
index a7b86857..9a10cbe9 100644
--- a/src/saml2/pack.py
+++ b/src/saml2/pack.py
@@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
#
-"""Contains classes and functions that are necessary to implement
+"""Contains classes and functions that are necessary to implement
different bindings.
Bindings normally consists of three parts:
-- rules about what to send
+- rules about what to send
- how to package the information
- which protocol to use
"""
@@ -46,10 +46,10 @@ FORM_SPEC = """<form method="post" action="%s">
def http_form_post_message(message, location, relay_state="",
typ="SAMLRequest"):
- """The HTTP POST binding defines a mechanism by which SAML protocol
+ """The HTTP POST binding defines a mechanism by which SAML protocol
messages may be transmitted within the base64-encoded content of a
HTML form control.
-
+
:param message: The message
:param location: Where the form should be posted to
:param relay_state: for preserving and conveying state information
@@ -66,25 +66,25 @@ def http_form_post_message(message, location, relay_state="",
_msg = message
response.append(FORM_SPEC % (location, typ, _msg, relay_state))
-
+
response.append("""<script type="text/javascript">""")
response.append(" window.onload = function ()")
response.append(" { document.forms[0].submit(); }")
response.append("""</script>""")
response.append("</body>")
-
+
return {"headers": [("Content-type", "text/html")], "data": response}
def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
sigalg=None, key=None):
- """The HTTP Redirect binding defines a mechanism by which SAML protocol
+ """The HTTP Redirect binding defines a mechanism by which SAML protocol
messages can be transmitted within URL parameters.
- Messages are encoded for use with this binding using a URL encoding
- technique, and transmitted using the HTTP GET method.
-
+ Messages are encoded for use with this binding using a URL encoding
+ technique, and transmitted using the HTTP GET method.
+
The DEFLATE Encoding is used in this function.
-
+
:param message: The message
:param location: Where the message should be posted to
:param relay_state: for preserving and conveying state information
@@ -93,7 +93,7 @@ def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
:param key: Key to use for signing
:return: A tuple containing header information and a HTML message.
"""
-
+
if not isinstance(message, basestring):
message = "%s" % (message,)
@@ -134,7 +134,7 @@ def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
login_url = glue_char.join([location, string])
headers = [('Location', str(login_url))]
body = []
-
+
return {"headers": headers, "data": body}
@@ -193,17 +193,17 @@ def make_soap_enveloped_saml_thingy(thingy, header_parts=None):
def http_soap_message(message):
return {"headers": [("Content-type", "application/soap+xml")],
"data": make_soap_enveloped_saml_thingy(message)}
-
+
def http_paos(message, extra=None):
return {"headers": [("Content-type", "application/soap+xml")],
"data": make_soap_enveloped_saml_thingy(message, extra)}
-
+
def parse_soap_enveloped_saml(text, body_class, header_class=None):
"""Parses a SOAP enveloped SAML thing and returns header parts and body
- :param text: The SOAP object as XML
+ :param text: The SOAP object as XML
:return: header parts and body as saml.samlbase instances
"""
envelope = ElementTree.fromstring(text)
@@ -233,7 +233,7 @@ def parse_soap_enveloped_saml(text, body_class, header_class=None):
header[sub.tag] = \
saml2.create_class_from_element_tree(klass, sub)
break
-
+
return body, header
# -----------------------------------------------------------------------------
@@ -242,7 +242,7 @@ PACKING = {
saml2.BINDING_HTTP_REDIRECT: http_redirect_message,
saml2.BINDING_HTTP_POST: http_form_post_message,
}
-
+
def packager(identifier):
try: