Author: anil.saldhana(a)jboss.com
Date: 2011-04-23 00:36:53 -0400 (Sat, 23 Apr 2011)
New Revision: 904
Modified:
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java
Log:
add support for csv for header name
Modified:
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java
===================================================================
---
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java 2011-04-22
23:36:19 UTC (rev 903)
+++
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/handler/BinaryTokenHandler.java 2011-04-23
04:36:53 UTC (rev 904)
@@ -21,6 +21,10 @@
*/
package org.picketlink.trust.jbossws.handler;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.xml.namespace.QName;
@@ -47,7 +51,7 @@
* <p>
* <i>System Properties:</i>
* <ul>
- * <li>binary.http.header: http header name</li>
+ * <li>binary.http.header: http header name. Can be a comma separated set of
names</li>
* <li>binary.http.cookie: http cookie name</li>
* <li>binary.http.encodingType: attribute value of the EncodingType
attribute</li>
* <li>binary.http.valueType: attribute value of the ValueType
attribute</li>
@@ -285,12 +289,30 @@
{
if( httpHeaderName!= null && !httpHeaderName.isEmpty())
{
- String header = http.getHeader(httpHeaderName);
- if( header != null)
+ //Sometime the http header name can be a comma separated list of names
+ if( httpHeaderName.contains(","))
{
- if(trace) log.trace("Header value has been identified:" + header);
- return clean(header);
+ List<String> headers = getHeaderNames(httpHeaderName);
+ StringBuilder builder = new StringBuilder();
+ for(String header: headers)
+ {
+ String value = getTokenValue(http, header);
+ if(value != null)
+ builder.append(value);
+ }
+ String str = builder.toString();
+ if(trace) log.trace("Header value has been identified:" + str );
+ return clean(str);
}
+ else
+ {
+ String header = http.getHeader(httpHeaderName);
+ if( header != null)
+ {
+ if(trace) log.trace("Header value has been identified:" +
header);
+ return clean(header);
+ }
+ }
}
if( httpCookieName != null && !httpCookieName.isEmpty())
{
@@ -310,6 +332,16 @@
return null;
}
+ private String getTokenValue(HttpServletRequest http,String header)
+ {
+ String headerValue = http.getHeader(header);
+ if( headerValue != null && !headerValue.isEmpty())
+ {
+ return clean(headerValue);
+ }
+ return null;
+ }
+
/**
* Given a binary token, create a {@link SOAPElement}
* @param token
@@ -362,7 +394,7 @@
while((i = value.indexOf(' ')) != -1)
{
value = value.substring(i + 1);
- }
+ }
}
if(trace)
{
@@ -370,4 +402,16 @@
}
return value;
}
+
+ private List<String> getHeaderNames(String str)
+ {
+ List<String> list = new ArrayList<String>();
+
+ StringTokenizer st = new StringTokenizer(str, ",");
+ while(st.hasMoreElements())
+ {
+ list.add(st.nextToken());
+ }
+ return list;
+ }
}
\ No newline at end of file
Show replies by date