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/09/04 12:22:25 UTC

svn commit: r1519970 - in /cxf/trunk: services/xkms/xkms-client/ services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/ services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/ systests/ws-security/src/test/resour...

Author: coheigea
Date: Wed Sep  4 10:22:24 2013
New Revision: 1519970

URL: http://svn.apache.org/r1519970
Log:
Making additional JAXB Context classes available to XKMSInvoker + fixing X509 File handler

Modified:
    cxf/trunk/services/xkms/xkms-client/pom.xml
    cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java
    cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/xkms-server.xml

Modified: cxf/trunk/services/xkms/xkms-client/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-client/pom.xml?rev=1519970&r1=1519969&r2=1519970&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-client/pom.xml (original)
+++ cxf/trunk/services/xkms/xkms-client/pom.xml Wed Sep  4 10:22:24 2013
@@ -63,9 +63,14 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
-        	<groupId>net.sf.ehcache</groupId>
-        	<artifactId>ehcache</artifactId>
-    		<version>${cxf.ehcache.version}</version>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.ehcache</groupId>
+            <artifactId>ehcache</artifactId>
+            <version>${cxf.ehcache.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>

Modified: 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/client/XKMSInvoker.java?rev=1519970&r1=1519969&r2=1519970&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/client/XKMSInvoker.java Wed Sep  4 10:22:24 2013
@@ -26,15 +26,17 @@ 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 javax.xml.ws.BindingProvider;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.xkms.exception.ExceptionMapper;
 import org.apache.cxf.xkms.exception.XKMSException;
 import org.apache.cxf.xkms.exception.XKMSLocateException;
@@ -42,6 +44,7 @@ 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;
@@ -56,7 +59,6 @@ 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);
@@ -81,20 +83,22 @@ public class XKMSInvoker {
     }
     
     public XKMSInvoker(String endpointAddress, Bus bus) {
-        
+
         if (bus != null) {
             SpringBusFactory.setDefaultBus(bus);
             SpringBusFactory.setThreadDefaultBus(bus);
         }
         
-        XKMSService xkmsService = new XKMSService();
-        xkmsConsumer = xkmsService.getPort(XKMSPortType.class);
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(XKMSPortType.class);
+        factory.setAddress(endpointAddress);
         
-        if (endpointAddress != null && !"".equals(endpointAddress)) {
-            ((BindingProvider)xkmsConsumer).getRequestContext().put(
-                BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 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) {

Modified: cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java?rev=1519970&r1=1519969&r2=1519970&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java (original)
+++ cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java Wed Sep  4 10:22:24 2013
@@ -215,7 +215,10 @@ public class FileCertificateRepo impleme
             }
 
         }
-        return result.get(0);
+        if (!result.isEmpty()) {
+            return result.get(0);
+        }
+        return null;
     }
 
     @Override
@@ -239,6 +242,9 @@ public class FileCertificateRepo impleme
             }
 
         }
-        return result.get(0);
+        if (!result.isEmpty()) {
+            return result.get(0);
+        }
+        return null;
     }
 }

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/xkms-server.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/xkms-server.xml?rev=1519970&r1=1519969&r2=1519970&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/xkms-server.xml (original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/xkms-server.xml Wed Sep  4 10:22:24 2013
@@ -99,10 +99,18 @@
         </property>
     </bean>
  
+    <bean id="additionalClasses"
+          class="org.apache.cxf.xkms.model.extensions.AdditionalClassesFactory" />
+        
     <jaxws:endpoint id="XKMSService"
         xmlns:serviceNamespace="http://www.w3.org/2002/03/xkms#wsdl"
         serviceName="serviceNamespace:XKMSService" endpointName="serviceNamespace:XKMSPort"
         implementor="#xkmsProviderBean" address="https://localhost:${testutil.ports.XKMSServer}/XKMS">
+        <jaxws:properties>
+            <entry key="jaxb.additionalContextClasses">
+                 <bean factory-bean="additionalClasses" factory-method="create" />
+            </entry>
+        </jaxws:properties>
     </jaxws:endpoint>
     
 </beans>