/**
* Tests the status of the LDAP details and throws an appropriate exception.
*
* @param dirContextOperations
* The context containing user data.
* @param username
* The username.
* @throws AuthenticationException
* if the status would prevent logging in
*/
private void checkAccountStatus(DirContextOperations dirContextOperations, String username)
throws AuthenticationException {
UserDetails ldapDetails = new LdapUserDetailsMapper()
.mapUserFromContext(dirContextOperations, username,
new ArrayList<GrantedAuthority>());
if (!ldapDetails.isEnabled()) {
throw new DisabledException("LDAP account is disabled.");
}
if (!ldapDetails.isAccountNonLocked()) {
throw new LockedException("LDAP account is locked.");
}
if (!ldapDetails.isCredentialsNonExpired()) {
throw new CredentialsExpiredException("Credentials for LDAP account are expired.");
}
if (!ldapDetails.isAccountNonExpired()) {
throw new AccountExpiredException("LDAP account is expired.");
}
}
LdapAuthenticator.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:communote-server
作者:
评论列表
文章目录