Hi,

I am currently trying to set up a custom security model using struts which involves extending ActionMapping
with a class called SecureActionMapping using Tomcat 5.0 and Struts 1.2.


My problem is that after initialisation of the actions, which definitely creates and parses the extended action mapping for each action because the bean property is checked for exuistence in the extending class, the property's set method is not called on execution of an action. Therefore rendering the vector that is initialised with the value parameter as empty instead of placing the value in it.

After searching for some alternate solutions on the web at JavaWorld and the struts.apache.org FAQ I was unable to find a solution to this. The following is how I have set this up;

in my web.xml file I tried adding a initialisation parameter for the ActionServlet as mentioned at JavaWorld

<init-param>
<param-name>mapping</param-name> <param-value>au.com.common.struts.action.mapping.SecureActionMapping</param-value>
</init-param>


and in the struts-config.xml

<action-mappings type="au.com.plantechnology.common.struts.action.mapping.SecureActionMapping">
<action path="/SecureAction" scope="request" type="au.com.plantechnology.finance.struts.action.SecureAction">
<set-property property="securityRoles" value="admin,manager,finance"/> <forward name="success" path="/test_security.jsp"/>
<forward name="failure" path="/login.jsp"/> </action>
</action-mappings>


Where my property is securityRoles.  The java class is as follows;

package au.com.common.struts.action.mapping;

import java.util.StringTokenizer;
import java.util.Vector;

import org.apache.struts.action.ActionMapping;

public class SecureActionMapping extends ActionMapping
{
private Vector myRoles = new Vector();
public SecureActionMapping() {}
public void setSecurityRoles(String aRolesString)
{
System.out.println("WTF ?");
StringTokenizer st = new StringTokenizer(aRolesString, ",", false);
while (st.hasMoreTokens())
{
myRoles.add(st.nextToken().trim());
}
}
public Vector getSecurityRoles()
{
return myRoles;
}
}


As the the System.out.println in my set method does not display I assume that this method is not being correctly called by the ActionServlet when creating the ActionMapping.

Any help would be great.

Thanks in advance

Steve Peck.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to