当前位置: 首页>>代码示例>>Java>>正文


Java DisabledException类代码示例

本文整理汇总了Java中net.sf.acegisecurity.DisabledException的典型用法代码示例。如果您正苦于以下问题:Java DisabledException类的具体用法?Java DisabledException怎么用?Java DisabledException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DisabledException类属于net.sf.acegisecurity包,在下文中一共展示了DisabledException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUserDetails

import net.sf.acegisecurity.DisabledException; //导入依赖的package包/类
/**
 * Explicitly set the given validated user details to be authenticated.
 * 
 * @param ud
 *            the User Details
 * @return Authentication
 */
public Authentication setUserDetails(UserDetails ud)
{
    try
    {
        // Apply the same validation that ACEGI would have to the user details - we may be going through a 'back
        // door'.
        if (!ud.isEnabled())
        {
            throw new DisabledException("User is disabled");
        }
        if (!ud.isAccountNonExpired())
        {
            throw new AccountExpiredException("User account has expired");
        }
        if (!ud.isAccountNonLocked())
        {
            throw new LockedException("User account is locked");
        }
        if (!ud.isCredentialsNonExpired())
        {
            throw new CredentialsExpiredException("User credentials have expired");
        }
        UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(ud, "", ud
                .getAuthorities());
        auth.setDetails(ud);
        auth.setAuthenticated(true);
        return setCurrentAuthentication(auth);
    }
    catch (net.sf.acegisecurity.AuthenticationException ae)
    {
        throw new AuthenticationException(ae.getMessage(), ae);
    }
    finally
    {
        // Support for logging tenantdomain / username (via log4j NDC)
        AuthenticationUtil.logNDC(ud.getUsername());
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:46,代码来源:AuthenticationContextImpl.java

示例2: setUserDetails

import net.sf.acegisecurity.DisabledException; //导入依赖的package包/类
/**
 * Explicitly set the given validated user details to be authenticated.
 * 
 * @param ud
 *            the User Details
 * @return Authentication
 */
public Authentication setUserDetails(UserDetails ud)
{
    String userId = ud.getUsername();

    try
    {
        // Apply the same validation that ACEGI would have to the user details - we may be going through a 'back
        // door'.
        if (!ud.isEnabled())
        {
            throw new DisabledException("User is disabled");
        }
        if (!ud.isAccountNonExpired())
        {
            throw new AccountExpiredException("User account has expired");
        }
        if (!ud.isAccountNonLocked())
        {
            throw new LockedException("User account is locked");
        }
        if (!ud.isCredentialsNonExpired())
        {
            throw new CredentialsExpiredException("User credentials have expired");
        }
        UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(ud, "", ud
                .getAuthorities());
        auth.setDetails(ud);
        auth.setAuthenticated(true);
        return setCurrentAuthentication(auth);
    }
    catch (net.sf.acegisecurity.AuthenticationException ae)
    {
        if (logger.isWarnEnabled())
        {
            // Shows only first 2 symbols of the username and masks all other character with '*' [see also ProtectedUser]
            StringBuilder sb = new StringBuilder();
            sb.append(ae.getMessage());
            sb.append(" [");
            sb.append(userId.substring(0,2));
            sb.append(new String(new char[(userId.length() - 2)]).replace("\0", "*"));
            sb.append("] - cannot set details for user");

            logger.warn(sb.toString());
        }
        throw new AuthenticationException(ae.getMessage(), ae);
    }
    finally
    {
        // Support for logging tenantdomain / username (via log4j NDC)
        AuthenticationUtil.logNDC(ud.getUsername());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:60,代码来源:AuthenticationContextImpl.java


注:本文中的net.sf.acegisecurity.DisabledException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。