private static SecureActionConfig getActionConfig(HttpServletRequest
request,
ServletContext app,
String linkString)
{
ModuleConfig moduleConfig = StrutsUtils.selectModule(linkString, app);
// Strip off the module path, if any
linkString = linkString.substring(moduleConfig.getPrefix().length());
// Use our servlet mapping, if one is specified
//String servletMapping = (String)app.getAttribute(Globals.SERVLET_KEY);
SecurePlugInInterface spi = (SecurePlugInInterface)app.getAttribute(
SecurePlugInInterface.SECURE_PLUGIN);
Iterator mappingItr = spi.getServletMappings().iterator();
while (mappingItr.hasNext())
{
String servletMapping = (String)mappingItr.next();
int starIndex = servletMapping != null ? servletMapping.indexOf('*')
: -1;
if (starIndex == -1)
{
continue;
} // No servlet mapping or no usable pattern defined, short circuit
String prefix = servletMapping.substring(0, starIndex);
String suffix = servletMapping.substring(starIndex + 1);
// Strip off the jsessionid, if any
int jsession = linkString.indexOf(";jsessionid=");
if (jsession >= 0)
{
linkString = linkString.substring(0, jsession);
}
// Strip off the query string, if any
// (differs from the SSL Ext. version - query string before anchor)
int question = linkString.indexOf("?");
if (question >= 0)
{
linkString = linkString.substring(0, question);
}
// Strip off the anchor, if any
int anchor = linkString.indexOf("#");
if (anchor >= 0)
{
linkString = linkString.substring(0, anchor);
}
// Unable to establish this link as an action, short circuit
if (!(linkString.startsWith(prefix) && linkString.endsWith(suffix)))
{
continue;
}
// Chop off prefix and suffix
linkString = linkString.substring(prefix.length());
linkString = linkString.substring(0,
linkString.length()
- suffix.length());
if (!linkString.startsWith("/"))
{
linkString = "/" + linkString;
}
SecureActionConfig secureConfig = (SecureActionConfig)moduleConfig.
findActionConfig(linkString);
return secureConfig;
}
return null;