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 boolean equals(Object rhs) { if (!(rhs instanceof User) || (rhs == null)) { return false; } User user = (User) rhs; // We rely on constructor to guarantee any User has non-null and >0 // authorities if (user.getAuthorities().length != this.getAuthorities().length) { return false; } for (int i = 0; i < this.getAuthorities().length; i++) { if (!this.getAuthorities()[i].equals(user.getAuthorities()[i])) { return false; } } // We rely on constructor to guarantee non-null username and password return (this.getPassword().equals(user.getPassword()) && this.getUsername().equals(user.getUsername()) && (this.isAccountNonExpired() == user.isAccountNonExpired()) && (this.isAccountNonLocked() == user.isAccountNonLocked()) && (this.isCredentialsNonExpired() == user.isCredentialsNonExpired()) && (this.isEnabled() == user.isEnabled())); }
super.setAuthorities(authorities); StringBuilder sb = new StringBuilder(); sb.append(super.toString()).append(": "); sb.append("Username: ").append(getUsername()).append("; "); sb.append("Password: [PROTECTED]; ");
this.credentialsNonExpired = credentialsNonExpired; this.accountNonLocked = accountNonLocked; setAuthorities(authorities);
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ActiveDirectoryUserDetail)) return false; if (!super.equals(o)) return false; ActiveDirectoryUserDetail that = (ActiveDirectoryUserDetail)o; if (displayName != null ? !displayName.equals(that.displayName) : that.displayName != null) { return false; } if (mail != null ? !mail.equals(that.mail) : that.mail != null) { return false; } if (telephoneNumber != null ? !telephoneNumber.equals(that.telephoneNumber) : that.telephoneNumber != null) { return false; } return !(toStringValue != null ? !toStringValue.equals(that.toStringValue) : that.toStringValue != null); }
public String toString() { StringBuffer sb = new StringBuffer(); sb.append(super.toString()).append(": "); sb.append("Username: ").append(this.username).append("; "); sb.append("Password: [PROTECTED]; "); sb.append("Enabled: ").append(this.enabled).append("; "); sb.append("AccountNonExpired: ").append(this.accountNonExpired).append("; "); sb.append("credentialsNonExpired: ").append(this.credentialsNonExpired).append("; "); sb.append("AccountNonLocked: ").append(this.accountNonLocked).append("; "); if (this.getAuthorities() != null) { sb.append("Granted Authorities: "); for (int i = 0; i < this.getAuthorities().length; i++) { if (i > 0) { sb.append(", "); } sb.append(this.getAuthorities()[i].toString()); } } else { sb.append("Not granted any authorities"); } return sb.toString(); } }
public int hashCode() { int code = 9792; if (this.getAuthorities() != null) { for (int i = 0; i < this.getAuthorities().length; i++) { code = code * (this.getAuthorities()[i].hashCode() % 7); } } if (this.getPassword() != null) { code = code * (this.getPassword().hashCode() % 7); } if (this.getUsername() != null) { code = code * (this.getUsername().hashCode() % 7); } if (this.isAccountNonExpired()) { code = code * -2; } if (this.isAccountNonLocked()) { code = code * -3; } if (this.isCredentialsNonExpired()) { code = code * -5; } if (this.isEnabled()) { code = code * -7; } return code; }
@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}); } }
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()])); }
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); }