Repository: cxf Updated Branches: refs/heads/master 8515dcba6 -> da25b2af7
[CXF-5807] - Fix STSClient configuration when Issuer EPR has an "anonymous" address Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/da25b2af Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/da25b2af Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/da25b2af Branch: refs/heads/master Commit: da25b2af7780b39df7953026a83194aefb15a647 Parents: 8515dcb Author: Colm O hEigeartaigh <[email protected]> Authored: Mon Jun 16 15:32:20 2014 +0100 Committer: Colm O hEigeartaigh <[email protected]> Committed: Mon Jun 16 15:32:20 2014 +0100 ---------------------------------------------------------------------- .../ws/security/trust/AbstractSTSClient.java | 28 +++++++++++++++----- .../apache/cxf/systest/sts/issuer/DoubleIt.wsdl | 3 ++- 2 files changed, 24 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/da25b2af/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java ---------------------------------------------------------------------- diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java index d78c496..ce4682f 100644 --- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java +++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java @@ -519,17 +519,33 @@ public abstract class AbstractSTSClient implements Configurable, InterceptorProv Service service = factory.create(); service.setDataBinding(dataBinding); + // Get the endpoint + service names by matching the 'location' to the + // address in the WSDL. If the 'location' is 'anonymous' then just fall + // back to the first service + endpoint name in the WSDL, if the endpoint + // name is not defined in the Metadata + List<ServiceInfo> services = service.getServiceInfos(); + String anonymousAddress = "http://www.w3.org/2005/08/addressing/anonymous"; - for (ServiceInfo serv : service.getServiceInfos()) { - for (EndpointInfo ei : serv.getEndpoints()) { - if (ei.getAddress().equals(location)) { - endpointName = ei.getName(); - serviceName = serv.getName(); + if (!anonymousAddress.equals(location)) { + for (ServiceInfo serv : services) { + for (EndpointInfo ei : serv.getEndpoints()) { + if (ei.getAddress().equals(location)) { + endpointName = ei.getName(); + serviceName = serv.getName(); + } } } } + EndpointInfo ei = service.getEndpointInfo(endpointName); - if (location != null) { + if (ei == null && anonymousAddress.equals(location) + && !services.isEmpty() && !services.get(0).getEndpoints().isEmpty()) { + serviceName = services.get(0).getName(); + endpointName = services.get(0).getEndpoints().iterator().next().getName(); + ei = service.getEndpointInfo(endpointName); + } + + if (location != null && !anonymousAddress.equals(location)) { ei.setAddress(location); } Endpoint endpoint = new EndpointImpl(bus, service, ei); http://git-wip-us.apache.org/repos/asf/cxf/blob/da25b2af/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/issuer/DoubleIt.wsdl ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/issuer/DoubleIt.wsdl b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/issuer/DoubleIt.wsdl index c50f0d3..84710c5 100644 --- a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/issuer/DoubleIt.wsdl +++ b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/issuer/DoubleIt.wsdl @@ -248,7 +248,8 @@ <sp:RequireInternalReference/> </wsp:Policy> <sp:Issuer> - <wsaw:Address>https://localhost:30101/SecurityTokenService/TransportSoap12</wsaw:Address> + <!--<wsaw:Address>https://localhost:30101/SecurityTokenService/TransportSoap12</wsaw:Address>--> + <wsaw:Address>http://www.w3.org/2005/08/addressing/anonymous</wsaw:Address> <wsaw:Metadata> <wsx:Metadata> <wsx:MetadataSection>
