Package org.apache.syncope.common.mod

Examples of org.apache.syncope.common.mod.UserMod


        userTO.getResources().clear();

        userTO = createUser(userTO);
        assertNotNull(userTO);

        UserMod userMod = new UserMod();
        userMod.setId(userTO.getId());

        // this resource has not a mapping for Password
        userMod.addResourceToBeAdded("ws-target-resource-update");

        userTO = userService.update(userTO.getId(), userMod);
        assertNotNull(userTO);
    }
View Full Code Here


        assertNotNull(pwdOnTestDb2Attr.getValues());
        assertFalse(pwdOnTestDb2Attr.getValues().isEmpty());
        final String pwdOnTestDb2 = pwdOnTestDb2Attr.getValues().iterator().next();

        // 2. request to change password only on testdb (no Syncope, no testdb2)
        UserMod userMod = new UserMod();
        userMod.setId(userTO.getId());
        userMod.setPassword(getUUIDString());
        PropagationRequestTO pwdPropRequest = new PropagationRequestTO();
        pwdPropRequest.addResource(RESOURCE_NAME_TESTDB);
        userMod.setPwdPropRequest(pwdPropRequest);

        userTO = userService.update(userMod.getId(), userMod);

        // 3a. Chech that only a single propagation took place
        assertNotNull(userTO.getPropagationStatusTOs());
        assertEquals(1, userTO.getPropagationStatusTOs().size());
        assertEquals(RESOURCE_NAME_TESTDB, userTO.getPropagationStatusTOs().iterator().next().getResource());
View Full Code Here

            userTO = userService.create(userTO).readEntity(UserTO.class);
            assertNotNull(userTO);

            // 4. update user, assign a propagation primary resource but don't provide any password
            UserMod userMod = new UserMod();
            userMod.setId(userTO.getId());
            userMod.addResourceToBeAdded("ws-target-resource-1");

            userTO = userService.update(userMod.getId(), userMod);
            assertNotNull(userTO);

            // 5. verify that propagation was successful
            List<PropagationStatusTO> props = userTO.getPropagationStatusTOs();
            assertNotNull(props);
View Full Code Here

        userTO = userService.create(userTO).readEntity(UserTO.class);
        assertNotNull(userTO);

        // 2. update user, assign a propagation primary resource but don't provide any password
        UserMod userMod = new UserMod();
        userMod.setId(userTO.getId());
        userMod.addResourceToBeAdded(RESOURCE_NAME_LDAP);

        userTO = userService.update(userMod.getId(), userMod);
        assertNotNull(userTO);

        // 3. verify that propagation was successful
        List<PropagationStatusTO> props = userTO.getPropagationStatusTOs();
        assertNotNull(props);
View Full Code Here

        // 2. check for cached attribute value
        actual = userService.read(actual.getId());
        assertEquals("virattrcache", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));

        UserMod userMod = new UserMod();
        userMod.setId(actual.getId());

        AttributeMod virtualdata = new AttributeMod();
        virtualdata.setSchema("virtualdata");
        virtualdata.addValueToBeAdded("virtualupdated");

        userMod.addVirtualAttributeToBeRemoved("virtualdata");
        userMod.addVirtualAttributeToBeUpdated(virtualdata);

        // 3. update virtual attribute
        actual = userService.update(actual.getId(), userMod);
        assertNotNull(actual);
View Full Code Here

    }

    @Test
    public void issueSYNCOPE265() {
        for (long i = 1; i <= 5; i++) {
            UserMod userMod = new UserMod();
            userMod.setId(i);

            AttributeMod attributeMod = new AttributeMod();
            attributeMod.setSchema("type");
            attributeMod.addValueToBeAdded("a type");

            userMod.addAttributeToBeRemoved("type");
            userMod.addAttributeToBeUpdated(attributeMod);

            UserTO userTO = userService.update(i, userMod);
            assertEquals("a type", userTO.getAttributeMap().get("type").getValues().get(0));
        }
    }
View Full Code Here

        assertNotNull(connObj);
        assertTrue(connObj.getAttributeMap().get("uniqueMember").getValues().
                contains("uid=" + userTO.getUsername() + ",ou=people,o=isp"));

        // 4. remove membership
        UserMod userMod = new UserMod();
        userMod.setId(userTO.getId());
        userMod.addMembershipToBeRemoved(userTO.getMemberships().iterator().next().getId());

        userTO = userService.update(userMod.getId(), userMod);
        assertTrue(userTO.getResources().contains(RESOURCE_NAME_LDAP));

        // 5. read role on resource, check that user DN was removed from uniqueMember
        connObj = resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, roleTO.getId());
        assertNotNull(connObj);
View Full Code Here

        userTO.getResources().clear();
        userTO = createUser(userTO);
        assertNotNull(userTO);

        // 2. assign resource without specifying a new pwd and check propagation failure
        UserMod userMod = new UserMod();
        userMod.setId(userTO.getId());
        userMod.addResourceToBeAdded(RESOURCE_NAME_TESTDB);
        userTO = userService.update(userMod.getId(), userMod);
        assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
        assertFalse(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());

        // 3. request to change password only on testdb
        userMod = new UserMod();
        userMod.setId(userTO.getId());
        userMod.setPassword(getUUIDString());
        PropagationRequestTO pwdPropRequest = new PropagationRequestTO();
        pwdPropRequest.addResource(RESOURCE_NAME_TESTDB);
        userMod.setPwdPropRequest(pwdPropRequest);

        userTO = userService.update(userMod.getId(), userMod);
        assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
        assertTrue(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());
    }
View Full Code Here

        UserTO newUserTO = AttributableOperations.clone(userTO);
        MembershipTO membership = new MembershipTO();
        membership.setRoleId(2L);
        newUserTO.addMembership(membership);

        UserMod userMod = AttributableOperations.diff(newUserTO, userTO);

        userTO = userService.update(userMod.getId(), userMod);
        assertNotNull(userTO);
    }
View Full Code Here

    protected UserTO updateUser(final Long id, SyncDelta delta, final boolean dryRun, final SyncResult result)
            throws Exception {

        UserTO userTO = userDataBinder.getUserTO(id);
        UserMod userMod = connObjectUtil.getAttributableMod(
                id, delta.getObject(), userTO, syncTask, AttributableUtil.getInstance(AttributableType.USER));

        delta = actions.beforeUpdate(this, delta, userTO, userMod);

        if (dryRun) {
            return userTO;
        }

        WorkflowResult<Map.Entry<Long, Boolean>> updated;
        try {
            updated = uwfAdapter.update(userMod);
        } catch (Exception e) {
            LOG.error("Update of user {} failed, trying to sync its status anyway (if configured)", id, e);

            result.setStatus(SyncResult.Status.FAILURE);
            result.setMessage("Update failed, trying to sync status anyway (if configured)\n" + e.getMessage());

            updated = new WorkflowResult<Map.Entry<Long, Boolean>>(
                    new AbstractMap.SimpleEntry<Long, Boolean>(id, false), new PropagationByResource(),
                    new HashSet<String>());
        }

        Boolean enabled = readEnabled(delta.getObject());
        if (enabled != null) {
            SyncopeUser user = userDAO.find(id);

            WorkflowResult<Long> enableUpdate = null;
            if (user.isSuspended() == null) {
                enableUpdate = uwfAdapter.activate(id, null);
            } else if (enabled && user.isSuspended()) {
                enableUpdate = uwfAdapter.reactivate(id);
            } else if (!enabled && !user.isSuspended()) {
                enableUpdate = uwfAdapter.suspend(id);
            }

            if (enableUpdate != null) {
                if (enableUpdate.getPropByRes() != null) {
                    updated.getPropByRes().merge(enableUpdate.getPropByRes());
                    updated.getPropByRes().purge();
                }
                updated.getPerformedTasks().addAll(enableUpdate.getPerformedTasks());
            }
        }

        List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(updated,
                userMod.getPassword(),
                userMod.getVirtualAttributesToBeRemoved(),
                userMod.getVirtualAttributesToBeUpdated(),
                Collections.singleton(syncTask.getResource().getName()));

        taskExecutor.execute(tasks);

        notificationManager.createTasks(updated.getResult().getKey(), updated.getPerformedTasks());
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.mod.UserMod

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.