Examples of JpaUser


Examples of org.apache.james.user.jpa.model.JPAUser

    public boolean addUser(String username, String password) {
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        final EntityTransaction transaction = entityManager.getTransaction();
        try {
            transaction.begin();
            JPAUser user = new JPAUser(username, password, algo);
            entityManager.persist(user);
            transaction.commit();
            return true;
        } catch (PersistenceException e) {
            logger.debug("Failed to save user", e);
View Full Code Here

Examples of org.apache.james.user.jpa.model.JPAUser

        }
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        final EntityTransaction transaction = entityManager.getTransaction();
        try {
            transaction.begin();
            JPAUser user = new JPAUser(lowerCasedUsername, password, algo);
            entityManager.persist(user);
            transaction.commit();
        } catch (PersistenceException e) {
            getLogger().debug("Failed to save user", e);
            if (transaction.isActive()) {
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

    public Class<User> getSourceType() {
        return User.class;
    }

    private JpaUser createEntity(User source) {
        JpaUser converted = null;
        if (source != null) {
            converted = new JpaUser();
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

        Authority authority = repository.getByAuthority(authorityName);
        assertNotNull(authority);
        assertEquals(authorityName, authority.getAuthority());
        assertTrue(authority.getUsers().isEmpty());

        User newUser = new JpaUser();
        newUser.setUsername("adminuser");
        newUser.addAuthority(authority);
        newUser = userRepository.save(newUser);
        assertEquals(authority, newUser.getAuthorities().iterator().next());

        authority = repository.getByAuthority(authorityName);
        assertEquals(1, authority.getUsers().size());
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

        assertThat(user, is(nullValue()));
    }

    @Test
    public void getByUsername_valid() {
        JpaUser user = (JpaUser)repository.getByUsername(USER_NAME);
        assertThat(user, notNullValue());
        assertThat(user.getEntityId(), is(equalTo(USER_ID)));
        assertThat(true, is(passwordEncoder.matches(USER_NAME, user.getPassword())));
        assertThat(user.isAccountNonExpired(), is(true));
        assertThat(user.getEmail(), is(equalTo(USER_EMAIL)));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

        assertThat(user, is(nullValue()));
    }

    @Test
    public void getByUserEmail_valid() {
        JpaUser user = (JpaUser)repository.getByUserEmail(USER_EMAIL);
        assertThat(user, notNullValue());
        assertThat(user.getEntityId(), is(equalTo(USER_ID)));
        assertThat(true, is(passwordEncoder.matches(USER_NAME, user.getPassword())));
        assertThat(user.isAccountNonExpired(), is(true));
        assertThat(user.getEmail(), is(equalTo(USER_EMAIL)));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

        assertThat(user.getEmail(), is(equalTo(USER_EMAIL)));
    }
   
    @Test
    public void getByOpenId_valid() {
        JpaUser user = (JpaUser)repository.getByOpenId(OPENID);
        assertThat(user, notNullValue());
        assertThat(user.getEntityId(), is(equalTo(USER_ID_OPENID_USER)));
        assertThat(user.isAccountNonExpired(), is(true));
        assertThat(user.getOpenId(), is(equalTo(OPENID)));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

    public void addOrDeleteUserDoesNotAffectAuthority() {
        Authority authority = authorityRepository.get("1");
        Assert.assertNotNull("Existing authority", authority);

        int usercount = authority.getUsers().size();
        User user = new JpaUser();
        user.setUsername("dummy");
        authority.addUser(user);
        authorityRepository.save(authority);
        assertNull("Persisting an Authority does not persist an unknown user", repository.getByUsername("dummy"));
        Assert.assertEquals("Authority has 1 more user", usercount + 1, authority.getUsers().size());
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

        return manager.find(JpaUser.class, primaryKey);
    }

    @Override
    public User save(User item) {
        JpaUser converted = converter.convert(item);
        return saveOrUpdate(converted.getEntityId(), manager, converted);
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaUser

    public Class<User> getSourceType() {
        return User.class;
    }

    private JpaUser createEntity(User source) {
        JpaUser converted = null;
        if (source != null) {
            converted = new JpaUser();
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.