You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/08/02 18:34:31 UTC
svn commit: r1509767 - in /cxf/branches/2.6.x-fixes: ./
rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java
systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
Author: sergeyb
Date: Fri Aug 2 16:34:30 2013
New Revision: 1509767
URL: http://svn.apache.org/r1509767
Log:
Merged revisions 1509704 via svnmerge from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
................
r1509704 | sergeyb | 2013-08-02 14:39:43 +0100 (Fri, 02 Aug 2013) | 13 lines
Merged revisions 1509700,1509702 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1509700 | sergeyb | 2013-08-02 14:33:48 +0100 (Fri, 02 Aug 2013) | 1 line
Trying to load Crypto with URI or File if other attempts fail
........
r1509702 | sergeyb | 2013-08-02 14:38:11 +0100 (Fri, 02 Aug 2013) | 1 line
Moving a try block a bit higher
........
................
Modified:
cxf/branches/2.6.x-fixes/ (props changed)
cxf/branches/2.6.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java
cxf/branches/2.6.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/branches/2.7.x-fixes:r1509704
Merged /cxf/trunk:r1509700-1509702
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.6.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java?rev=1509767&r1=1509766&r2=1509767&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java (original)
+++ cxf/branches/2.6.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java Fri Aug 2 16:34:30 2013
@@ -19,8 +19,10 @@
package org.apache.cxf.rs.security.common;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
import java.net.URL;
import java.util.Map;
import java.util.Properties;
@@ -55,14 +57,17 @@ public class CryptoLoader {
return null;
}
- crypto = getCryptoCache(message).get(o);
+ String propResourceName = (String)o;
+
+ Map<Object, Crypto> cryptoCache = getCryptoCache(message);
+ crypto = cryptoCache != null ? cryptoCache.get(propResourceName) : null;
if (crypto != null) {
return crypto;
}
ClassLoaderHolder orig = null;
try {
- URL url = ClassLoaderUtils.getResource((String)o, this.getClass());
+ URL url = ClassLoaderUtils.getResource(propResourceName, this.getClass());
if (url == null) {
ResourceManager manager = message.getExchange()
.getBus().getExtension(ResourceManager.class);
@@ -70,7 +75,22 @@ public class CryptoLoader {
if (loader != null) {
orig = ClassLoaderUtils.setThreadContextClassloader(loader);
}
- url = manager.resolveResource((String)o, URL.class);
+ url = manager.resolveResource(propResourceName, URL.class);
+ }
+ if (url == null) {
+ try {
+ URI propResourceUri = URI.create(propResourceName);
+ if (propResourceUri.getScheme() != null) {
+ url = propResourceUri.toURL();
+ } else {
+ File f = new File(propResourceUri.toString());
+ if (f.exists()) {
+ url = f.toURI().toURL();
+ }
+ }
+ } catch (IOException ex) {
+ // let CryptoFactory try to load it
+ }
}
if (url != null) {
Properties props = new Properties();
@@ -79,7 +99,7 @@ public class CryptoLoader {
in.close();
crypto = CryptoFactory.getInstance(props);
} else {
- crypto = CryptoFactory.getInstance((String)o);
+ crypto = CryptoFactory.getInstance(propResourceName, Thread.currentThread().getContextClassLoader());
}
getCryptoCache(message).put(o, crypto);
return crypto;
Modified: cxf/branches/2.6.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java?rev=1509767&r1=1509766&r2=1509767&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java (original)
+++ cxf/branches/2.6.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java Fri Aug 2 16:34:30 2013
@@ -54,10 +54,22 @@ public class JAXRSXmlSecTest extends Abs
@Test
public void testPostBookWithEnvelopedSigAndProxy() throws Exception {
String address = "https://localhost:" + PORT + "/xmlsig";
- doTestSignatureProxy(address, false);
+ doTestSignatureProxy(address, false, null);
}
- private void doTestSignatureProxy(String address, boolean enveloping) {
+ @Test
+ public void testPostBookWithEnvelopedSigAndProxy2() throws Exception {
+ String address = "https://localhost:" + PORT + "/xmlsig";
+ doTestSignatureProxy(address, false, "");
+ }
+
+ @Test
+ public void testPostBookEnvelopingSigAndProxy() throws Exception {
+ String address = "https://localhost:" + PORT + "/xmlsig";
+ doTestSignatureProxy(address, true, "file:");
+ }
+
+ private void doTestSignatureProxy(String address, boolean enveloping, String cryptoUrlPrefix) throws Exception {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(address);
@@ -70,8 +82,12 @@ public class JAXRSXmlSecTest extends Abs
properties.put("ws-security.callback-handler",
"org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
properties.put("ws-security.signature.username", "alice");
- properties.put("ws-security.signature.properties",
- "org/apache/cxf/systest/jaxrs/security/alice.properties");
+
+ String cryptoUrl = "org/apache/cxf/systest/jaxrs/security/alice.properties";
+ if (cryptoUrlPrefix != null) {
+ cryptoUrl = cryptoUrlPrefix + this.getClass().getResource("/" + cryptoUrl).toURI().getPath();
+ }
+ properties.put("ws-security.signature.properties", cryptoUrl);
bean.setProperties(properties);
XmlSigOutInterceptor sigInterceptor = new XmlSigOutInterceptor();
if (enveloping) {