Author: coheigea
Date: Thu Aug 22 16:34:52 2013
New Revision: 1516506
URL: http://svn.apache.org/r1516506
Log:
Make it possible to set up an XKMSInvoker with just an endpoint URL + a CXF bus
Modified:
cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/client/XKMSInvoker.java
cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/client.xml
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=1516506&r1=1516505&r2=1516506&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
Thu Aug 22 16:34:52 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/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java?rev=1516506&r1=1516505&r2=1516506&view=diff
==============================================================================
---
cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java
(original)
+++
cxf/trunk/services/xkms/xkms-client/src/main/java/org/apache/cxf/xkms/crypto/XkmsCryptoProvider.java
Thu Aug 22 16:34:52 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/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=1516506&r1=1516505&r2=1516506&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
Thu Aug 22 16:34:52 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" />