hi,
below is a writeup of how we implemented it.
*** Client Side ***
Code:
BasicAuthenticationInvokerRequestExecutor
---------------------------------------------------
private void embedInfo(final PostMethod postMethod){
Locale currentLocale = AppSession.getLocale();
postMethod.addRequestHeader("CURRENT_LOCALE_KEY", currentLocale.toString());
}
...
protected RemoteInvocationResult doExecuteRequest(
final HttpInvokerClientConfiguration config,
final ByteArrayOutputStream baos) throws IOException,
ClassNotFoundException {
...
PostMethod postMethod = createPostMethod(config);
this.embedInfo(postMethod);
...
*** Server Side ***
Code:
UserExtractionFilter
----------------------
public class UserExtractionFilter implements Filter{
private static final Logger logger = Logger.getLogger(UserExtractionFilter.class);
private FilterConfig filterConfig;
private void setWmsSecureContext(String localeStr){
WmsSecureContext context = (WmsSecureContext)ContextHolder.getContext();
//if(context==null)throw new GeneralException("Secure Context does not exists on server.");
if(context==null)return;
if(localeStr==null)return;
String tokens[] = localeStr.split("_");
logger.debug("tokens[0]: " + tokens[0]);
logger.debug("tokens[1]: " + tokens[1]);
context.setCurrentLocale(new Locale(tokens[0], tokens[1]));
}
public void doFilter (ServletRequest request,
ServletResponse response,
FilterChain chain)
{
try
{
if(!(request instanceof HttpServletRequest))
throw new ServletException("Can only process HttpServletRequest");
if(!(response instanceof HttpServletResponse))
throw new ServletException("Can only process HttpServletResponse");
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;
String currentLocale = httpRequest.getHeader("CURRENT_LOCALE_KEY");
logger.debug("context: " + ContextHolder.getContext());
logger.debug("CURRENT_LOCALE_KEY: " + currentLocale);
this.setWmsSecureContext(currentLocale);
chain.doFilter (request, response);
} catch (IOException io) {
System.out.println ("IOException raised in SimpleFilter");
} catch (ServletException se) {
System.out.println ("ServletException raised in SimpleFilter");
}
}
public FilterConfig getFilterConfig()
{
return this.filterConfig;
}
public void setFilterConfig (FilterConfig filterConfig)
{
this.filterConfig = filterConfig;
}
/* (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
this.setFilterConfig(arg0);
}
/* (non-Javadoc)
* @see javax.servlet.Filter#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
}
}
Code:
Spring Config File
---------------------
<bean id="autoIntegrationFilter" class="net.sf.acegisecurity.ui.AutoIntegrationFilter">
<property name="secureContext"><value>com.web.WmsSecureContext</value></property>
</bean>
Code:
Retrieving the local object
------------------------------
WmsSecureContext context = (WmsSecureContext)ContextHolder.getContext();
Locale locale = context.getLocale();
Conclusion
------------
Embedding extra information wasn't too difficult once basic concepts was clear.
Just need to add additional information in the header and then write a filter to create the desired object.
However i wasn't able to use the AuthenticationSimpleHttpInvokerRequestExecutor because we are using CommonsHttpClient with SSL and there wasn't a method provided to extra header information.
If the AuthenticationSimpleHttpInvokerRequestExecutor has these features, it would be great.
once again, thanks ben for your advice.