Package org.apache.mailreaderjpa

Examples of org.apache.mailreaderjpa.User


     * @param username Username to authenticate
     * @param password Password to authenticate
     */
    public User authenticate(String username, String password) {

        User user = findUserByUsername(username);
        if ((user != null)
            && user.getPassword().equals(password)) {
            return user;
        } else {
            return null;
        }

View Full Code Here


            Protocol protocol2 = new Protocol();
            protocol2.setDescription("POP3 Protocol");
            em.persist(protocol2);

            // Set up the initial user and subscriptions
            User user = new User();
            user.setUsername("user");
            user.setPassword("pass");
            user.setFullName("John Q. User");
            user.setFromAddress("John.User@somewhere.com");
            List<Subscription> list = new ArrayList<Subscription>();
            user.setSubscriptions(list);
            Subscription sub = null;
            sub = new Subscription();
            sub.setUser(user);
            sub.setHost("mail.yahoo.com");
            sub.setProtocol(protocol1);
View Full Code Here

        EntityManager em = entityManager();
        EntityTransaction et = null;
        try {
            et = em.getTransaction();
            et.begin();
            User user = em.find(User.class, subscription.getUser().getId());
            user.addSubscription(subscription);
            em.persist(subscription);
            et.commit();
        } catch (Exception e) {
            log("Exception in createSubscription()", e);
            throw new PersistenceException(e);
View Full Code Here

        EntityManager em = entityManager();
        EntityTransaction et = null;
        try {
            et = em.getTransaction();
            et.begin();
            User user = em.find(User.class, subscription.getUser().getId());
            user.removeSubscription(subscription);
            subscription = em.merge(subscription);
            em.remove(subscription);
            et.commit();
        } catch (Exception e) {
            log("Exception in deleteSubscription()", e);
View Full Code Here

     * @param username Username to look up
     */
    public User findUserByUsername(String username) {

        EntityManager em = entityManager();
        User user = null;
        try {
            Query query = em.createNamedQuery(USERNAME_QUERY);
            query.setParameter("username", username);
            user = (User) query.getSingleResult();
            return user;
View Full Code Here

     * <p>Handle a request to log this user on.</p>
     */
    public String logon() {

        try {
            User user = getLogic().authenticate(getUsername(), getPassword());
            if (user != null) {
                if (user.getPassword().equals(getPassword())) {
                    getState().setUser(user);
                    return "success";
                }
            }
        } catch (Exception e) {
View Full Code Here

        String mode = (String) retrieveData(MODE_KEY);
        if (mode != null) {
            setMode(mode);
        }

        User user = (User) retrieveData(USER_KEY);
        if (user != null) {
            this.user = user;
        } else {
            setup();
        }
View Full Code Here

    public String save() {

        // Special handling for unique username checking on a CREATE transaction
        if (Constants.CREATE_MODE.equals(getMode())) {
            try {
                User existing = getLogic().findUserByUsername(getUser().getUsername());
                if (existing != null) {
                    error("Username '" + getUser().getUsername() + "' is already in use, please try again");
                    return null;
                }
            } catch (Exception e) {
View Full Code Here

     * by re-finding the currently logged on user (if any), or by creating
     * a new instance.</p>
     */
    private void setup() {

        User current = getState().getUser();
        if (current == null) {
            this.user = new User();
            return;
        } else {
            this.user = getLogic().findUserById(current.getId());
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.mailreaderjpa.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.