Methods Summary |
---|
protected java.lang.String | handleRejection(com.opensymphony.xwork2.ActionInvocation invocation, javax.servlet.http.HttpServletResponse response)Handles a rejection by sending a 403 HTTP error
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return null;
|
public java.lang.String | intercept(com.opensymphony.xwork2.ActionInvocation invocation)
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
String result = null;
if (!isAllowed(request, invocation.getAction())) {
result = handleRejection(invocation, response);
} else {
result = invocation.invoke();
}
return result;
|
protected boolean | isAllowed(javax.servlet.http.HttpServletRequest request, java.lang.Object action)Determines if the request should be allowed for the action
if (allowedRoles.size() > 0) {
boolean result = false;
for (String role : allowedRoles) {
if (request.isUserInRole(role)) {
result = true;
}
}
return result;
} else if (disallowedRoles.size() > 0) {
for (String role : disallowedRoles) {
if (request.isUserInRole(role)) {
return false;
}
}
}
return true;
|
public void | setAllowedRoles(java.lang.String roles)
this.allowedRoles = stringToList(roles);
|
public void | setDisallowedRoles(java.lang.String roles)
this.disallowedRoles = stringToList(roles);
|
protected java.util.List | stringToList(java.lang.String val)Splits a string into a List
if (val != null) {
String[] list = val.split("[ ]*,[ ]*");
return Arrays.asList(list);
} else {
return Collections.EMPTY_LIST;
}
|