Java 无法调用DefaultBootstrap.bootstrap();方法在自己的opensaml解组方法中
我编写了以下解组方法来处理xml文件,但在执行过程中遇到以下错误 以下代码片段是我的代码:Java 无法调用DefaultBootstrap.bootstrap();方法在自己的opensaml解组方法中,java,opensaml,Java,Opensaml,我编写了以下解组方法来处理xml文件,但在执行过程中遇到以下错误 以下代码片段是我的代码: private Response a(String text) throws ConfigurationException, SAXException { try { DefaultBootstrap.bootstrap(); <= ERROR HERE } catch(ConfigurationException e
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;
}
private响应a(字符串文本)抛出ConfigurationException,SAXException{
试一试{
DefaultBootstrap.bootstrap();如果它只是一个测试代码,运行时没有任何https通信,那么应该设置系统属性
org.opensaml.httpclient.https.disableHostnameVerification=true
在jvm中,或在DefaultBootstrap.bootstrap()方法之前包含以下代码段:
谢谢你的帮助!它很有效,我正在为这个方法编写junit测试,并寻找解决方案。非常感谢!
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)
System.setProperty("org.opensaml.httpclient.https.disableHostnameVerification", "true");