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: Deflate compression again


Hi all,

The thread at 
http://www.oasis-open.org/archives/saml-dev/200604/threads.html#00005
already discussed how to use the Java java.util.zip.Deflater in order to 
compress
a SAML protocol message for use with the HTTP Redirect Binding.

It was pointed to the need to set the "nowrap" argument of the the 
Deflater constructor
to "true" in order to produce the correct output (RFC1951, without zlib 
headers).

We succeed in encoding and decoding data without the headers using the 
Deflater and
Inflater classes.

What doesn't work however is decoding in this way the SAMLRequest 
parameter that is presented
as an example of the Redirect Binding in the SAML2 Bindings document.

Are we missing something or is this example not encoded correctly? If 
the latter is the case, could someone
supply a correctly encoded SAMLRequest for testing purposes?

We  try to decompress the parameter with the following code, it fails with
"Exception in thread "main" java.util.zip.DataFormatException: invalid 
bit length repeat
    at java.util.zip.Inflater.inflateBytes(Native Method)..."

        // Example of an HTTP-Redirect encoded LogoutRequest message 
from SAML2 Bindings Spec (p.21)
        String 
samlRequestUrlEncoded="fVFdS8MwFH0f7D%2BUvGdNsq62oSsIQyhMESc%2B%2BJYlmRbWpObeyvz3puv2IMjyFM7HPedyK1DdsZdb%2F%2BEHfLFfgwVMTt3RgTwzazIEJ72CFqRTnQWJWu7uH7dSLJjsg0ev%2FZFMlttiBWADtt6R%2BSyJr9msiRH7O70sCm31Mj%2Bo%2BC%2B1KA5GlEWeZaogSQMw2MYBKodrIhjLKONU8FdeSsZkVr6T5M0GiHMjvWCknqZXZ2OoPxF7kGnaGOuwxZ%2Fn4L9bY8NC%2By4du1XpRXnxPcXizSZ58KFTeHujEWkNPZylsh9bAMYYUjO2Uiy3jCpTCMo5M1StVjmN9SO150sl9lU6RV2Dp0vsLIy7NM7YU82r9B90PrvCf85W%2FwL8zSVQzAEAAA%3D%3D";
        System.out.println("Url Encoded SAMLRequest: " + 
samlRequestUrlEncoded + "\n");

        String urlDecoded = URLDecoder.decode(samlRequestUrlEncoded, 
"UTF-8");
        System.out.println("URL-decoded: " + urlDecoded + "\n");
   
        byte compressedBytes[] = new 
sun.misc.BASE64Decoder().decodeBuffer(samlRequestUrlEncoded);

        // nowrap=true
        Inflater decompresser = new Inflater(true);
        decompresser.setInput(compressedBytes);
        byte[] result = new byte[2000];
        int resultLength = decompresser.inflate(result);
        decompresser.end();

        // Decode the bytes into a String
        String outputString = new String(result, 0, resultLength, "UTF-8");
        System.out.println("inflater output: " + outputString);

Thanks for your help,
Andreas



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