authorizationauthenticationinterceptor.java

来自「pojo的mvc框架」· Java 代码 · 共 42 行

JAVA
42
字号
package xyz.frame.plugin.login;import xyz.frame.Interceptor;import xyz.frame.LogicException;import xyz.frame.LogicFlow;import xyz.frame.RedirectException;import xyz.frame.view.ViewException;/** * An interceptor capable of redirecting flow in case an authorization or * authentication exception occurs *  * @author Guilherme Silveira */public class AuthorizationAuthenticationInterceptor implements Interceptor {	/**	 * Intercepts and in case of a authentication, authorization exception	 * redirects to some pre-defined logic	 * 	 * @see xyz.frame.Interceptor#intercept(xyz.frame.LogicFlow)	 */	public void intercept(LogicFlow flow) throws LogicException, ViewException {		try {			flow.execute();		} catch (LogicException ex) {			Throwable cause = ex.getCause();			try {				if (cause instanceof AuthenticationException) {					// login/failed.authentication.jsp --> login form					flow.redirect("/login.form.logic?what=authentication");				} else if (cause instanceof AuthorizationException) {					flow.redirect("/login.failed.logic?what=authorization");				}			} catch (RedirectException e) {				throw new LogicException(e.getMessage(), e.getCause());			}		}	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?