Thursday, March 11, 2021

SignOn PeopleCode: Base64 Decode + Inflate

This is a follow-up to my previous post where we saw how we can Deflate + Base64 Encode a SAML Request. 

Refer: https://pe0ples0ft.blogspot.com/2021/03/sso-deflate-base64-encode-saml.html

Here is an example of the reverse - Base64 Decode + Inflate:

/* Code Credit: Diego De Boni: https://www.linkedin.com/in/diego-de-boni-625312 */
Local string &sEncodedB64 = "c3RydnEFAA==";
/* Decode Base64 */
Local JavaObject &decoder = GetJavaClass("com.peoplesoft.tools.util.Base64");
Local JavaObject &decodedBytes = &decoder.decode(&sEncodedB64);
Local JavaObject &decoded = CreateJavaObject("java.lang.String", &decodedBytes);
/* Inflate */
Local JavaObject &inflater = CreateJavaObject("java.util.zip.Inflater", True);
Local JavaObject &baOutputStream = CreateJavaObject("java.io.ByteArrayOutputStream");
Local JavaObject &inflaterOutputStream = CreateJavaObject("java.util.zip.InflaterOutputStream", &baOutputStream, &inflater);
&inflaterOutputStream.write(&decodedBytes, 0, &decodedBytes.length);
&inflaterOutputStream.close();
Local string &sInflated = &baOutputStream.toString();

No comments:

Post a Comment