?? authenticationexceptionmessageconvertor.java
字號:
/*
* Copyright 2005-2010 the original author or autors
*
* http://www.skyon.com.cn
*
* Project { SkyonFramework }
*/
package com.skyon.um.security.acegi.webwork;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpSession;
import net.sf.acegisecurity.AuthenticationException;
import net.sf.acegisecurity.ui.AbstractProcessingFilter;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.LocaleProvider;
import com.opensymphony.xwork.TextProvider;
import com.opensymphony.xwork.TextProviderSupport;
import com.skyon.framework.web.webwork.interceptor.ExceptionHandlerInterceptor;
/**
*
* @since 2005-8-8
* @author 王政
* @version $Id: AuthenticationExceptionMessageConvertor.java,v 1.1 2005/08/25 08:04:17 wangzheng Exp $
*/
public class AuthenticationExceptionMessageConvertor {
private static TextProvider textProvider = new TextProviderSupport(AuthenticationExceptionMessageConvertor.class, new LocaleProvider() {
public Locale getLocale() {
return (ActionContext.getContext() != null) ? ActionContext.getContext().getLocale() : null;
}
});
public static String getAuthenticationExceptionMessage(HttpSession session) {
Object o = session.getAttribute(AbstractProcessingFilter.ACEGI_SECURITY_LAST_EXCEPTION_KEY);
if (o == null) {
return null;
}
if (! AuthenticationException.class.isInstance(o)) {
StringBuffer sb = new StringBuffer();
sb.append(" HttpSession Key : ");
sb.append(AbstractProcessingFilter.ACEGI_SECURITY_LAST_EXCEPTION_KEY);
sb.append(" should contain the type : ");
sb.append(AuthenticationException.class);
sb.append(" , but it now contain a type of : ");
sb.append(o.getClass());
sb.append(" . Please make sure your applicaiton hasn't use this session key ");
throw new IllegalStateException(sb.toString());
}
AuthenticationException exception = (AuthenticationException) o;
List args = new LinkedList();
args.add(exception.getMessage());
return ExceptionHandlerInterceptor.getDisplayText(exception, textProvider, args);
}
public static void main(String[] args) {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -