...
A custom implantation of RoleValidator can specified in the security section of the nexaweb-reference-framework.xml.
Code Block |
---|
<security> <!-- Whether or not security is enable --> <enabled>true</enabled> <!-- xal file to use as login page --> <loginPage>XAL/login/Login.xal</loginPage> <!-- custom role validator --> <roleValidator>com.mycompany.security.impleCustomRoleValidator</roleValidator> </security> |
This will instantiate the specified class and set it as the roleValidator.
Then in the impleCustomRoleValidator
class, you can implement the method below: public boolean
Code Block | ||||
---|---|---|---|---|
| ||||
public boolean validateElement( Element element ) |
...
For example, if we have a button in the page like this:
...
Code Block | ||||
---|---|---|---|---|
| ||||
public boolean validateElement( Element element )
{
//validation returning value
boolean retValue = false;
//User details of the logged in user
CustomUserDetailsuserDetails = (CustomUserDetails)AppContext.getAppContext().getSecurityManager().getUserDetails();
//if no validation needed or user's dept attributes contains "Department_A"
if(element.getAttribute("validate").equalsIgnoreCase("false") (
element.getAttribute("validate").equalsIgnoreCase("true") &&
element.getAttribute("dept").indexOf(userDetails.getDepartment())!=-1)){
retValue=true;
element.setAttribute("text", "passed");//validation passed
}else{
element.setAttribute("text","failed"); //otherwise validation failed
}
return retValue;
} |
...