本文整理汇总了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());
}
}
示例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());
}
}