Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* ZkAccessDeniedHandler.java
 
 {{IS_NOTE
 	Purpose:
 		
 	Description:
 		
 	History:
 		Thu Dec 21 16:45:26     2006, Created by Henri
}}IS_NOTE
Copyright (C) 2006 Potix Corporation. All Rights Reserved.
{{IS_RIGHT
}}IS_RIGHT
*/
package org.zkoss.zkplus.acegi;
import  org.acegisecurity.ui.AccessDeniedHandler;
import  org.acegisecurity.ui.AccessDeniedHandlerImpl;
import  org.acegisecurity.AccessDeniedException;
import  javax.servlet.ServletException;
import  javax.servlet.ServletRequest;
import  javax.servlet.ServletResponse;
import  javax.servlet.http.HttpServletRequest;
import  javax.servlet.http.HttpServletResponse;

Used by ExceptionTranslationFilter to handle an AccessDeniedException. This handler will popup the specified error page so it must be a Window that can be doModel.

Author(s):
Henri
public class ZkAccessDeniedHandler implements AccessDeniedHandler {
	private static final String ON_ACCESSDENIED = "onAccessDenied";
	private String _errorPage;
	public void setErrorPage(String url) {
		 = url;
	}
	public String getErrorPage() {
		return ;
	}
    public void handle(ServletRequest request, ServletResponse response, AccessDeniedException accessDeniedException)
        throws IOException, ServletException {
        // Put exception into request scope (perhaps of use to a view)
        ((HttpServletRequest) request).setAttribute(AccessDeniedHandlerImpl.ACEGI_SECURITY_ACCESS_DENIED_EXCEPTION_KEY,
            accessDeniedException);
    	final Component comp = (Componentrequest.getAttribute(.);
		if (!comp.isListenerAvailable(true)) {
			final EventListener listener = new ShowWindowEventListener();
			comp.setAttribute(listener);
		}
		final String url = getErrorPage();
    	Events.postEvent(new Event(compurl != null ? url : "~./accessDenied.zul"));
    }
New to GrepCode? Check out our FAQ X