【问题标题】:Unable to invoke DefaultBootstrap.bootstrap(); method in own opensaml unmarshalling method无法调用 DefaultBootstrap.bootstrap();自己的opensaml解组方法中的方法
【发布时间】:2019-11-04 13:42:16
【问题描述】:

我编写了以下解组方法来处理我的 xml 文件,但在执行过程中遇到以下错误。

以下sn-p是我的代码:

private Response a(String text) throws ConfigurationException, SAXException  {

        try {
             DefaultBootstrap.bootstrap();   <= ERROR HERE
        }
        catch(ConfigurationException e) {
             log.error("Error Encountered", e);
        }

        Schema s = SAMLSchemaBuilder.getSAML11Schema();

        BasicParserPool bpp = new BasicParserPool();
        bpp.setNamespaceAware(true);
        bpp.setIgnoreElementContentWhitespace(true);
        bpp.setSchema(schema);

        InputStream is= new ByteArrayInputStream(Base64.decode(samlContent).getBytes());
        Response res= null;

        try {
            Document doc = bpp.parse(is);
            Element elmt= doc.getDocumentElement();
            try {

                QName qn = new QName(elmt.getNamespaceURI(), elmt.getLocalName(), elmt.getPrefix());
                Unmarshaller um = Configuration.getUnmarshallerFactory().getUnmarshaller(qn);
                samlResponse = (Response) unmarshaller.unmarshall(elmt);
            } catch (XMLParserException e) {
                  logger.debug(e.getMessage());
        } catch (UnmarshallingException e) {
            logger.debug(e.getMessage());
        }

        return res;
    }

以下是 IDE 中的错误消息返回:

java.lang.IllegalArgumentException: Error create SSL context

    at org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.init(TLSProtocolSocketFactory.java:151)
    at org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.<init>(TLSProtocolSocketFactory.java:111)
    at org.opensaml.DefaultBootstrap.initializeHttpClient(DefaultBootstrap.java:118)
    at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:110)

如果您之前遇到以下问题,我将非常感谢任何形式的帮助或知识分享。谢谢!

【问题讨论】:

    标签: java opensaml


    【解决方案1】:

    如果它只是一个测试代码,在没有任何 https 通信的情况下运行,你应该设置系统属性 org.opensaml.httpclient.https.disableHostnameVerification=true 在 jvm 中,或者在 DefaultBootstrap.bootstrap() 方法之前包含以下代码 sn -p:

    System.setProperty("org.opensaml.httpclient.https.disableHostnameVerification", "true");
    

    【讨论】:

    • 感谢您的帮助!它确实有效,我正在为此方法编写junit测试并寻找解决方案。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-02
    • 1970-01-01
    • 2018-06-24
    • 2021-03-30
    • 2013-02-23
    • 1970-01-01
    相关资源
    最近更新 更多