cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1509704 - in /cxf/branches/2.7.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
Date Fri, 02 Aug 2013 13:39:43 GMT
Author: sergeyb
Date: Fri Aug  2 13:39:43 2013
New Revision: 1509704

URL: http://svn.apache.org/r1509704
Log:
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.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java
    cxf/branches/2.7.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1509700-1509702

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.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.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java?rev=1509704&r1=1509703&r2=1509704&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java
Fri Aug  2 13:39:43 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;
@@ -63,15 +65,18 @@ public class CryptoLoader {
         if (o == null) {
             return null;
         }
-        Map<Object, Crypto> cryptoCache = getCryptoCache(message); 
-        crypto = cryptoCache != null ? cryptoCache.get(o) : null;
+        
+        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);
@@ -79,12 +84,27 @@ 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) {
                 crypto = loadCryptoFromURL(url);
             } else {
-                crypto = CryptoFactory.getInstance((String)o);
+                crypto = CryptoFactory.getInstance(propResourceName, Thread.currentThread().getContextClassLoader());
             }
             if (cryptoCache != null) {
                 cryptoCache.put(o, crypto);

Modified: cxf/branches/2.7.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.7.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java?rev=1509704&r1=1509703&r2=1509704&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
Fri Aug  2 13:39:43 2013
@@ -56,10 +56,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);
         
@@ -72,8 +84,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) {



Mime
View raw message