You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2013/08/22 18:40:44 UTC

svn commit: r1516509 - in /cxf/branches/2.7.x-fixes: services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/ services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/ systests/ws-security/src/test/resources/org/apache/cxf/systest/...

Author: coheigea
Date: Thu Aug 22 16:40:44 2013
New Revision: 1516509

URL: http://svn.apache.org/r1516509
Log:
Merged revisions 1516506 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1516506 | coheigea | 2013-08-22 17:34:52 +0100 (Thu, 22 Aug 2013) | 2 lines

  Make it possible to set up an XKMSInvoker with just an endpoint URL + a CXF bus

........

Modified:
    cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java
    cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java
    cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml

Modified: cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java?rev=1516509&r1=1516508&r2=1516509&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java (original)
+++ cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java Thu Aug 22 16:40:44 2013
@@ -31,7 +31,10 @@ import java.util.UUID;
 
 import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.xkms.exception.ExceptionMapper;
 import org.apache.cxf.xkms.exception.XKMSException;
 import org.apache.cxf.xkms.exception.XKMSLocateException;
@@ -53,6 +56,7 @@ import org.apache.cxf.xkms.model.xmldsig
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3._2002._03.xkms_wsdl.XKMSPortType;
+import org.w3._2002._03.xkms_wsdl.XKMSService;
 
 public class XKMSInvoker {
     private static final Logger LOG = LoggerFactory.getLogger(XKMSInvoker.class);
@@ -71,7 +75,22 @@ public class XKMSInvoker {
     public XKMSInvoker(XKMSPortType xkmsConsumer) {
         this.xkmsConsumer = xkmsConsumer;
     }
-
+    
+    public XKMSInvoker(String endpointAddress, Bus bus) {
+        
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+        XKMSService xkmsService = new XKMSService();
+        xkmsConsumer = xkmsService.getPort(XKMSPortType.class);
+        
+        if (endpointAddress != null && !"".equals(endpointAddress)) {
+            ((BindingProvider)xkmsConsumer).getRequestContext().put(
+                BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress
+            );
+        }
+    }
+    
     public X509Certificate getServiceCertificate(QName serviceName) {
         return getCertificateForId(Applications.SERVICE_SOAP, serviceName.toString());
     }
@@ -245,5 +264,5 @@ public class XKMSInvoker {
         request.setService(XKMSConstants.XKMS_ENDPOINT_NAME);
         request.setId(UUID.randomUUID().toString());
     }
-
+    
 }

Modified: cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java?rev=1516509&r1=1516508&r2=1516509&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java (original)
+++ cxf/branches/2.7.x-fixes/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java Thu Aug 22 16:40:44 2013
@@ -66,6 +66,23 @@ 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/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml?rev=1516509&r1=1516508&r2=1516509&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml Thu Aug 22 16:40:44 2013
@@ -44,6 +44,7 @@
     </cxf:bus>
     
     <!-- Begin Symmetric -->
+    <!--
     <jaxws:client id="xkmsClient"
         serviceClass="org.w3._2002._03.xkms_wsdl.XKMSPortType"
         name="{http://www.w3.org/2002/03/xkms#wsdl}XKMSPort" 
@@ -61,10 +62,19 @@
             </entry>
         </jaxws:properties>
     </jaxws:client>
+    -->
+    
+    <bean id="xkmsInvoker" class="org.apache.cxf.xkms.client.XKMSInvoker">
+        <constructor-arg>
+            <value>https://localhost:${testutil.ports.XKMSServer}/XKMS</value>
+        </constructor-arg>
+        <constructor-arg ref="cxf"/>
+    </bean>
     
     <bean id="xkmsCrypto" class="org.apache.cxf.xkms.crypto.XkmsCryptoProvider">
         <constructor-arg>
-            <ref bean="xkmsClient" />
+            <!-- <ref bean="xkmsClient" /> -->
+            <ref bean="xkmsInvoker" />
         </constructor-arg>
     </bean>
     
@@ -88,7 +98,8 @@
     
     <bean id="xkmsAsymmetricCrypto" class="org.apache.cxf.xkms.crypto.XkmsCryptoProvider">
         <constructor-arg>
-            <ref bean="xkmsClient" />
+            <!-- <ref bean="xkmsClient" /> -->
+            <ref bean="xkmsInvoker" />
         </constructor-arg>
         <constructor-arg>
              <ref bean="crypto" />