List of usage examples for org.springframework.security.ldap.authentication.ad ActiveDirectoryLdapAuthenticationProvider setUseAuthenticationRequestCredentials
public void setUseAuthenticationRequestCredentials(boolean useAuthenticationRequestCredentials)
From source file:org.apache.atlas.web.security.AtlasADAuthenticationProvider.java
private Authentication getADAuthentication(Authentication authentication) { try {/*w w w . j av a 2 s .com*/ String userName = authentication.getName(); String userPassword = ""; if (authentication.getCredentials() != null) { userPassword = authentication.getCredentials().toString(); } ActiveDirectoryLdapAuthenticationProvider adAuthenticationProvider = new ActiveDirectoryLdapAuthenticationProvider( adDomain, adURL); adAuthenticationProvider.setConvertSubErrorCodesToExceptions(true); adAuthenticationProvider.setUseAuthenticationRequestCredentials(true); if (userName != null && userPassword != null && !userName.trim().isEmpty() && !userPassword.trim().isEmpty()) { final List<GrantedAuthority> grantedAuths = getAuthorities(userName); final UserDetails principal = new User(userName, userPassword, grantedAuths); final Authentication finalAuthentication = new UsernamePasswordAuthenticationToken(principal, userPassword, grantedAuths); authentication = adAuthenticationProvider.authenticate(finalAuthentication); if (groupsFromUGI) { authentication = getAuthenticationWithGrantedAuthorityFromUGI(authentication); } return authentication; } else { LOG.error("AD Authentication Failed userName or userPassword is null or empty"); return null; } } catch (Exception e) { LOG.error("AD Authentication Failed:", e); return null; } }