You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2012/12/18 11:59:16 UTC
svn commit: r1423406 - in
/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common:
crypto/SantuarioUtil.java crypto/WSProviderConfig.java util/Loader.java
Author: coheigea
Date: Tue Dec 18 10:59:15 2012
New Revision: 1423406
URL: http://svn.apache.org/viewvc?rev=1423406&view=rev
Log:
[WSS-417] - A fix to deploy WSS4J in Karaf
Conflicts:
ws-security-common/src/main/java/org/apache/ws/security/common/util/Loader.java
ws-security-dom/src/main/java/org/apache/ws/security/dom/WSSConfig.java
Added:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/SantuarioUtil.java
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/WSProviderConfig.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/util/Loader.java
Added: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/SantuarioUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/SantuarioUtil.java?rev=1423406&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/SantuarioUtil.java (added)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/SantuarioUtil.java Tue Dec 18 10:59:15 2012
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ws.security.common.crypto;
+
+import java.security.Provider;
+
+import org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI;
+
+public final class SantuarioUtil {
+
+ private SantuarioUtil() {
+ // complete
+ }
+
+
+ public static Provider getSantuarioProvider() {
+ return new XMLDSigRI();
+ }
+}
+
+
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/WSProviderConfig.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/WSProviderConfig.java?rev=1423406&r1=1423405&r2=1423406&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/WSProviderConfig.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/crypto/WSProviderConfig.java Tue Dec 18 10:59:15 2012
@@ -123,7 +123,7 @@ public final class WSProviderConfig {
}
private static void addXMLDSigRIInternal() {
- addJceProvider("ApacheXMLDSig", "org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI");
+ addJceProvider("ApacheXMLDSig", SantuarioUtil.getSantuarioProvider());
}
private static void initializeResourceBundles() {
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/util/Loader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/util/Loader.java?rev=1423406&r1=1423405&r2=1423406&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/util/Loader.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/ws/security/common/util/Loader.java Tue Dec 18 10:59:15 2012
@@ -51,21 +51,37 @@ public class Loader {
* @return TODO
*/
public static URL getResource(String resource) {
- ClassLoader classLoader = null;
URL url = null;
try {
- classLoader = getTCL();
+ ClassLoader classLoader = getTCL();
if (classLoader != null) {
log.debug("Trying to find [" + resource + "] using " + classLoader + " class loader.");
url = classLoader.getResource(resource);
+ if (url == null && resource.startsWith("/")) {
+ //certain classloaders need it without the leading /
+ url = classLoader.getResource(resource.substring(1));
+ }
if (url != null) {
return url;
- }
+ }
}
} catch (Throwable t) {
log.warn("Caught Exception while in Loader.getResource. This may be innocuous.", t);
}
-
+
+ ClassLoader cluClassloader = Loader.class.getClassLoader();
+ if (cluClassloader == null) {
+ cluClassloader = ClassLoader.getSystemClassLoader();
+ }
+ url = cluClassloader.getResource(resource);
+ if (url == null && resource.startsWith("/")) {
+ //certain classloaders need it without the leading /
+ url = cluClassloader.getResource(resource.substring(1));
+ }
+ if (url != null) {
+ return url;
+ }
+
// Last ditch attempt: get the resource from the class path. It
// may be the case that clazz was loaded by the Extension class
// loader which the parent of the system class loader. Hence the
@@ -98,6 +114,10 @@ public class Loader {
if (loader != null) {
log.debug("Trying to find [" + resource + "] using " + loader + " class loader.");
url = loader.getResource(resource);
+ if (url == null && resource.startsWith("/")) {
+ //certain classloaders need it without the leading /
+ url = loader.getResource(resource.substring(1));
+ }
if (url != null) {
return url;
}
@@ -240,9 +260,25 @@ public class Loader {
log.debug(e.getMessage(), e);
}
}
- // we reached here because tcl was null or because of a
- // security exception, or because clazz could not be loaded...
- // In any case we now try one more time
- return Class.forName(clazz);
+
+ return loadClass2(clazz, null);
+ }
+
+ private static Class<?> loadClass2(String className, Class<?> callingClass)
+ throws ClassNotFoundException {
+ try {
+ return Class.forName(className);
+ } catch (ClassNotFoundException ex) {
+ try {
+ if (Loader.class.getClassLoader() != null) {
+ return Loader.class.getClassLoader().loadClass(className);
+ }
+ } catch (ClassNotFoundException exc) {
+ if (callingClass != null && callingClass.getClassLoader() != null) {
+ return callingClass.getClassLoader().loadClass(className);
+ }
+ }
+ throw ex;
+ }
}
}