Example usage for org.springframework.security.core.userdetails User isEnabled

List of usage examples for org.springframework.security.core.userdetails User isEnabled

Introduction

In this page you can find the example usage for org.springframework.security.core.userdetails User isEnabled.

Prototype

public boolean isEnabled() 

Source Link

Usage

From source file:com.klm.workshop.security.CustomUserDetails.java

/**
 * Construct user with authorities//from  ww w.  j  av a2  s .  com
 * 
 * @param user The current user
 * @param roles The current user's roles
 */
public CustomUserDetails(com.klm.workshop.model.User user, List<GrantedAuthority> roles) {
    super(user.getEmail(), user.getPassword(), user.isEnabled(), true, true, true, roles);
    this.user = user;
}

From source file:com.saresh.labsproject.security.LPUserDetailsService.java

private UserDetails buildUserForAuthentication(com.saresh.labsproject.entity.User user,
        List<GrantedAuthority> authorities) {
    return new User(user.getLogin(), user.getPassword(), user.isEnabled(), true, true, true, authorities);
}

From source file:co.edu.utb.softeng.springtodos.service.security.MyUserDetailsService.java

private User buildSpringUser(co.edu.utb.softeng.springtodos.entity.security.User user,
        List<GrantedAuthority> authorities) {
    return new User(user.getUsername(), user.getPassword(), user.isEnabled(), true, true, true, authorities);
}

From source file:com.qpark.eip.core.spring.auth.DatabaseUserProvider.java

/**
 * Get a clone of the {@link User}./*from w  w w .  ja  va2 s.c  om*/
 *
 * @param user
 *            the {@link User} to clone.
 * @return the clone.
 */
private User clone(final User user) {
    User c = null;
    if (user != null) {
        c = new User(user.getUsername(), user.getPassword(), user.isEnabled(), user.isAccountNonExpired(),
                user.isCredentialsNonExpired(), user.isAccountNonLocked(), user.getAuthorities());
    }
    return c;
}

From source file:com.bac.accountserviceapp.data.AccountServiceUserDetails.java

public AccountServiceUserDetails(User user, Collection<? extends UserDetailsAuthority> userDetailsAuthorities) {

    if (user != null) {

        userName = user.getUserEmail();//ww w .jav  a 2 s .c  o m
        password = new String(user.getUserPassword());
        enabled = user.isEnabled();
    }

    if (userDetailsAuthorities == null) {
        return;
    }
    for (UserDetailsAuthority uda : userDetailsAuthorities) {
        Application application = uda.getApplication();
        AccessLevel accessLevel = uda.getAccessLevel();
        if (application != null && accessLevel != null) {
            if (application.isEnabled()) {
                String serviceRole = accessLevel.getAccountServiceRole() == null ? "No available role"
                        : accessLevel.getAccountServiceRole().name();
                String authority = String.format(authorityFormat, application.getName(), authoritySeparator,
                        serviceRole);
                authorities.add(new SimpleGrantedAuthority(authority));
            }
        }
    }
}

From source file:org.springframework.security.jackson2.UserDeserializerTests.java

@Test
public void deserializeUserWithNullPasswordNoAuthorityTest() throws IOException {
    String userJsonWithoutPasswordString = "{\"@class\": \"org.springframework.security.core.userdetails.User\", "
            + "\"username\": \"user\", \"accountNonExpired\": true, "
            + "\"accountNonLocked\": true, \"credentialsNonExpired\": true, \"enabled\": true, "
            + "\"authorities\": [\"java.util.HashSet\", []]}";
    ObjectMapper mapper = buildObjectMapper();
    User user = mapper.readValue(userJsonWithoutPasswordString, User.class);
    assertThat(user).isNotNull();// ww w  .  j a v  a 2  s  .c  o  m
    assertThat(user.getUsername()).isEqualTo("user");
    assertThat(user.getPassword()).isEqualTo("");
    assertThat(user.getAuthorities()).hasSize(0);
    assertThat(user.isEnabled()).isEqualTo(true);
}

From source file:org.parancoe.plugins.securityevolution.ParancoeUserDetailsService.java

@Override
public UserDetails loadUserByUsername(java.lang.String username)
        throws UsernameNotFoundException, DataAccessException {

    org.parancoe.plugins.securityevolution.User user = userDao.findByUsername(username);

    if (user == null)
        throw new UsernameNotFoundException("username " + username + " not found in the system");

    List<Authority> authorities = authorityDao.findAllAuthoritiesAssociatedToUsername(username);
    return new User(user.getUsername(), user.getPassword(), user.isEnabled(), true, true, !user.isLocked(),
            authorities2GrantedAuthorities(authorities));
}

From source file:fr.xebia.springframework.security.core.userdetails.jdbc.ExtendedJdbcUserDetailsManager.java

@Override
protected UserDetails createUserDetails(String username, UserDetails userFromUserQuery,
        List<GrantedAuthority> combinedAuthorities) {
    final User user = (User) super.createUserDetails(username, userFromUserQuery, combinedAuthorities);
    List<UserDetails> users = getJdbcTemplate().query(selectUserExtraColumns, new String[] { username },
            new RowMapper<UserDetails>() {
                public UserDetails mapRow(ResultSet rs, int rowNum) throws SQLException {
                    ExtendedUser extendedUser = new ExtendedUser(user.getUsername(), user.getPassword(),
                            user.isEnabled(), user.isAccountNonExpired(), user.isCredentialsNonExpired(),
                            user.isAccountNonLocked(), user.getAuthorities());
                    extendedUser.setAllowedRemoteAddresses(rs.getString(1));
                    extendedUser.setComments(rs.getString(2));

                    return extendedUser;
                }/*  w ww.  j  a  v  a2 s. c om*/
            });
    if (users.size() == 0) {
        throw new UsernameNotFoundException(messages.getMessage("JdbcDaoImpl.notFound",
                new Object[] { username }, "Username {0} not found"), username);
    }
    return users.get(0);
}

From source file:org.taverna.server.master.identity.UserStore.java

/**
 * Get information about a server account.
 * //from  w w w. java  2  s  .c o  m
 * @param userName
 *            The username to look up.
 * @return A description map intended for use by a server admin over JMX.
 */
@WithinSingleTransaction
@ManagedOperation(description = "Get information about a server account.")
@ManagedOperationParameters(@ManagedOperationParameter(name = "userName", description = "The username to look up."))
public Map<String, String> getUserInfo(String userName) {
    User u = getById(userName);
    Map<String, String> info = new HashMap<String, String>();
    info.put("name", u.getUsername());
    info.put("admin", u.isAdmin() ? "yes" : "no");
    info.put("enabled", u.isEnabled() ? "yes" : "no");
    info.put("localID", u.getLocalUsername());
    return info;
}