Hi Julian,
Thanks for responding to my post. I'm going to try your suggestion and will
let you know. 
Best,
Patricia Goldweic
[EMAIL PROTECTED]
 

> -----Original Message-----
> From: [email protected] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Julian (Google)
> Sent: Monday, September 08, 2008 10:38 AM
> To: Google Apps APIs
> Subject: [google-apps-apis] Re: Java SSO intermittent problem
> 
> 
> Hi Patricia,
> 
> I think you may need to Flush the stream to finish any buffered
> output:
> 
>     while ((count = decompressorStream.read(buf)) != -1) {
>         out.write(buf, 0, count);
>     }
>     out.flush();
>     return out.toByteArray();
> 
> Please let me know if this solves the issue.
> 
> Thanks,
> Julian.
> 
> On Sep 5, 6:52 pm, "Patricia Goldweic" <[EMAIL PROTECTED]>
> wrote:
> > Hi,
> > I just realized that I forgot to include part of the 
> relevant code of 
> > my implementation (the definition of 'inflate').  Once again, I'll 
> > very much appreciate any help with this.
> > -Patricia
> >
> > Here it goes:
> >
> > ===================================================================
> > private static byte[] inflate(byte[] bytes, boolean nowrap)
> >
> > throws IOException {
> >
> >     Inflater decompressor = null;
> >
> >     InflaterInputStream decompressorStream = null;
> >
> >     ByteArrayOutputStream out = new ByteArrayOutputStream();
> >
> >     try {
> >
> >     decompressor = new Inflater(nowrap);
> >
> >     decompressorStream = new InflaterInputStream(new 
> > ByteArrayInputStream(bytes), decompressor);
> >
> >     byte[] buf = new byte[1024];
> >
> >     int count;
> >
> >     while ((count = decompressorStream.read(buf)) != -1) {
> >
> >         out.write(buf, 0, count);
> >
> >     }
> >
> >     return out.toByteArray();
> >
> >     } finally {
> >
> >         if (decompressor != null) decompressor.end();
> >
> >         try {
> >
> >             if (decompressorStream != null) 
> > decompressorStream.close();
> >
> >          } catch (IOException ioe) {
> >
> >             /*ignore*/
> >
> >          }
> >
> >          try {
> >
> >               if (out != null) out.close();
> >
> >          } catch (IOException ioe) {
> >
> >             /*ignore*/
> >
> >          }
> >
> >         }
> >
> > }
> >
> > 
> ======================================================================
> > ======
> > =====================
> >
> > Patricia Goldweic
> > [EMAIL PROTECTED]
> >
> >   _____
> >
> > From: [email protected] 
> > [mailto:[EMAIL PROTECTED] On Behalf Of Patricia 
> > Goldweic
> > Sent: Thursday, September 04, 2008 4:40 PM
> > To: [email protected]
> > Subject: [google-apps-apis] Java SSO intermittent problem
> >
> > Hi,
> > My SSO java code started failing intermittently with an 
> exception of 
> > the type 'Unexpected end of ZLIB input stream'  when 
> decoding the SAML request.
> > Has anybody gone through this before?
> > Here is my code for decoding, based on the original reference 
> > implementation, and somewhat modified based on suggestions in this 
> > list from some time ago (by Nate) as to how to avoid intermittent 
> > exceptions related to buffer size:
> >
> > 
> ======================================================================
> > =
> >
> > private String decodeAuthnRequestXML(String 
> encodedRequestXmlString) 
> > throws SamlException {
> >
> >     String uncompressed = null;
> >
> >     try {
> >
> >     // URL decode
> >
> >     // No need to URL decode: auto decoded by 
> request.getParameter() 
> > method
> >
> >     // Base64 decode
> >
> >     Base64 base64Decoder = new Base64();
> >
> >     byte[] xmlBytes = encodedRequestXmlString.getBytes("UTF-8");
> >
> >     byte[] base64DecodedByteArray = base64Decoder.decode(xmlBytes);
> >
> >     // Uncompress the AuthnRequest data using a stream 
> decompressor, 
> > as suggested by Nate ( Google Apps Api's group)
> >
> >     try {
> >
> >     uncompressed = new 
> String(inflate(base64DecodedByteArray, true));
> >
> >     } catch (ZipException e) {
> >
> >     uncompressed = new 
> String(inflate(base64DecodedByteArray, false));
> >
> >     }
> >
> >     } catch (UnsupportedEncodingException e) {
> >
> >     e.printStackTrace();
> >
> >     throw new SamlException("Error decoding AuthnRequest: " +
> >
> >     "Check decoding scheme - " + e.getMessage());
> >
> >     } catch (Exception e) {
> >
> >     e.printStackTrace();
> >
> >     throw new SamlException("Error decoding AuthnRequest: " +
> >
> >     "Check decoding scheme - " + e.getMessage());
> >
> >     }
> >
> >     return uncompressed;
> >
> > }
> >
> > 
> ======================================================================
> > ======
> > ======================
> >
> > I'll appreciate any ideas/suggestions you may have. Thanks,
> >
> > -Patricia
> > 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Apps APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to