• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

SAMLResponse

New Here ,
Feb 07, 2020 Feb 07, 2020

Copy link to clipboard

Copied

Hello guys! I tried to decipher this SAML Response, it worked, it shows the string on the screen. Now I want to to do the opposite, to deflate the response, from string to binary, do I have to change something in the code or use another function?
 
The entire code is here:
 
<!--- We take a base64 encoded, deflated SAML response string --->
 
<cfset SAMLResponse = "fVPNbtswDL4X6DvwthZwgmB7gCEJCvSSLUA39KzItE1EFj1Stuc9/Sgl3doB3cWwLX7k90M98gw1o0LqEMZIE4oizCznz7c3j+8fwvdY21dysabYvin4oHAiSR3YGVBSGEOi3iWEJj+cIKAqxkQuQEPWBDThYFPYekxIobTr0XcukvYK3EBnVCiV2bqGbx1pBRQhjRIrEPwxkhjPc+Q5YN1ihuTRVpdYlgrmjnxnc5wkrGEmo5eH7KiFnYvt+vbm9uYoOBGPCl+2T1vrPqEmal0ijvoXsmftycOBvPDsJuvh/LkVHk3tw88hsKDA3f7r7uG+OJAxzxTOFJXjK9jWtHESHhY4Cp8Q7p4P2+M9dPmwR6ej4AUtrqbCAhrh/p8wOozFGGc2xbDAp82m2mw2sKAT+xXqCjxHs7m/5mT8Enmzvucag744ZeWGxonDmEetjbMJzifUD8KTcbHMlBJNlJaizBy/Vlfw8LS13I/BRX8GPinK5LLzMGRtFx2BjUHWHjC21lzPS848om0ZDqlTqEfJLPPUj6usAMyFCS2/TIHKqmnKNbY+BWja7IejmLL+MmboFiVfhOXPy4Y1Vttzj6WueePhGg7miSmU6oJnVToFNFIJffG9bPLrfXjpobwyK23lYLfKfho4OKFfl6LBpYQSX4j9b3Pu9ofdfbE6340aTgu04szq0snSyoA/BqWOLXuKVO6QbZbdw5R3NISrUwg+jAZoWMrdKf47aXGlRhizi6O322MlM14DQ0ujdgt41+dXOOH6Nw==" />
 
<!--- We convert the string to binary and a ByteArrayInputStream to be able to read the stream --->
 
<cfset byteIn = createObject("java", "java.io.ByteArrayInputStream").init(ToBinary(SAMLResponse)) />
 
<cfset byteClass = CreateObject("Java", "java.lang.Byte").TYPE />
 
<cfset byteArray = CreateObject("Java", "java.lang.reflect.Array").NewInstance(byteClass, 1024) />
 
<!--- We init the output object where we are going to inflate our response --->
 
<cfset byteOut = CreateObject("Java", "java.io.ByteArrayOutputStream").init() />
 
<!--- We init the zip inflater --->
 
<cfset inflater = CreateObject("Java", "java.util.zip.Inflater").init(true) />
 
<!--- We are specifying to the ibnflater what to read --->
 
<cfset inflaterStream = CreateObject("Java", "java.util.zip.InflaterInputStream").init(byteIn, inflater) />
 
<!--- We loop through our byte array, inflate the buffer and store it inside of our output buffer --->
 
<cfset Count = inflaterStream.read(byteArray) />
 
<cfloop condition="Count neq -1">
 
<cfset byteOut.write(byteArray, 0, Count) />
 
<cfset Count = inflaterStream.read(byteArray) />
 
</cfloop>
 
<!--- We end/close our inflater --->
 
<cfset inflater.end() />
 
<cfset inflaterStream.close() />
 
<!--- Finally we convert back our bytes stream to a nice string
 

 

🙂 --->
 
<cfset inflatedSAMLResponse = ToString(byteOut.tobyteArray()) />
 
<cfdump var="#inflatedSAMLResponse#" />
84325555_2588326734612819_414771159347757056_o.jpg
TOPICS
Advanced techniques

Views

296

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources
Documentation