有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

saml Java Inflater引发DataFormatException“无效代码长度集”

我正在用充气机解压一个简单的请求。由于这个值是用GZIP压缩的,所以我设法将“true”传递给充气器构造函数,以提供与这种格式的兼容性。然而,膨胀行抛出DataFormatException

    private String decodeMessage(String SAMLContent) {
        try {
            //URLDecode, Base64 and inflate data

            //URLDecode
            SAMLContent = URLDecoder.decode(SAMLContent, "UTF-8");

            //Base64 decoding
            byte[] decode = Base64.getDecoder().decode(SAMLContent);
            SAMLContent = new String(decode, "UTF-8");
            //SAMLContent = new String(Base64.getDecoder().decode(SAMLContent), "UTF-8");

            //Inflating data
            try {
                byte[] inflated = new byte[(10 * SAMLContent.getBytes("UTF-8").length)];
                Inflater i = new Inflater(true);
                i.setInput(SAMLContent.getBytes("UTF-8"), 0, SAMLContent.getBytes("UTF-8").length);

                //The following line throws DFException
                int finalSize = i.inflate(inflated);

                SAMLContent = new String(SAMLContent.getBytes("UTF-8"), 0, finalSize, "UTF-8");
                i.end();

            } catch (DataFormatException ex) {
                JOptionPane.showMessageDialog(null, "DFE: " + ex.getMessage());  //Returns "invalid code length set"
            }

        } catch (UnsupportedEncodingException ex) {
            JOptionPane.showMessageDialog(null, "UEE: " + ex.getMessage());
        }

        return SAMLContent;
    }

例外情况在第20行提出。我试图复制的工作流程是

  1. 正在复制请求的值(This one for instance
  2. 使用this URL decoder to decode it(左下角文本框)
  3. 将第二步的结果粘贴到此Base64decoder + inflater中,以获取原始XML,如最后一页的第三个文本框所示

共 (0) 个答案