Author: asoldano
Date: Thu May 10 11:11:14 2012
New Revision: 1336589
URL: http://svn.apache.org/viewvc?rev=1336589&view=rev
Log:
[CXF-4304] Complete WSA support for STS client configuration via EPR
Added:
cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/sts/STSClientTest.java
(with props)
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml
(with props)
Modified:
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
Modified:
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java?rev=1336589&r1=1336588&r2=1336589&view=diff
==============================================================================
---
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
(original)
+++
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
Thu May 10 11:11:14 2012
@@ -455,6 +455,18 @@ public class STSClient implements Config
return;
}
location = EndpointReferenceUtils.getAddress(ref);
+ final QName sName = EndpointReferenceUtils.getServiceName(ref, bus);
+ if (sName != null) {
+ serviceName = sName;
+ final QName epName = EndpointReferenceUtils.getPortQName(ref, bus);
+ if (epName != null) {
+ endpointName = epName;
+ }
+ }
+ final String wsdlLoc = EndpointReferenceUtils.getWSDLLocation(ref);
+ if (wsdlLoc != null) {
+ wsdlLocation = wsdlLoc;
+ }
String mexLoc = findMEXLocation(ref);
if (mexLoc != null) {
try {
@@ -504,7 +516,7 @@ public class STSClient implements Config
}
}
}
- return EndpointReferenceUtils.getAddress(ref);
+ return null;
}
protected String findMEXLocation(Element ref) {
Element el = DOMUtils.getFirstElement(ref);
Added:
cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/sts/STSClientTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/sts/STSClientTest.java?rev=1336589&view=auto
==============================================================================
---
cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/sts/STSClientTest.java
(added)
+++
cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/sts/STSClientTest.java
Thu May 10 11:11:14 2012
@@ -0,0 +1,65 @@
+/**
+ * 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.ws.security.sts;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.jaxb.JAXBContextCache;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.security.trust.STSClient;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class STSClientTest extends Assert {
+
+ @Test
+ public void testConfigureViaEPR() throws Exception {
+
+ final Set<Class<?>> addressingClasses = new HashSet<Class<?>>();
+
addressingClasses.add(org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class);
+
addressingClasses.add(org.apache.cxf.ws.addressing.ObjectFactory.class);
+
+ JAXBContext ctx =
JAXBContextCache.getCachedContextAndSchemas(addressingClasses, null, null, null,
+
true).getContext();
+ Unmarshaller um = ctx.createUnmarshaller();
+ InputStream inStream = getClass().getResourceAsStream("epr.xml");
+ JAXBElement el = (JAXBElement)um.unmarshal(inStream);
+ EndpointReferenceType ref = (EndpointReferenceType)el.getValue();
+
+ Bus bus = BusFactory.getThreadDefaultBus();
+ STSClient client = new STSClient(bus);
+ client.configureViaEPR(ref);
+
+
assertEquals("http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl",
+ client.getWsdlLocation());
+ assertEquals(new
QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
"SecurityTokenService"),
+ client.getServiceQName());
+ assertEquals(new
QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"),
+ client.getEndpointQName());
+ }
+}
Propchange:
cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/sts/STSClientTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/sts/STSClientTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml?rev=1336589&view=auto
==============================================================================
---
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml
(added)
+++
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml
Thu May 10 11:11:14 2012
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+<wsaws:Address
xmlns:wsaws="http://www.w3.org/2005/08/addressing">http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService</wsaws:Address>
+<wsaws:Metadata xmlns:wsaws="http://www.w3.org/2005/08/addressing"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+
wsdli:wsdlLocation="http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl">
+ <wsaw:ServiceName xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+
xmlns:stsns="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"
+
EndpointName="UT_Port">stsns:SecurityTokenService</wsaw:ServiceName>
+</wsaws:Metadata>
+</wsa:EndpointReference>
+
Propchange:
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
cxf/trunk/rt/ws/security/src/test/resources/org/apache/cxf/ws/security/sts/epr.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml