saml-dev message
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
| [List Home]
Subject: Decoding SAMLRequest.
- From: bhaskar jain <bhaskar.jain2002@gmail.com>
- To: saml-dev@lists.oasis-open.org
- Date: Sat, 31 Oct 2009 23:31:57 +0530
Hello list,
From the spec, for HTTP-Resirect binding, the SAMLRequest is DEFLATE-compressed, then Base 64 encoded, then URL encoded.
I do this in Python for decoding the SAMLRequest to get the AuthnRequest. Was wondering if this will always work? Is there any better alternative in C / Python.
def decode_authn_request(authn_request):
""" AuthnRequest is always deflated, base64 encoded and url-escaped.
:Parameters:
-`authn_request`: AuthnRequest
:Return:
The decoded AuthnRequest if successful else empty string.
"""
decoded = ''
a = urllib.unquote(authn_request)
a = a.strip('SAMLRequest=')
try:
decoded = zlib.decompress(base64.b64decode(a), -8)
except (zlib.error, TypeError):
try:
decoded = zlib.decompress(base64.b64decode(a))
except (zlib.error, TypeError):
pass
return decoded
Thanks,
Bhaskar.
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
| [List Home]