OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

saml-dev message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Decoding SAMLRequest.


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]