⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authenticationexceptionmessageconvertor.java

📁 ACEGI数据库保存 ACEGI数据库保存 ACEGI数据库保存
💻 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 + -