Author: anil.saldhana(a)jboss.com
Date: 2011-04-13 01:08:53 -0400 (Wed, 13 Apr 2011)
New Revision: 884
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClientConfig.java
Log:
add ws-a issuer and ws-p applies to
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java 2011-04-13
05:08:24 UTC (rev 883)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java 2011-04-13
05:08:53 UTC (rev 884)
@@ -57,18 +57,22 @@
*/
public class STSClient
{
- private ThreadLocal<Dispatch<Source>> dispatchLocal = new
InheritableThreadLocal<Dispatch<Source>>();
+ private final ThreadLocal<Dispatch<Source>> dispatchLocal = new
InheritableThreadLocal<Dispatch<Source>>();
- private String targetNS = "http://org.picketlink.trust/sts/";
+ private final String targetNS = "http://org.picketlink.trust/sts/";
+ private String wsaIssuerAddress;
+
+ private String wspAppliesTo;
+
/**
* Constructor
* @see {@link #setDispatch(Dispatch)} for the setting of the {@link Dispatch} object
*/
public STSClient()
- {
+ {
}
-
+
/**
* <p>
* Constructor that creates the {@link Dispatch} for use.
@@ -84,6 +88,9 @@
QName service = new QName(targetNS, config.getServiceName());
QName portName = new QName(targetNS, config.getPortName());
+ wsaIssuerAddress = config.getWsaIssuer();
+ wspAppliesTo = config.getWspAppliesTo();
+
Service jaxwsService = Service.create(service);
jaxwsService.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
config.getEndPointAddress());
Dispatch<Source> dispatch = jaxwsService.createDispatch(portName,
Source.class, Mode.PAYLOAD);
@@ -95,20 +102,20 @@
// add the username and password to the request context.
reqContext.put(BindingProvider.USERNAME_PROPERTY, config.getUsername());
reqContext.put(BindingProvider.PASSWORD_PROPERTY, config.getPassword());
- }
- setDispatch(dispatch);
+ }
+ setDispatch(dispatch);
}
-
+
/**
* Set the {@link Dispatch} object for use
* @param dispatch
*/
- public void setDispatch( Dispatch<Source> dispatch )
+ public void setDispatch(Dispatch<Source> dispatch)
{
- if( dispatch == null )
- throw new IllegalArgumentException( "dispatch is null" );
-
- dispatchLocal.set( dispatch );
+ if (dispatch == null)
+ throw new IllegalArgumentException("dispatch is null");
+
+ dispatchLocal.set(dispatch);
}
/**
@@ -122,6 +129,15 @@
// create a custom token request message.
RequestSecurityToken request = new RequestSecurityToken();
setTokenType(tokenType, request);
+
+ if (wsaIssuerAddress != null)
+ {
+ request.setIssuer(WSTrustUtil.createIssuer(wsaIssuerAddress));
+ }
+ if (wspAppliesTo != null)
+ {
+ request.setAppliesTo(WSTrustUtil.createAppliesTo(wspAppliesTo));
+ }
// send the token request to JBoss STS and get the response.
return issueToken(request);
}
@@ -232,7 +248,7 @@
request.setRequestType(URI.create(WSTrustConstants.ISSUE_REQUEST));
if (request.getContext() == null)
request.setContext("default-context");
-
+
validateDispatch();
DOMSource requestSource = this.createSourceFromRequest(request);
Source response = dispatchLocal.get().invoke(requestSource);
@@ -333,7 +349,7 @@
Node rstr = nodes.item(0);
- return (Element) rstr.getFirstChild();
+ return (Element) rstr.getFirstChild();
}
/**
@@ -441,13 +457,13 @@
throw new WSTrustException("Error creating source from request: " +
e.getMessage(), e);
}
}
-
+
/**
* Validate that we have a {@code Dispatch} to work with
*/
private void validateDispatch()
{
- if( getDispatch() == null )
- throw new RuntimeException( "Dispatch has not been set" );
+ if (getDispatch() == null)
+ throw new RuntimeException("Dispatch has not been set");
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClientConfig.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClientConfig.java 2011-04-13
05:08:24 UTC (rev 883)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClientConfig.java 2011-04-13
05:08:53 UTC (rev 884)
@@ -69,6 +69,10 @@
public static final String TOKEN_TYPE = "tokenType";
+ public static final String WSA_ISSUER = "wsaIssuer";
+
+ public static final String WSP_APPLIES_TO = "wspAppliesTo";
+
private final String serviceName;
private final String portName;
@@ -79,6 +83,10 @@
private final String password;
+ private final String wsaIssuer;
+
+ private final String wspAppliesTo;
+
private STSClientConfig(final Builder builder)
{
serviceName = builder.serviceName;
@@ -86,6 +94,8 @@
endpointAddress = builder.endpointAddress;
username = builder.username;
password = builder.password;
+ wsaIssuer = builder.wsaIssuer;
+ wspAppliesTo = builder.wspAppliesTo;
}
public String getServiceName()
@@ -113,6 +123,16 @@
return password;
}
+ public String getWsaIssuer()
+ {
+ return wsaIssuer;
+ }
+
+ public String getWspAppliesTo()
+ {
+ return wspAppliesTo;
+ }
+
public String toString()
{
return getClass().getSimpleName() + "[serviceName=" + serviceName +
", portName=" + portName
@@ -131,6 +151,10 @@
private String password;
+ private String wsaIssuer;
+
+ private String wspAppliesTo;
+
public Builder()
{
}
@@ -170,6 +194,18 @@
return this;
}
+ public Builder wsaIssuer(final String wsa)
+ {
+ this.wsaIssuer = wsa;
+ return this;
+ }
+
+ public Builder wspAppliesTo(final String wsp)
+ {
+ this.wspAppliesTo = wsp;
+ return this;
+ }
+
public String getServiceName()
{
return serviceName;
Show replies by date