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 2014/02/21 16:47:03 UTC
svn commit: r1570610 - in
/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp:
STSAuthenticationProvider.java STSPortFilter.java beans/STSClientAction.java
Author: coheigea
Date: Fri Feb 21 15:47:03 2014
New Revision: 1570610
URL: http://svn.apache.org/r1570610
Log:
[FEDIZ-71] - Enable use of Apache CXF Fediz IDP with external third-party WS-Trust STS
Modified:
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSAuthenticationProvider.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java
cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSAuthenticationProvider.java?rev=1570610&r1=1570609&r2=1570610&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSAuthenticationProvider.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSAuthenticationProvider.java Fri Feb 21 15:47:03 2014
@@ -57,17 +57,24 @@ public class STSAuthenticationProvider i
private static final String HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512 =
"http://docs.oasis-open.org/ws-sx/ws-trust/200512/";
+ private static final String HTTP_SCHEMAS_XMLSOAP_ORG_WS_2005_02_TRUST =
+ "http://schemas.xmlsoap.org/ws/2005/02/trust";
+
private static final Logger LOG = LoggerFactory
.getLogger(STSAuthenticationProvider.class);
protected String wsdlLocation;
+ protected String namespace = HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512;
+
protected String wsdlService;
protected String wsdlEndpoint;
protected String appliesTo;
+ protected boolean use200502Namespace;
+
protected String tokenType;
protected Bus bus;
@@ -94,16 +101,16 @@ public class STSAuthenticationProvider i
}
sts.setKeyType(HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
sts.setWsdlLocation(wsdlLocation);
- sts.setServiceQName(new QName(
- HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512,
- wsdlService));
- sts.setEndpointQName(new QName(
- HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512,
- wsdlEndpoint));
+ sts.setServiceQName(new QName(namespace, wsdlService));
+ sts.setEndpointQName(new QName(namespace, wsdlEndpoint));
+
sts.getProperties().put(SecurityConstants.USERNAME, authentication.getName());
sts.getProperties().put(SecurityConstants.PASSWORD, (String)authentication.getCredentials());
sts.getProperties().putAll(properties);
-
+ if (use200502Namespace) {
+ sts.setNamespace(HTTP_SCHEMAS_XMLSOAP_ORG_WS_2005_02_TRUST);
+ }
+
if (lifetime != null) {
sts.setEnableLifetime(true);
sts.setTtl(lifetime.intValue());
@@ -187,6 +194,14 @@ public class STSAuthenticationProvider i
public void setWsdlEndpoint(String wsdlEndpoint) {
this.wsdlEndpoint = wsdlEndpoint;
}
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
public String getAppliesTo() {
return appliesTo;
@@ -323,6 +338,14 @@ public class STSAuthenticationProvider i
return properties;
}
+ public boolean isUse200502Namespace() {
+ return use200502Namespace;
+ }
+
+ public void setUse200502Namespace(boolean use200502Namespace) {
+ this.use200502Namespace = use200502Namespace;
+ }
+
//May be uncommented for debugging
// private void setTimeout(Client client, Long timeout) {
// HTTPConduit conduit = (HTTPConduit) client.getConduit();
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java?rev=1570610&r1=1570609&r2=1570610&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSPortFilter.java Fri Feb 21 15:47:03 2014
@@ -55,9 +55,13 @@ public class STSPortFilter extends Gener
if (!isPortSet && request.isSecure()) {
try {
URL url = new URL(authProvider.getWsdlLocation());
- URL updatedUrl = new URL(url.getProtocol(), url.getHost(), request.getLocalPort(), url.getFile());
- setSTSWsdlUrl(authProvider, updatedUrl.toString());
- LOG.info("STSAuthenticationProvider.wsdlLocation set to " + updatedUrl.toString());
+ if (url.getPort() == 0) {
+ URL updatedUrl = new URL(url.getProtocol(), url.getHost(), request.getLocalPort(), url.getFile());
+ setSTSWsdlUrl(authProvider, updatedUrl.toString());
+ LOG.info("STSAuthenticationProvider.wsdlLocation set to " + updatedUrl.toString());
+ } else {
+ setSTSWsdlUrl(authProvider, url.toString());
+ }
} catch (MalformedURLException e) {
LOG.error("Invalid Url '" + authProvider.getWsdlLocation() + "': " + e.getMessage());
}
Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java?rev=1570610&r1=1570609&r2=1570610&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java (original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java Fri Feb 21 15:47:03 2014
@@ -76,18 +76,27 @@ public class STSClientAction {
private static final String HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512 =
"http://docs.oasis-open.org/ws-sx/ws-trust/200512/";
+
+ private static final String HTTP_SCHEMAS_XMLSOAP_ORG_WS_2005_02_TRUST =
+ "http://schemas.xmlsoap.org/ws/2005/02/trust";
private static final String SECURITY_TOKEN_SERVICE = "SecurityTokenService";
private static final Logger LOG = LoggerFactory
.getLogger(STSClientAction.class);
+
+ protected String namespace = HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512;
protected String wsdlLocation;
protected String wsdlEndpoint;
+
+ protected String wsdlService = SECURITY_TOKEN_SERVICE;
protected String tokenType = WSConstants.WSS_SAML2_TOKEN_TYPE;
+ protected boolean use200502Namespace;
+
protected int ttl = 1800;
protected Bus bus;
@@ -121,6 +130,22 @@ public class STSClientAction {
this.wsdlEndpoint = wsdlEndpoint;
}
+ public String getWsdlService() {
+ return wsdlService;
+ }
+
+ public void setWsdlService(String wsdlService) {
+ this.wsdlService = wsdlService;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
public void setBus(Bus bus) {
this.bus = bus;
}
@@ -204,11 +229,11 @@ public class STSClientAction {
processWsdlLocation(context);
sts.setWsdlLocation(wsdlLocation);
- sts.setServiceQName(new QName(
- HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512,
- SECURITY_TOKEN_SERVICE));
- sts.setEndpointQName(new QName(
- HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512, wsdlEndpoint));
+ sts.setServiceQName(new QName(namespace, wsdlService));
+ sts.setEndpointQName(new QName(namespace, wsdlEndpoint));
+ if (use200502Namespace) {
+ sts.setNamespace(HTTP_SCHEMAS_XMLSOAP_ORG_WS_2005_02_TRUST);
+ }
if (serviceConfig.getRequestedClaims() != null && serviceConfig.getRequestedClaims().size() > 0) {
addClaims(sts, serviceConfig.getRequestedClaims());
@@ -359,4 +384,12 @@ public class STSClientAction {
this.keyType = keyType;
}
+ public boolean isUse200502Namespace() {
+ return use200502Namespace;
+ }
+
+ public void setUse200502Namespace(boolean use200502Namespace) {
+ this.use200502Namespace = use200502Namespace;
+ }
+
}