You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by dk...@apache.org on 2015/03/19 15:11:42 UTC
svn commit: r1667760 -
/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java
Author: dkulp
Date: Thu Mar 19 14:11:41 2015
New Revision: 1667760
URL: http://svn.apache.org/r1667760
Log:
Try getting opensaml 3 initialized in OSGi
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java?rev=1667760&r1=1667759&r2=1667760&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java Thu Mar 19 14:11:41 2015
@@ -68,23 +68,39 @@ public final class OpenSAMLUtil {
}
try {
WSProviderConfig.init();
- InitializationService.initialize();
- // OpenSAMLBootstrap.bootstrap();
- builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
- marshallerFactory = XMLObjectProviderRegistrySupport.getMarshallerFactory();
- unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
+
+ try {
+ tryInitWithClassLoader(Thread.currentThread().getContextClassLoader());
+ } catch (Throwable t) {
+ tryInitWithClassLoader(InitializationService.class.getClassLoader());
+ }
+
samlEngineInitialized = true;
if (LOG.isDebugEnabled()) {
- LOG.debug("opensaml2 library bootstrap complete");
+ LOG.debug("opensaml3 library bootstrap complete");
}
} catch (InitializationException e) {
LOG.error(
- "Unable to bootstrap the opensaml2 library - all SAML operations will fail",
+ "Unable to bootstrap the opensaml3 library - all SAML operations will fail",
e
);
}
}
}
+
+ private static void tryInitWithClassLoader(ClassLoader l) throws InitializationException {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(l);
+ InitializationService.initialize();
+ // OpenSAMLBootstrap.bootstrap();
+ builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
+ marshallerFactory = XMLObjectProviderRegistrySupport.getMarshallerFactory();
+ unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
+ } finally {
+ Thread.currentThread().setContextClassLoader(loader);
+ }
+ }
/**
* Convert a SAML Assertion from a DOM Element to an XMLObject