Hi Julian,
Thanks again for your reply. I actually did start with the latest code, but
that code is unfortunately not robust enough since it guesses a fixed buffer
length (5000) that is supposed to accommodate the decompressed stream (and
you don't know how big this is going to be). This gives rise to another kind
of intermittent failures  ("didn't allocate enough space to hold
decompressed data" ), which were reported in an earlier thread
(http://groups.google.com/group/google-apps-apis/browse_thread/thread/8f190c
7c6e68b1ee/04d0bc40ffbcc9c8?lnk=gst&q=didn%27t+allocate+enough+space+to+hold
#04d0bc40ffbcc9c8 ) One possibility is to set this size to a very high
number and hope that it works. However, 
somebody suggested what was supposed to be a better solution in this same
thread, and that's what I used in my code.
Unfortunately this caused the other type of intermittent exception that I
reported :-(.
So I ended up experimenting with another variation of the code in the
reference implementation, after some research into this Java exception in
general (thanks for your pointers too), and I seem to have managed to avoid
any exceptions after quite a bit of testing. I still need to do some more
testing before I can ensure that is totally safe though.
Best,
-Patricia

Patricia Goldweic
[EMAIL PROTECTED]
 

> -----Original Message-----
> From: [email protected] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Julian (Google)
> Sent: Tuesday, September 09, 2008 8:08 AM
> To: Google Apps APIs
> Subject: [google-apps-apis] Re: Java SSO intermittent problem
> 
> 
> Hi Patricia,
> 
> Did you start coding from our last release? I recommend you 
> to try our latest code if not:
> http://code.google.com/p/google-apps-sso-sample/source/browse/
trunk/java/samlsource/src/servlets/ProcessResponseServlet.java
> 
> Also, there are few post in this thread, about a similar issue:
> http://forums.sun.com/thread.jspa?messageID=616929
> 
> Cheers,
> Julian
> 
> On Sep 8, 5:21 pm, "Patricia Goldweic" <[EMAIL PROTECTED]>
> wrote:
> > Hi again Julian,
> > Unfortunately this is still happening (it happened after my 
> 10th attempt).
> > For more info, the exception is thrown during the call to 
> 'read'. Here 
> > is the backtrace:
> > 
> ----------------------------------------------------------------------
> > ------
> > -----
> > java.io.EOFException: Unexpected end of ZLIB input stream
> >         at
> > java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223)
> >         at
> > java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
> >         at java.io.FilterInputStream.read(FilterInputStream.java:90)
> >         at
> > 
> edu.northwestern.at.gint.servlets.ProcessSAMLResponseServlet.inflate(P
> > rocess
> > SAMLResponseServlet.java:248)
> >         at
> > 
> edu.northwestern.at.gint.servlets.ProcessSAMLResponseServlet.decodeAut
> > hnRequ
> > estXML(ProcessSAMLResponseServlet.java:210)
> >         at
> > 
> edu.northwestern.at.gint.servlets.ProcessSAMLResponseServlet.processRe
> > quest(
> > ProcessSAMLResponseServlet.java:109)
> >         at
> > 
> edu.northwestern.at.gint.servlets.ProcessSAMLResponseServlet.doGet(Pro
> > cessSA
> > MLResponseServlet.java:68)
> >         at 
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> >         at 
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >         at
> > 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
> > cation
> > FilterChain.java:290)
> >         at
> > 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
> > lterCh
> > ain.java:206)
> > ...
> > 
> ----------------------------------------------------------------------
> > ------
> > --------
> >
> > Thanks again for any help on this,
> > -Patricia
> >
> > 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