I'm getting a java.util.zip.ZipException: invalid bit length repeat
when attempting to retrieve a AuthnRequest with the opensaml library HTTPRedirectDeflateDecoder
. I'm receiving the deflated and encoded SAMLObject thorough a GET request. This is the code I'm using to retrieve the object
import org.opensaml.saml.saml2.binding.decoding.impl.HTTPRedirectDeflateDecoder;
protected String getAuthnRequest(
HttpServletRequest request,
HttpServletResponse response) throws Exception {
HTTPRedirectDeflateDecoder decoder = new HTTPRedirectDeflateDecoder();
decoder.setHttpServletRequest(request);
try {
decoder.initialize();
decoder.decode(); //error occurs here
} catch (ComponentInitializationException | MessageDecodingException e) {
throw new Exception("error in decoding authnrequest", e);
}
MessageContext<SAMLObject> messageContext = decoder.getMessageContext();
...
}
Full error:
org.opensaml.messaging.decoder.MessageDecodingException: Error unmarshalling message from input stream
at org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder.unmarshallMessage(BaseHttpServletRequestXMLMessageDecoder.java:158)
at org.opensaml.saml.saml2.binding.decoding.impl.HTTPRedirectDeflateDecoder.doDecode(HTTPRedirectDeflateDecoder.java:108)
at org.opensaml.messaging.decoder.AbstractMessageDecoder.decode(AbstractMessageDecoder.java:58)
at org.opensaml.messaging.decoder.servlet.AbstractHttpServletRequestMessageDecoder.decode(AbstractHttpServletRequestMessageDecoder.java:55)
at org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder.decode(BaseHttpServletRequestXMLMessageDecoder.java:72)
at com.healthtrio.htcweb.common.controller.sso.BaseOutboundController.getAuthnRequestId(BaseOutboundController.java:426)
... 129 common frames omitted
Caused by: net.shibboleth.utilities.java.support.xml.XMLParserException: Unable to read data from input stream
at net.shibboleth.utilities.java.support.xml.BasicParserPool.parse(BasicParserPool.java:255)
at org.opensaml.core.xml.util.XMLObjectSupport.unmarshallFromInputStream(XMLObjectSupport.java:235)
at org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder.unmarshallMessage(BaseHttpServletRequestXMLMessageDecoder.java:154)
... 134 common frames omitted
Caused by: java.util.zip.ZipException: invalid bit length repeat
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:165)
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:123)
at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.readAndBuffer(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
at net.shibboleth.utilities.java.support.xml.BasicParserPool$DocumentBuilderProxy.parse(BasicParserPool.java:785)
at net.shibboleth.utilities.java.support.xml.BasicParserPool.parse(BasicParserPool.java:247)
... 136 common frames omitted
Any help is appreciated,
Thanks
Found the error, This was a mistake from the data I was testing with. I used a deflated/encoded AuthnRequest. Since this is a GET request, I had to also URL decode the SAML Object.