尝试检索 AuthnRequest 时出现 ZipException
ZipException when Attempting to retrieve AuthnRequest
我在尝试使用 opensaml 库 HTTPRedirectDeflateDecoder
检索 AuthnRequest 时收到 java.util.zip.ZipException: invalid bit length repeat
。我通过 GET 请求接收压缩和编码的 SAMLObject。这是我用来检索对象的代码
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();
...
}
完整错误:
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
感谢任何帮助,
谢谢
发现错误,这是我测试数据的错误。我使用了 deflated/encoded AuthnRequest。由于这是一个 GET 请求,我还必须 URL 解码 SAML 对象。
我在尝试使用 opensaml 库 HTTPRedirectDeflateDecoder
检索 AuthnRequest 时收到 java.util.zip.ZipException: invalid bit length repeat
。我通过 GET 请求接收压缩和编码的 SAMLObject。这是我用来检索对象的代码
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();
...
}
完整错误:
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
感谢任何帮助,
谢谢
发现错误,这是我测试数据的错误。我使用了 deflated/encoded AuthnRequest。由于这是一个 GET 请求,我还必须 URL 解码 SAML 对象。