Author: anil.saldhana(a)jboss.com
Date: 2011-05-17 01:01:03 -0400 (Tue, 17 May 2011)
New Revision: 942
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
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/auth/AbstractSTSLoginModule.java
Log:
handle wst:issuer and RST batch request issue
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-05-17
04:58:37 UTC (rev 941)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java 2011-05-17
05:01:03 UTC (rev 942)
@@ -67,6 +67,11 @@
private String wspAppliesTo;
/**
+ * Indicates whether the request is a batch request - will be read from the {@link
STSClientConfig}
+ */
+ private boolean isBatch = false;
+
+ /**
* Constructor
* @see {@link #setDispatch(Dispatch)} for the setting of the {@link Dispatch} object
*/
@@ -89,6 +94,8 @@
QName service = new QName(targetNS, config.getServiceName());
QName portName = new QName(targetNS, config.getPortName());
+ isBatch = config.isBatch();
+
wsaIssuerAddress = config.getWsaIssuer();
wspAppliesTo = config.getWspAppliesTo();
@@ -156,6 +163,10 @@
public Element issueTokenForEndpoint(String endpointURI) throws WSTrustException
{
RequestSecurityToken request = new RequestSecurityToken();
+ if (wsaIssuerAddress != null)
+ {
+ request.setIssuer(WSTrustUtil.createIssuer(wsaIssuerAddress));
+ }
setAppliesTo(endpointURI, request);
return issueToken(request);
}
@@ -180,6 +191,10 @@
throw new IllegalArgumentException("One of endpointURI or tokenType must be
provided.");
RequestSecurityToken request = new RequestSecurityToken();
+ if (wsaIssuerAddress != null)
+ {
+ request.setIssuer(WSTrustUtil.createIssuer(wsaIssuerAddress));
+ }
setAppliesTo(endpointURI, request);
setTokenType(tokenType, request);
return issueToken(request);
@@ -210,6 +225,10 @@
throw new IllegalArgumentException("One of endpointURI or tokenType must be
provided.");
RequestSecurityToken request = new RequestSecurityToken();
+ if (wsaIssuerAddress != null)
+ {
+ request.setIssuer(WSTrustUtil.createIssuer(wsaIssuerAddress));
+ }
setAppliesTo(endpointURI, request);
setTokenType(tokenType, request);
setOnBehalfOf(principal, request);
@@ -250,7 +269,13 @@
public Element issueToken(RequestSecurityToken request) throws WSTrustException
{
if (request.getRequestType() == null)
- request.setRequestType(URI.create(WSTrustConstants.ISSUE_REQUEST));
+ {
+ if (isBatch)
+ request.setRequestType(URI.create(WSTrustConstants.BATCH_ISSUE_REQUEST));
+ else
+ request.setRequestType(URI.create(WSTrustConstants.ISSUE_REQUEST));
+ }
+
if (request.getContext() == null)
request.setContext("default-context");
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-05-17
04:58:37 UTC (rev 941)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClientConfig.java 2011-05-17
05:01:03 UTC (rev 942)
@@ -73,6 +73,8 @@
public static final String WSP_APPLIES_TO = "wspAppliesTo";
+ public static final String IS_BATCH = "isBatch";
+
private final String serviceName;
private final String portName;
@@ -87,6 +89,8 @@
private final String wspAppliesTo;
+ private boolean isBatch = false; //Is the RST a batch request?
+
private STSClientConfig(final Builder builder)
{
serviceName = builder.serviceName;
@@ -94,6 +98,7 @@
endpointAddress = builder.endpointAddress;
username = builder.username;
password = builder.password;
+ isBatch = builder.isBatch;
wsaIssuer = builder.wsaIssuer;
wspAppliesTo = builder.wspAppliesTo;
}
@@ -133,6 +138,11 @@
return wspAppliesTo;
}
+ public boolean isBatch()
+ {
+ return isBatch;
+ }
+
public String toString()
{
return getClass().getSimpleName() + "[serviceName=" + serviceName +
", portName=" + portName
@@ -155,6 +165,8 @@
private String wspAppliesTo;
+ private boolean isBatch;
+
public Builder()
{
}
@@ -231,6 +243,16 @@
return password;
}
+ public boolean isBatch()
+ {
+ return isBatch;
+ }
+
+ public void setBatch(boolean isBatch)
+ {
+ this.isBatch = isBatch;
+ }
+
public STSClientConfig build()
{
validate(this);
@@ -258,6 +280,8 @@
this.password = properties.getProperty(PASSWORD);
this.wsaIssuer = properties.getProperty(WSA_ISSUER);
this.wspAppliesTo = properties.getProperty(WSP_APPLIES_TO);
+ String batchStr = properties.getProperty(IS_BATCH);
+ this.isBatch = StringUtil.isNotNull(batchStr) ?
Boolean.parseBoolean(batchStr) : false;
if
(this.password.startsWith(PicketLinkFederationConstants.PASS_MASK_PREFIX))
{
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/auth/AbstractSTSLoginModule.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/auth/AbstractSTSLoginModule.java 2011-05-17
04:58:37 UTC (rev 941)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/auth/AbstractSTSLoginModule.java 2011-05-17
05:01:03 UTC (rev 942)
@@ -223,6 +223,11 @@
public static final String PASSWORD_KEY = "password";
/**
+ * Key to specify whether this batch issue request
+ */
+ public static final String IS_BATCH = "isBatch";
+
+ /**
* The subject to be populated.
*/
protected Subject subject;
@@ -284,6 +289,11 @@
protected String securityDomain = null;
/**
+ * Value to indicate whether the RST is a batch request
+ */
+ protected boolean isBatch = false;
+
+ /**
* Initialized this login module. Simple stores the passed in fields and
* also validates the options.
*
@@ -333,6 +343,12 @@
{
this.injectCallerPrincipalGroup = Boolean.parseBoolean(callerPrincipalGroup);
}
+
+ String batchIssueString = (String) options.get(IS_BATCH);
+ if (StringUtil.isNotNull(batchIssueString))
+ {
+ this.isBatch = Boolean.parseBoolean(batchIssueString);
+ }
}
/**
@@ -442,6 +458,8 @@
builder.portName((String) options.get(PORT_NAME)).serviceName((String)
options.get(SERVICE_NAME));
builder.username((String) options.get(USERNAME_KEY)).password((String)
options.get(PASSWORD_KEY));
+ builder.setBatch(isBatch);
+
String passwordString = (String) options.get(PASSWORD_KEY);
if (passwordString != null &&
passwordString.startsWith(PicketLinkFederationConstants.PASS_MASK_PREFIX))
{
Show replies by date