Package org.jboss.seam.examples.seamcrm.user

Examples of org.jboss.seam.examples.seamcrm.user.User


        if (!Strings.isNullOrEmpty(credentials.getUsername())) {
            log.info("Authenticating: \"" + credentials.getUsername() + "\"");

            try {
                User u = em.createQuery("from User u join fetch u.contact where u.contact.emailAddress=:username", User.class)
                        .setParameter("username", credentials.getUsername()).getSingleResult();

                if (u != null) {
                    PasswordCredential password = (PasswordCredential) credentials.getCredential();
                    String hashedPassword = securityUtil.hash(u, password.getValue());
                    if (hashedPassword.equals(u.getPassword())) {
                        loginEvent.fire(u);
                        u.setDateLastLogin(new Date());
                        setUser(new SimpleUser(u.getContact().getEmailAddress()));
                        setStatus(AuthenticationStatus.SUCCESS);
                        eventLog.fire(new EventLog(u, "User Logged In"));
                    } else {
                        messages.info("Incorrect Password");
                        setStatus(AuthenticationStatus.FAILURE);
View Full Code Here


    c.setTimeZone(TimeZone.MST7MDT);
      c.setAccount(widgets);

    em.persist(c);

    User u = new User();
    u.setDateCreated(CalendarTools.nowNoMilliseconds());
    String hash = securityUtil.hash(u, "seamrocks");
    u.setPassword(hash);
    u.setContact(c);

    em.persist(u);
  }
View Full Code Here

    c.setTimeZone(TimeZone.MST7MDT);
    c.setAccount(widgets);

    em.persist(c);

    User u = new User();
    u.setDateCreated(CalendarTools.nowNoMilliseconds());
    u.setPassword(securityUtil.hash(u, "demo"));
    u.setContact(c);

    em.persist(u);
  }
View Full Code Here

TOP

Related Classes of org.jboss.seam.examples.seamcrm.user.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.