acegiseurityexceptioni18nutil.java

来自「一个关于tlms的一个小程序 看看能否帮助到别人」· Java 代码 · 共 89 行

JAVA
89
字号
package com.szmx.component.security.acegipro.util;

import org.acegisecurity.*;
import org.acegisecurity.ui.digestauth.NonceExpiredException;
import org.acegisecurity.providers.ldap.LdapDataAccessException;
import org.acegisecurity.providers.ProviderNotFoundException;
import org.acegisecurity.providers.rcp.RemoteAuthenticationException;
import org.acegisecurity.providers.cas.ProxyUntrustedException;
import org.acegisecurity.concurrent.ConcurrentLoginException;
import org.acegisecurity.concurrent.SessionAlreadyUsedException;
import org.acegisecurity.userdetails.UsernameNotFoundException;

/**
 * ================================================================
 * Copyright 2006 szmx
 * <p/>
 * Change Revision
 * ---------------------------------------------------------------
 * Date              Author            Remarks
 * Mar 31, 2006      BZhang     Create class com.szmx.component.security.acegipro.util.AcegiSeurityExceptionI18nUtil
 * ================================================================
 */
public class AcegiSeurityExceptionI18nUtil {

    /**
     * Get Defined i18n Messasge Key.
     *
     * @param acegiEx
     * @return String i18n message key value defined in AcegiproMessages.properties
     * author: Bing Zhang
     */
    public static String getDefinedI18nMessasgeKey(AcegiSecurityException acegiEx) {
        String i18nMessageKey;
        if (acegiEx instanceof AuthenticationException) {
            if (acegiEx instanceof AccountExpiredException) {
                i18nMessageKey = "acegipro.exception.accountExpired";
            } else if (acegiEx instanceof AuthenticationCredentialsNotFoundException) {
                i18nMessageKey = "acegipro.exception.credentialsNotFound";
            } else if (acegiEx instanceof AuthenticationServiceException) {
                if (acegiEx instanceof LdapDataAccessException) {
                    i18nMessageKey = "acegipro.exception.ldapDataAccess";
                } else {
                    i18nMessageKey = "acegipro.exception.authenticationService";
                }
            } else if (acegiEx instanceof BadCredentialsException) {
                if (acegiEx instanceof UsernameNotFoundException) {
                    i18nMessageKey = "acegipro.exception.usernameNotFound";
                } else {
                    i18nMessageKey = "acegipro.exception.badCredentials";
                }
            } else if (acegiEx instanceof ConcurrentLoginException) {
                i18nMessageKey = "acegipro.exception.concurrentLogin";
            } else if (acegiEx instanceof CredentialsExpiredException) {
                i18nMessageKey = "acegipro.exception.credentialsExpired";
            } else if (acegiEx instanceof DisabledException) {
                i18nMessageKey = "acegipro.exception.accountDisabled";
            } else if (acegiEx instanceof InsufficientAuthenticationException) {
                i18nMessageKey = "acegipro.exception.insufficientAuthentication";
            } else if (acegiEx instanceof LockedException) {
                i18nMessageKey = "acegipro.exception.accountLocked";
            } else if (acegiEx instanceof NonceExpiredException) {
                i18nMessageKey = "acegipro.exception.digestNonceExpired";
            } else if (acegiEx instanceof ProviderNotFoundException) {
                i18nMessageKey = "acegipro.exception.providerNotFound";
            } else if (acegiEx instanceof ProxyUntrustedException) {
                i18nMessageKey = "acegipro.exception.proxyUntrusted";
            } else if (acegiEx instanceof SessionAlreadyUsedException) {
                i18nMessageKey = "acegipro.exception.sessionAlreadyUsed";
            } else {
                i18nMessageKey = "acegipro.exception.authentication";
            }
        } else {
            if (acegiEx instanceof AccessDeniedException) {
                if (acegiEx instanceof AuthorizationServiceException) {
                    i18nMessageKey = "acegipro.exception.authorizationService";
                } else {
                    i18nMessageKey = "acegipro.exception.accessDenied";
                }
            } else if (acegiEx instanceof RemoteAuthenticationException) {
                i18nMessageKey = "acegipro.exception.remoteAuthentication";
            } else {
                i18nMessageKey = "acegipro.exception.unkown";
            }
        }

        return i18nMessageKey;
    }
}

⌨️ 快捷键说明

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