public class UserRoleAuthorizationInterceptor extends Object implements com.opensymphony.xwork2.interceptor.Interceptor
Constructor and Description |
---|
UserRoleAuthorizationInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
This method currently does nothing.
|
protected void |
handleNotAuthorized(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handle a request that is not authorized according to this interceptor.
|
void |
init()
This method currently does nothing.
|
String |
intercept(com.opensymphony.xwork2.ActionInvocation invocation)
Intercept the action invocation and check to see if the user has the
proper role.
|
void |
setAuthorizedRoles(String[] authorizedRoles)
Set the roles that this interceptor should treat as authorized.
|
public String intercept(com.opensymphony.xwork2.ActionInvocation invocation) throws Exception
intercept
in interface com.opensymphony.xwork2.interceptor.Interceptor
invocation
- the current action invocationException
- when setting the error on the response failspublic final void setAuthorizedRoles(String[] authorizedRoles)
authorizedRoles
- array of role namesprotected void handleNotAuthorized(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
This method can be overridden to write a custom message, forward or redirect to some error page or login page, or throw a ServletException.
request
- current HTTP requestresponse
- current HTTP responsejavax.servlet.ServletException
- if there is an internal errorIOException
- in case of an I/O error when writing the responsepublic void destroy()
destroy
in interface com.opensymphony.xwork2.interceptor.Interceptor
public void init()
init
in interface com.opensymphony.xwork2.interceptor.Interceptor
Copyright © 2015. All rights reserved.