org.acegisecurity.userdetails.User Java Examples
The following examples show how to use
org.acegisecurity.userdetails.User.
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: DaoSupportImpl.java From ramus with GNU General Public License v3.0 | 6 votes |
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { com.ramussoft.net.common.User user = getUserFactory().getUser(username); if (user == null) { throw new UsernameNotFoundException(MessageFormat.format( "User {0} not found", username)); } List<Group> list = user.getGroups(); GrantedAuthority[] arrayAuths = new GrantedAuthority[list.size() + 1]; for (int i = 0; i < list.size(); i++) { arrayAuths[i] = new GrantedAuthorityImpl("ROLE_" + list.get(i).getName().toUpperCase()); } arrayAuths[list.size()] = new GrantedAuthorityImpl("ROLE_USER"); return new User(user.getLogin(), user.getPassword(), true, true, true, true, arrayAuths); }
Example #2
Source File: WCTDAOAuthenticationProvider.java From webcurator with Apache License 2.0 | 6 votes |
protected Object mapRow(ResultSet rs, int rownum) throws SQLException { String username = rs.getString(1); String password = rs.getString(2); boolean enabled = rs.getBoolean(3); boolean credentialsNonExpired = rs.getBoolean(4); if (password == null) { //set the password to blank for users authenticated by an external Authentication source password = ""; } UserDetails user = new User(username, password, enabled, true, !credentialsNonExpired, true, new GrantedAuthority[] {new GrantedAuthorityImpl("HOLDER")}); return user; }
Example #3
Source File: WCTDAOAuthenticationProvider.java From webcurator with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { List users = usersByUsernameMapping.execute(username); if (users.size() == 0) { throw new UsernameNotFoundException("User not found"); } UserDetails user = (UserDetails) users.get(0); // contains no GrantedAuthority[] List dbAuths = authoritiesByUsernameMapping.execute(user.getUsername()); if (dbAuths.size() == 0) { throw new UsernameNotFoundException("User has no GrantedAuthority"); } GrantedAuthority[] arrayAuths = {}; addCustomAuthorities(user.getUsername(), dbAuths); arrayAuths = (GrantedAuthority[]) dbAuths.toArray(arrayAuths); String returnUsername = user.getUsername(); if (!isUsernameBasedPrimaryKey()) { returnUsername = username; } return new User(returnUsername, user.getPassword(), user.isEnabled(), true, true, true, arrayAuths); }
Example #4
Source File: KualiUserDetailsServiceImpl.java From rice with Educational Community License v2.0 | 5 votes |
/** * This method is necessary for loading users by the ticket response * * @param username * @param authorities * @return the UserDetails */ public UserDetails loadUserByUsernameAndAuthorities(String username, GrantedAuthority[] authorities) { if (logger.isDebugEnabled()) { logger.debug("loadUserByUsernameAndAuthorities"); } GrantedAuthority[] newAuthorities = new GrantedAuthority[authorities.length+1]; System.arraycopy(authorities, 0, newAuthorities, 0, authorities.length); newAuthorities[authorities.length]= new GrantedAuthorityImpl("ROLE_KUALI_USER"); logger.warn("setting granted authorities:" + newAuthorities.toString()); UserDetails user = new User(username, "empty_password", true, true, true, true, newAuthorities); return user; }
Example #5
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); }