Package com.evasion.entity.security

Examples of com.evasion.entity.security.User


    public void deleteUser(User u) {
        em.remove(em.merge(u));
    }

    public User updateUser(User u) {
        final User userBDD = em.find(User.class, u.getUsername());
        LOGGER.debug("Mise à jour du user: {}", u.toString());

        LOGGER.debug("Mise à jour du user: {}", userBDD.getLastLogin());
        UserDetailsAdapter.validGrantedAuthority(u);
        if (!userBDD.getPassword().equals(u.getPassword())) {
            UserDetailsAdapter.encodPassword(u);
        }
        return em.merge(u);
    }
View Full Code Here


        }
        return em.merge(u);
    }

    public void updateLastLogin(String userName) {
        final User userBDD = this.findUserByUserName(userName);

        if (userBDD != null) {
            LOGGER.debug("Mise à jour de la date de dernière conneciton du user {}", userName);
            userBDD.setLastLogin(new Date());
            em.merge(userBDD);
        }
    }
View Full Code Here

    }

    public final UserDetails loadUserByUsername(String login)
            throws PersistenceViolationException {
        try {
            User account = findUserByUserName(login);
            em.flush();
            if (account != null) {
                return new UserDetailsAdapter(account);
            } else {
                return null;
View Full Code Here

            throw new PersistenceViolationException("Erreur lors de l'identification du login '" + login + "' en persistence");
        }
    }

    public User findUserByUserName(String u) {
        User user;
        if (u.equals(USERNAME_ADMIN)) {
            user = initAdminUser();
        } else {
            user = em.find(User.class, u);
        }
View Full Code Here

    /**
     * Initialise de compte administrateur si non present en base.
     * @return
     */
    public User initAdminUser() {
        User user = em.find(User.class, USERNAME_ADMIN);
        if (user == null || user.getPassword() == null ||
                user.getPassword().isEmpty()) {
            HashSet<String> auth = new HashSet<String>();
            auth.add("ROLE_SUPERADMIN");
            auth.add("ROLE_ADMIN");
            user = new User();
            user.setUsername(USERNAME_ADMIN);
            user.setEnabled(true);
            user.setPassword(USERNAME_ADMIN + USERNAME_ADMIN);
            user.setAuthorities(auth);
            UserDetailsAdapter.encodPassword(user);
            user.setEmail("test@test.fr");
            em.merge(user);
        }
        return user;
    }
View Full Code Here

        Query query = em.createNamedQuery(User.FIND_ALL);
        return query.getResultList();
    }

    public User findUserByUserName(String u) {
        User user;
        user = em.find(User.class, u);
        return user;
    }
View Full Code Here

    public void deleteUser(User u) {
        em.remove(em.merge(u));
    }

    public User updateUser(User u) {
        final User userBDD = em.find(User.class, u.getUsername());
        LOGGER.debug("Mise à jour du user: {}", u.toString());

        LOGGER.debug("Mise à jour du user: {}", userBDD.getLastLogin());
        validGrantedAuthority(u);
        if (!userBDD.getPassword().equals(u.getPassword())) {
            encodPassword(u);
        }
        return em.merge(u);
    }
View Full Code Here

    /**
     * {@inheritDoc }
     */
    @Override
    public void postLogin(String userName) {
        final User user = userDAO.findById(userName);
        updateLastLogin(user);
    }
View Full Code Here

    /**
     * {@inheritDoc }
     */
    @Override
    public EvasionPrincipal getEvasionPrincipal(String userName) {
        final User user = userDAO.findById(userName);
        EvasionPrincipal userPrincipal = new EvasionPrincipal(userName);
        userPrincipal.setLastLogin(user.getLastLogin());
        return userPrincipal;
    }
View Full Code Here

    /**
     * {@inheritDoc }
     */
    @Override
    public String getPassword(String userName) {
        final User user = userDAO.findById(userName);
        if (user == null) {
            return null;
        } else {
            return user.getPassword();
        }
    }
View Full Code Here

TOP

Related Classes of com.evasion.entity.security.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.