Search in sources :

Example 1 with ExtendedUser

use of eu.esdihumboldt.hale.server.security.util.impl.ExtendedUser in project hale by halestudio.

the class UserDetailsServiceImpl method createUserDetails.

// private boolean usingOpenID() {
// return System.getProperty(BaseWebApplication.SYSTEM_PROPERTY_LOGIN_PAGE, "false")
// .toLowerCase().equals("openid");
// }
/**
 * Create user details for a given user.
 *
 * @param user the user
 * @param newUser if the user is a newly created user
 * @return the user details
 */
private UserDetails createUserDetails(User user, boolean newUser) {
    Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
    // every user has the user role
    authorities.add(new SimpleGrantedAuthority(ROLE_USER));
    if (configurationService != null) {
        boolean admin = configurationService.getBoolean("user." + user.getLogin() + ".admin", false);
        if (admin) {
            authorities.add(new SimpleGrantedAuthority(ROLE_ADMIN));
        }
    }
    ExtendedUser userDetails = new ExtendedUser(user.getLogin(), user.getPassword(), true, true, true, true, authorities);
    userDetails.setNewUser(newUser);
    return userDetails;
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) ExtendedUser(eu.esdihumboldt.hale.server.security.util.impl.ExtendedUser) HashSet(java.util.HashSet)

Aggregations

ExtendedUser (eu.esdihumboldt.hale.server.security.util.impl.ExtendedUser)1 HashSet (java.util.HashSet)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1