cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1521479 - in /cxf/trunk: services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/ services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/ services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/crypto/ syste...
Date Tue, 10 Sep 2013 13:37:33 GMT
Author: cschneider
Date: Tue Sep 10 13:37:32 2013
New Revision: 1521479

URL: http://svn.apache.org/r1521479
Log:
CXF-5259 Allow to create crypto provider without fallback. Separate factory for client from
XKMSInvoker

Added:
    cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSClientFactory.java
    cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XKMSInvoker.java
      - copied, changed from r1521368, cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java
Removed:
    cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java
Modified:
    cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/CryptoProviderUtils.java
    cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProvider.java
    cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProviderFactory.java
    cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/crypto/CryptoProviderFactory.java
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml

Added: cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSClientFactory.java?rev=1521479&view=auto
==============================================================================
--- cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSClientFactory.java
(added)
+++ cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSClientFactory.java
Tue Sep 10 13:37:32 2013
@@ -0,0 +1,47 @@
+/**
+ * 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.cxf.xkms.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.xkms.model.extensions.ResultDetails;
+import org.w3._2002._03.xkms_wsdl.XKMSPortType;
+
+public final class XKMSClientFactory {
+    private XKMSClientFactory() {
+        // Util class
+    }
+    
+    public static XKMSPortType create(String endpointAddress, Bus bus) {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setBus(bus);
+        factory.setServiceClass(XKMSPortType.class);
+        factory.setAddress(endpointAddress);
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put("jaxb.additionalContextClasses", 
+                       new Class[] {ResultDetails.class});
+        factory.setProperties(properties);
+        
+        return (XKMSPortType)factory.create();
+    }
+}

Modified: cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/CryptoProviderUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/CryptoProviderUtils.java?rev=1521479&r1=1521478&r2=1521479&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/CryptoProviderUtils.java
(original)
+++ cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/CryptoProviderUtils.java
Tue Sep 10 13:37:32 2013
@@ -36,7 +36,7 @@ import org.apache.wss4j.common.crypto.Me
 import org.apache.wss4j.common.ext.WSPasswordCallback;
 import org.apache.wss4j.common.ext.WSPasswordCallback.Usage;
 
-public final class CryptoProviderUtils {
+final class CryptoProviderUtils {
 
     private CryptoProviderUtils() {
     }

Copied: cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XKMSInvoker.java
(from r1521368, cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XKMSInvoker.java?p2=cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XKMSInvoker.java&p1=cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java&r1=1521368&r2=1521479&rev=1521479&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java
(original)
+++ cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XKMSInvoker.java
Tue Sep 10 13:37:32 2013
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.xkms.client;
+package org.apache.cxf.xkms.crypto.impl;
 
 import java.io.ByteArrayInputStream;
 import java.math.BigInteger;
@@ -26,17 +26,13 @@ import java.security.cert.CertificateFac
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.UUID;
 
 import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.xkms.client.X509AppId;
 import org.apache.cxf.xkms.exception.ExceptionMapper;
 import org.apache.cxf.xkms.exception.XKMSException;
 import org.apache.cxf.xkms.exception.XKMSLocateException;
@@ -44,7 +40,6 @@ import org.apache.cxf.xkms.exception.XKM
 import org.apache.cxf.xkms.exception.XKMSValidateException;
 import org.apache.cxf.xkms.handlers.Applications;
 import org.apache.cxf.xkms.handlers.XKMSConstants;
-import org.apache.cxf.xkms.model.extensions.ResultDetails;
 import org.apache.cxf.xkms.model.xkms.KeyBindingEnum;
 import org.apache.cxf.xkms.model.xkms.LocateRequestType;
 import org.apache.cxf.xkms.model.xkms.LocateResultType;
@@ -60,7 +55,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3._2002._03.xkms_wsdl.XKMSPortType;
 
-public class XKMSInvoker {
+class XKMSInvoker {
     private static final Logger LOG = LoggerFactory.getLogger(XKMSInvoker.class);
 
     private static final org.apache.cxf.xkms.model.xmldsig.ObjectFactory DSIG_OF =
@@ -78,29 +73,6 @@ public class XKMSInvoker {
         this.xkmsConsumer = xkmsConsumer;
     }
     
-    public XKMSInvoker(String endpointAddress) {
-        this(endpointAddress, null);
-    }
-    
-    public XKMSInvoker(String endpointAddress, Bus bus) {
-
-        if (bus != null) {
-            SpringBusFactory.setDefaultBus(bus);
-            SpringBusFactory.setThreadDefaultBus(bus);
-        }
-        
-        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
-        factory.setServiceClass(XKMSPortType.class);
-        factory.setAddress(endpointAddress);
-        
-        Map<String, Object> properties = new HashMap<String, Object>();
-        properties.put("jaxb.additionalContextClasses", 
-                       new Class[] {ResultDetails.class});
-        factory.setProperties(properties);
-        
-        xkmsConsumer = (XKMSPortType)factory.create();
-    }
-    
     public X509Certificate getServiceCertificate(QName serviceName) {
         return getCertificateForId(Applications.SERVICE_SOAP, serviceName.toString());
     }

Modified: cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProvider.java?rev=1521479&r1=1521478&r2=1521479&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProvider.java
(original)
+++ cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProvider.java
Tue Sep 10 13:37:32 2013
@@ -32,7 +32,6 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.xkms.cache.EHCacheXKMSClientCache;
 import org.apache.cxf.xkms.cache.XKMSCacheToken;
 import org.apache.cxf.xkms.cache.XKMSClientCache;
-import org.apache.cxf.xkms.client.XKMSInvoker;
 import org.apache.cxf.xkms.crypto.CryptoProviderException;
 import org.apache.cxf.xkms.handlers.Applications;
 import org.apache.wss4j.common.crypto.Crypto;
@@ -42,7 +41,7 @@ import org.apache.wss4j.common.crypto.Cr
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.w3._2002._03.xkms_wsdl.XKMSPortType;
 
-public class XkmsCryptoProvider extends CryptoBase {
+class XkmsCryptoProvider extends CryptoBase {
 
     private static final Logger LOG = LogUtils.getL7dLogger(XkmsCryptoProvider.class);
 
@@ -67,23 +66,6 @@ public class XkmsCryptoProvider extends 
         this.xkmsClientCache = xkmsClientCache;
     }
     
-    public XkmsCryptoProvider(XKMSInvoker xkmsInvoker) {
-        this(xkmsInvoker, null);
-    }
-    
-    public XkmsCryptoProvider(XKMSInvoker xkmsInvoker, Crypto defaultCrypto) {
-        this(xkmsInvoker, defaultCrypto, new EHCacheXKMSClientCache());
-    }
-    
-    public XkmsCryptoProvider(XKMSInvoker xkmsInvoker, Crypto defaultCrypto, XKMSClientCache
xkmsClientCache) {
-        if (xkmsInvoker == null) {
-            throw new IllegalArgumentException("xkmsInvoker may not be null");
-        }
-        this.xkmsInvoker = xkmsInvoker;
-        this.defaultCrypto = defaultCrypto;
-        this.xkmsClientCache = xkmsClientCache;
-    }
-    
     @Override
     public X509Certificate[] getX509Certificates(CryptoType cryptoType) throws WSSecurityException
{
         if (LOG.isLoggable(Level.INFO)) {

Modified: cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProviderFactory.java?rev=1521479&r1=1521478&r2=1521479&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProviderFactory.java
(original)
+++ cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/impl/XkmsCryptoProviderFactory.java
Tue Sep 10 13:37:32 2013
@@ -30,6 +30,10 @@ import org.apache.wss4j.common.crypto.Cr
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.w3._2002._03.xkms_wsdl.XKMSPortType;
 
+/**
+ * For usage in OSGi this factory will be published as a service.
+ * Outside OSGi it can be used directly 
+ */
 public class XkmsCryptoProviderFactory implements CryptoProviderFactory {
     
     private final XKMSPortType xkmsConsumer;
@@ -50,4 +54,8 @@ public class XkmsCryptoProviderFactory i
                                               + e.getMessage(), e);
         }
     }
+
+    public Crypto create() {
+        return new XkmsCryptoProvider(xkmsConsumer);
+    }
 }

Modified: cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/crypto/CryptoProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/crypto/CryptoProviderFactory.java?rev=1521479&r1=1521478&r2=1521479&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/crypto/CryptoProviderFactory.java
(original)
+++ cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/crypto/CryptoProviderFactory.java
Tue Sep 10 13:37:32 2013
@@ -24,6 +24,18 @@ import org.apache.wss4j.common.crypto.Cr
 
 public interface CryptoProviderFactory {
 
+    /**
+     * Create with merlin fallback settings retrieved from cxf message
+     * @param message
+     * @return
+     */
     Crypto create(Message message);
 
+    /**
+     * Create without fallback crypto 
+     * 
+     * @param cryptoProperties
+     * @return xkms crypto
+     */
+    Crypto create();
 }

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml?rev=1521479&r1=1521478&r2=1521479&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml
(original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml
Tue Sep 10 13:37:32 2013
@@ -60,7 +60,7 @@
     </jaxws:client>
     -->
     
-    <bean id="xkmsInvoker" class="org.apache.cxf.xkms.client.XKMSInvoker">
+    <bean id="xkmsClient" class="org.apache.cxf.xkms.client.XKMSClientFactory" factory-method="create">
         <constructor-arg>
             <value>https://localhost:${testutil.ports.XKMSServer}/XKMS</value>
         </constructor-arg>
@@ -69,8 +69,7 @@
     
     <bean id="xkmsCrypto" class="org.apache.cxf.xkms.crypto.impl.XkmsCryptoProvider">
         <constructor-arg>
-            <!-- <ref bean="xkmsClient" /> -->
-            <ref bean="xkmsInvoker" />
+            <ref bean="xkmsClient" />
         </constructor-arg>
     </bean>
     
@@ -94,8 +93,7 @@
     
     <bean id="xkmsAsymmetricCrypto" class="org.apache.cxf.xkms.crypto.impl.XkmsCryptoProvider">
         <constructor-arg>
-            <!-- <ref bean="xkmsClient" /> -->
-            <ref bean="xkmsInvoker" />
+            <ref bean="xkmsClient" />
         </constructor-arg>
         <constructor-arg>
              <ref bean="crypto" />



Mime
View raw message