Package com.evasion.entity.security

Examples of com.evasion.entity.security.User


    /**
     * 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);
            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());
        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

            }

            if (event instanceof AuthenticationSuccessEvent) {
                AuthenticationSuccessEvent authenticationSuccessEvent = (AuthenticationSuccessEvent) event;
                String username = authenticationSuccessEvent.getAuthentication().getName();
                User user = userAuthService.findUserByUserName(username);
                // sauvergarde en session de la précédente date de connexion
                HttpServletRequest request = (HttpServletRequest) ( (ServletRequestAttributes) RequestContextHolder.getRequestAttributes() ).getRequest();
                request.getSession().setAttribute("lastLogin", user.getLastLogin());
                // mise à jour de la date de connexion.
                userAuthService.updateLastLogin(user.getUsername());
                LOGGER.debug("Validation de l'authentification et mise à jour de la date de dernière connection");
            }

        }
    }
View Full Code Here

            }
            catch (BookTravelServiceException ex) {
                java.util.logging.Logger.getLogger(IndexRoadmapCtrl.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        User user = userEJB.findUserByUserName(Utils.getUserName());
        commentaireNew.setUser(user);

    }
View Full Code Here

    @Override
    public StaticPage createPage(StaticPage page, String userName) throws PersistenceViolationException {
        if (page.getId() != null) {
            throw new PersistenceViolationException("Cette méthode ne peut être utilisé pour une page déja existente");
        }
        User user = userService.findUserByUserName(userName);
        page.setUser(user);
        return savePage(page);
    }
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.