protected UserDetails attemptToImpersonate(String username, RuntimeException e) { // this backend cannot tell if the user name exists or not. so substitute by what we know User u = User.getById(username, false); if (u!=null) { LastGrantedAuthoritiesProperty p = u.getProperty(LastGrantedAuthoritiesProperty.class); if (p!=null) return new org.acegisecurity.userdetails.User(username,"",true,true,true,true, p.getAuthorities()); } throw e; } }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { return new org.acegisecurity.userdetails.User(username,"",true,true,true,true,new GrantedAuthority[]{AUTHENTICATED_AUTHORITY}); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { return new org.acegisecurity.userdetails.User(username,"",true,true,true,true,new GrantedAuthority[]{AUTHENTICATED_AUTHORITY}); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { return new org.acegisecurity.userdetails.User(username,"",true,true,true,true,new GrantedAuthority[]{AUTHENTICATED_AUTHORITY}); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>(); auths.add(AUTHENTICATED_AUTHORITY); Set<String> groups = groupsByUser.get(username); if (groups != null) { for (String g : groups) { auths.add(new GrantedAuthorityImpl(g)); } } return new org.acegisecurity.userdetails.User(username,"",true,true,true,true, auths.toArray(new GrantedAuthority[auths.size()])); }
protected Object mapRow(ResultSet rs, int rownum) throws SQLException { String username = rs.getString(1); String password = rs.getString(2); boolean enabled = rs.getBoolean(3); UserDetails user = new User(username, password, enabled, true, true, true, new GrantedAuthority[] {new GrantedAuthorityImpl("HOLDER")}); return user; } }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { if(!UnixUser.exists(username)) throw new UsernameNotFoundException("No such Unix user: "+username); // return some dummy instance return new User(username,"",true,true,true,true, new GrantedAuthority[]{AUTHENTICATED_AUTHORITY}); } }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { doDelay(); final Set<String> groups = usersAndGroups().get(username); if (groups == null) { throw new UsernameNotFoundException(username); } List<GrantedAuthority> gs = new ArrayList<GrantedAuthority>(); gs.add(AUTHENTICATED_AUTHORITY); for (String g : groups) { gs.add(new GrantedAuthorityImpl(g)); } return new User(username, "", true, true, true, true, gs.toArray(new GrantedAuthority[gs.size()])); }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { if(!UnixUser.exists(username)) throw new UsernameNotFoundException("No such Unix user: "+username); // return some dummy instance return new User(username,"",true,true,true,true, new GrantedAuthority[]{AUTHENTICATED_AUTHORITY}); } }
protected UserDetails attemptToImpersonate(String username, RuntimeException e) { // this backend cannot tell if the user name exists or not. so substitute by what we know User u = User.getById(username, false); if (u!=null) { LastGrantedAuthoritiesProperty p = u.getProperty(LastGrantedAuthoritiesProperty.class); if (p!=null) return new org.acegisecurity.userdetails.User(username,"",true,true,true,true, p.getAuthorities()); } throw e; } }
public static UserMap addUsersFromProperties(UserMap userMap, Properties props) { // Now we have properties, process each one individually UserAttributeEditor configAttribEd = new UserAttributeEditor(); for (Iterator iter = props.keySet().iterator(); iter.hasNext();) { String username = (String) iter.next(); String value = props.getProperty(username); // Convert value to a password, enabled setting, and list of granted authorities configAttribEd.setAsText(value); UserAttribute attr = (UserAttribute) configAttribEd.getValue(); // Make a user object, assuming the properties were properly provided if (attr != null) { UserDetails user = new User(username, attr.getPassword(), attr.isEnabled(), true, true, true, attr.getAuthorities()); userMap.addUser(user); } } return userMap; }
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()); addCustomAuthorities(user.getUsername(), dbAuths); if (dbAuths.size() == 0) { throw new UsernameNotFoundException("User has no GrantedAuthority"); } GrantedAuthority[] arrayAuths = (GrantedAuthority[]) dbAuths.toArray(new GrantedAuthority[dbAuths.size()]); String returnUsername = user.getUsername(); if (!usernameBasedPrimaryKey) { returnUsername = username; } return new User(returnUsername, user.getPassword(), user.isEnabled(), true, true, true, arrayAuths); }