use of net.sf.acegisecurity.providers.dao.UsernameNotFoundException in project alfresco-repository by Alfresco.
the class RepositoryAuthenticationDao method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String incomingUserName) throws UsernameNotFoundException, DataAccessException {
CacheEntry userEntry = getUserEntryOrNull(incomingUserName);
if (userEntry == null) {
throw new UsernameNotFoundException("Could not find user by userName: " + AuthenticationUtil.maskUsername(incomingUserName));
}
UserDetails userDetails = userEntry.userDetails;
if (userEntry.credentialExpiryDate == null || userEntry.credentialExpiryDate.getTime() >= System.currentTimeMillis()) {
return userDetails;
}
if (userDetails instanceof RepositoryAuthenticatedUser) {
RepositoryAuthenticatedUser repoUser = (RepositoryAuthenticatedUser) userDetails;
return new RepositoryAuthenticatedUser(userDetails.getUsername(), userDetails.getPassword(), userDetails.isEnabled(), userDetails.isAccountNonExpired(), false, userDetails.isAccountNonLocked(), userDetails.getAuthorities(), repoUser.getHashIndicator(), repoUser.getSalt());
}
throw new AlfrescoRuntimeException("Unable to retrieve a compatible UserDetails object (requires RepositoryAuthenticatedUser)");
}
Aggregations