org.acegisecurity.userdetails.ldap.LdapUserDetails Java Examples
The following examples show how to use
org.acegisecurity.userdetails.ldap.LdapUserDetails.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubsonicLdapBindAuthenticator.java From subsonic with GNU General Public License v3.0 | 5 votes |
public LdapUserDetails authenticate(String username, String password) { // LDAP authentication must be enabled on the system. if (!settingsService.isLdapEnabled()) { throw new BadCredentialsException("LDAP authentication disabled."); } // User must be defined in Subsonic, unless auto-shadowing is enabled. User user = securityService.getUserByName(username); if (user == null && !settingsService.isLdapAutoShadowing()) { throw new BadCredentialsException("User does not exist."); } // LDAP authentication must be enabled for the given user. if (user != null && !user.isLdapAuthenticated()) { throw new BadCredentialsException("LDAP authentication disabled for user."); } try { createDelegate(); LdapUserDetails details = delegateAuthenticator.authenticate(username, password); if (details != null) { LOG.info("User '" + username + "' successfully authenticated in LDAP. DN: " + details.getDn()); if (user == null) { User newUser = new User(username, "", null, true, 0L, 0L, 0L); newUser.setStreamRole(true); newUser.setSettingsRole(true); securityService.createUser(newUser); LOG.info("Created local user '" + username + "' for DN " + details.getDn()); } } return details; } catch (RuntimeException x) { LOG.info("Failed to authenticate user '" + username + "' in LDAP.", x); throw x; } }
Example #2
Source File: LdapUserDetailsService.java From rice with Educational Community License v2.0 | 5 votes |
public UserDetails loadUserByUsername(String username) { LdapUserDetails ldapUserDetails = ldapUserSearch.searchForUser(username); GrantedAuthority[] authorities = ldapAuthoritiesPopulator.getGrantedAuthorities(ldapUserDetails); return new User(username, "empty_password", true, true, true, true, authorities); }
Example #3
Source File: UserDetailsServiceBasedAuthoritiesPopulator.java From subsonic with GNU General Public License v3.0 | 4 votes |
public GrantedAuthority[] getGrantedAuthorities(LdapUserDetails userDetails) throws LdapDataAccessException { UserDetails details = userDetailsService.loadUserByUsername(userDetails.getUsername()); return details.getAuthorities(); }
Example #4
Source File: WCTAuthoritiesPopulator.java From webcurator with Apache License 2.0 | 4 votes |
/** @see LdapAuthoritiesPopulator#getGrantedAuthorities(LdapUserDetails) .*/ public GrantedAuthority[] getGrantedAuthorities(LdapUserDetails userDetails) throws LdapDataAccessException { return getGrantedAuthorities(userDetails.getUsername()); }