Package org.apache.syncope.core.persistence.beans.user

Examples of org.apache.syncope.core.persistence.beans.user.SyncopeUser


    private RoleDAO roleDAO;

    @Test
    public void delete() {
        Membership membership = membershipDAO.find(4L);
        SyncopeUser user = membership.getSyncopeUser();
        SyncopeRole role = membership.getSyncopeRole();

        membershipDAO.delete(4L);

        membershipDAO.flush();

        for (Membership m : user.getMemberships()) {
            assertTrue(m.getId() != 4L);
        }
        for (Membership m : roleDAO.findMemberships(role)) {
            assertTrue(m.getId() != 4L);
        }
View Full Code Here


    }

    @Test
    public void deleteAndCreate() {
        Membership membership = membershipDAO.find(3L);
        SyncopeUser user = membership.getSyncopeUser();
        SyncopeRole role = membership.getSyncopeRole();

        // 1. delete that membership
        membershipDAO.delete(membership.getId());
View Full Code Here

        resourceDAO.flush();
        resourceDAO.detach(actual);
        resourceDAO.detach(connector);

        // assign the new resource to an user
        SyncopeUser user = userDAO.find(1L);
        assertNotNull("user not found", user);

        user.addResource(actual);

        resourceDAO.flush();

        // retrieve resource
        resource = resourceDAO.find(actual.getName());
        assertNotNull(resource);

        // check connector
        connector = connInstanceDAO.find(100L);
        assertNotNull(connector);

        assertNotNull(connector.getResources());
        assertTrue(connector.getResources().contains(resource));

        assertNotNull(resource.getConnector());
        assertTrue(resource.getConnector().equals(connector));

        // check mappings
        List<UMappingItem> items = resource.getUmapping().getItems();
        assertNotNull(items);
        assertEquals(5, items.size());

        // check user
        user = userDAO.find(1L);
        assertNotNull(user);
        assertNotNull(user.getResources());
        assertTrue(user.getResources().contains(actual));
    }
View Full Code Here

        ExternalResource actual = resourceDAO.find("ws-target-resource-2");
        assertNull("delete did not work", actual);

        // resource must be not referenced any more from users
        for (Long id : userIds) {
            SyncopeUser actualUser = userDAO.find(id);
            assertNotNull(actualUser);
            for (ExternalResource res : actualUser.getResources()) {
                assertFalse(res.getName().equalsIgnoreCase(resource.getName()));
            }
        }

        // resource must be not referenced any more from the connector
View Full Code Here

                    LOG.error("Cannot check previous passwords. attributable is not a user object: {}",
                            attributable.getClass().getName());
                    result = (T) evaluatedPPSpec;
                    break;
                }
                SyncopeUser user = (SyncopeUser) attributable;
                if (user.verifyPasswordHistory(user.getClearPassword(), ppSpec.getHistoryLength())) {
                    evaluatedPPSpec.getWordsNotPermitted().add(user.getClearPassword());
                }
                result = (T) evaluatedPPSpec;
                break;
            case ACCOUNT:
            case GLOBAL_ACCOUNT:
View Full Code Here

     * @throws NotFoundException if user contained in the workflow result cannot be found
     */
    public void createTasks(final Long userId, final Set<String> performedTasks)
            throws NotFoundException {

        SyncopeUser user = userDAO.find(userId);
        if (user == null) {
            throw new NotFoundException("User " + userId);
        }

        for (Notification notification : notificationDAO.findAll()) {
View Full Code Here

    @Transactional(noRollbackFor = {BadCredentialsException.class, DisabledException.class})
    public Authentication authenticate(final Authentication authentication)
            throws AuthenticationException {

        boolean authenticated = false;
        SyncopeUser user = null;

        String username = authentication.getName();
        if (adminUser.equals(username)) {
            authenticated = authenticate(
                    authentication.getCredentials().toString(),
                    CipherAlgorithm.valueOf(adminPasswordAlgorithm),
                    adminPassword);
        } else {
            user = userDAO.find(username);

            if (user != null && user.isSuspended() != null) {
                if (user.isSuspended()) {
                    throw new DisabledException("User " + user.getUsername() + " is suspended");
                }
                authenticated = authenticate(
                        authentication.getCredentials().toString(),
                        user.getCipherAlgorithm(),
                        user.getPassword());
            }
        }

        UsernamePasswordAuthenticationToken token;

        if (authenticated) {
            token = new UsernamePasswordAuthenticationToken(
                    authentication.getPrincipal(),
                    null,
                    userDetailsService.loadUserByUsername(authentication.getPrincipal().toString()).getAuthorities());

            token.setDetails(authentication.getDetails());

            auditManager.audit(Category.authentication, AuthenticationSubCategory.login, Result.success,
                    "Successfully authenticated, with roles: " + token.getAuthorities());

            LOG.debug("User {} successfully authenticated, with roles {}",
                    authentication.getPrincipal(), token.getAuthorities());

            if (user != null) {
                user.setLastLoginDate(new Date());
                user.setFailedLogins(0);
                userDAO.save(user);
            }
        } else {
            if (user != null) {
                user.setFailedLogins(user.getFailedLogins() + 1);
                userDAO.save(user);
            }

            auditManager.audit(Category.authentication, AuthenticationSubCategory.login, Result.failure,
                    "User " + authentication.getPrincipal() + " not authenticated");
View Full Code Here

        if (adminUser.equals(username)) {
            for (Entitlement entitlement : entitlementDAO.findAll()) {
                authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
            }
        } else {
            final SyncopeUser user = userDAO.find(username);

            if (user == null) {
                throw new UsernameNotFoundException("Could not find any user with id " + username);
            }

            // Give entitlements based on roles assigned to user (and their ancestors)
            final Set<SyncopeRole> roles = new HashSet<SyncopeRole>(user.getRoles());
            for (SyncopeRole role : user.getRoles()) {
                roles.addAll(roleDAO.findAncestors(role));
            }
            for (SyncopeRole role : roles) {
                for (Entitlement entitlement : role.getEntitlements()) {
                    authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
View Full Code Here

        UDerSchema actual = derSchemaDAO.find("sderived", UDerSchema.class);
        assertNotNull("expected save to work", actual);
        assertEquals(sderived, actual);

        SyncopeUser owner = userDAO.find(3L);
        assertNotNull("did not get expected user", owner);

        UDerAttr derAttr = new UDerAttr();
        derAttr.setOwner(owner);
        derAttr.setDerivedSchema(sderived);

        derAttr = derAttrDAO.save(derAttr);
        derAttrDAO.flush();

        derAttr = derAttrDAO.find(derAttr.getId(), UDerAttr.class);
        assertNotNull("expected save to work", derAttr);

        String value = derAttr.getValue(owner.getAttributes());
        assertNotNull(value);
        assertFalse(value.isEmpty());
        assertTrue(value.startsWith("vivaldi - 2010-10-20"));
        assertTrue(value.endsWith("[]"));
    }
View Full Code Here

    @Test(expected = InvalidEntityException.class)
    public void saveWithTwoOwners() {
        SyncopeRole root = roleDAO.find("root", null);
        assertNotNull("did not find expected role", root);

        SyncopeUser user = userDAO.find(1L);
        assertNotNull("did not find expected user", user);

        SyncopeRole role = new SyncopeRole();
        role.setName("error");
        role.setUserOwner(user);
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.user.SyncopeUser

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.