Package com.evasion.entity.security

Examples of com.evasion.entity.security.User


    public void sendEmailWithTemplate(String userName, String templateKey, Map<String, Object> properties) {
        String subject = templateEJB.merge(Constante.PREFIX_EMAIL_TEMPLATE_SUBJECT + templateKey,
                Locale.FRENCH, properties);
        String body = templateEJB.merge(Constante.PREFIX_EMAIL_TEMPLATE_BODY + templateKey,
                Locale.FRENCH, properties);
        User user = userEJB.findUserByUserName(userName);
        if (StringUtils.isBlank(subject) || StringUtils.isBlank(body) || user == null) {
            throw new IllegalArgumentException("Template or User can not be found.");
        } else {
            sendMail(subject, body, user.getEmail());
        }
    }
View Full Code Here


    @edu.umd.cs.findbugs.annotations.SuppressWarnings("UPM_UNCALLED_PRIVATE_METHOD")
    @PostConstruct
    private void init() {
        authorityDAO.setEntityManager(em);
        userDAO.setEntityManager(em);
        User admin = userDAO.findById("admin");
        if (admin == null) {
            LOGGER.error("Restart app to init admin user.");
        }
    }
View Full Code Here

     * {@inheritDoc }
     */
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    @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

    public Account findOrCreateAdminAccount() throws EvasionException {

        Account acc = accountDAO.findAccountByUsername("admin");
        if (acc == null) {
            User admin = userDAO.findById("admin");
            if (admin == null) {
                admin = new User();
                admin.setEnabled(true);
                admin.setUsername("admin");
                admin.setPassword("adminadmin");
                admin.setEmail("admin@localhost");
            }
            Person person = new Individual("", Civilite.monsieur, "admin", "admin", new Date());
            defaultDAO.persist(person);
            acc = new Account(admin, person);
            createAccount(acc);
View Full Code Here

        return acc;
    }

    public void checkOrUpdateAdminAuth() throws EvasionException {
        Authority auth = findOrCreateAdminAuthority();
        User admin = findOrCreateAdminAccount().getUser();
        if (!admin.getAuthorities().contains(auth)) {
            admin.addAuthority(auth);
            updateUser(admin);
        }
    }
View Full Code Here

        }
        return u;
    }

    public User updateUser(User u) {
        final User userBDD = em.find(User.class, u.getUsername());
        LOGGER.debug("Mise à jour du user: {}", u.toString());
        validGrantedAuthority(u);
        if (u.getPassword()!=null && !u.getPassword().isEmpty()) {
            encodPassword(u);
        } else {
            u.setPassword(userBDD.getPassword());
        }
        return em.merge(u);
    }
View Full Code Here

        } else {
        this.getPerson().setEmail(dto.getEmail());
        this.setPerson(dto.getPerson());
        }
        if (this.getUser()==null) {
            this.setUser(new User());
        }
        this.getUser().setUsername(dto.getUsername());
        this.getUser().setPassword(dto.getPassword());
        this.getUser().setEmail(dto.getEmail());
        this.getUser().setEnabled(dto.isEnabled());
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

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.