Search in sources :

Example 11 with ProvisioningResult

use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.

the class UserLogic method deprovision.

@PreAuthorize("hasRole('" + StandardEntitlement.USER_UPDATE + "')")
@Override
public ProvisioningResult<UserTO> deprovision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    // security checks
    UserTO user = binder.getUserTO(key);
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.USER_UPDATE), user.getRealm());
    securityChecks(effectiveRealms, user.getRealm(), user.getKey());
    List<PropagationStatus> statuses = provisioningManager.deprovision(key, resources, nullPriorityAsync);
    ProvisioningResult<UserTO> result = new ProvisioningResult<>();
    result.setEntity(binder.returnUserTO(binder.getUserTO(key)));
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 12 with ProvisioningResult

use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.

the class UserLogic method provision.

@PreAuthorize("hasRole('" + StandardEntitlement.USER_UPDATE + "')")
@Override
public ProvisioningResult<UserTO> provision(final String key, final Collection<String> resources, final boolean changePwd, final String password, final boolean nullPriorityAsync) {
    // security checks
    UserTO user = binder.getUserTO(key);
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.USER_UPDATE), user.getRealm());
    securityChecks(effectiveRealms, user.getRealm(), user.getKey());
    List<PropagationStatus> statuses = provisioningManager.provision(key, changePwd, password, resources, nullPriorityAsync);
    ProvisioningResult<UserTO> result = new ProvisioningResult<>();
    result.setEntity(binder.returnUserTO(binder.getUserTO(key)));
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 13 with ProvisioningResult

use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.

the class GroupLogic method provision.

@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> provision(final String key, final Collection<String> resources, final boolean changePwd, final String password, final boolean nullPriorityAsync) {
    // security checks
    GroupTO group = binder.getGroupTO(key);
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_UPDATE), group.getRealm());
    securityChecks(effectiveRealms, group.getRealm(), group.getKey());
    List<PropagationStatus> statuses = provisioningManager.provision(key, resources, nullPriorityAsync);
    ProvisioningResult<GroupTO> result = new ProvisioningResult<>();
    result.setEntity(binder.getGroupTO(key));
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) GroupTO(org.apache.syncope.common.lib.to.GroupTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 14 with ProvisioningResult

use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.

the class AnyDirectoryPanel method customResultBody.

@Override
@SuppressWarnings("unchecked")
protected Panel customResultBody(final String panelId, final AnyWrapper<A> item, final Serializable result) {
    if (!(result instanceof ProvisioningResult)) {
        throw new IllegalStateException("Unsupported result type");
    }
    return new StatusPanel(panelId, ((ProvisioningResult<A>) result).getEntity(), new ListModel<>(new ArrayList<>()), ((ProvisioningResult<A>) result).getPropagationStatuses().stream().map(input -> {
        ConnObjectTO before = input.getBeforeObj();
        ConnObjectWrapper afterObjWrapper = new ConnObjectWrapper(((ProvisioningResult<A>) result).getEntity(), input.getResource(), input.getAfterObj());
        return Pair.of(before, afterObjWrapper);
    }).collect(Collectors.toList()), pageRef);
}
Also used : ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) ArrayList(java.util.ArrayList) ConnObjectTO(org.apache.syncope.common.lib.to.ConnObjectTO) StatusPanel(org.apache.syncope.client.console.wizards.any.StatusPanel) ConnObjectWrapper(org.apache.syncope.client.console.commons.status.ConnObjectWrapper)

Example 15 with ProvisioningResult

use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.

the class PlainSchemaITCase method issue259.

@Test
public void issue259() {
    PlainSchemaTO schemaTO = buildPlainSchemaTO("schema_issue259", AttrSchemaType.Double);
    schemaTO.setUniqueConstraint(true);
    schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    assertNotNull(schemaTO);
    AnyTypeClassTO typeClass = new AnyTypeClassTO();
    typeClass.setKey("issue259");
    typeClass.getPlainSchemas().add(schemaTO.getKey());
    anyTypeClassService.create(typeClass);
    UserTO userTO = UserITCase.getUniqueSampleTO("issue259@syncope.apache.org");
    userTO.getAuxClasses().add(typeClass.getKey());
    userTO.getPlainAttrs().add(attrTO(schemaTO.getKey(), "1"));
    userTO = createUser(userTO).getEntity();
    assertNotNull(userTO);
    UserTO newUserTO = SerializationUtils.clone(userTO);
    newUserTO.getMemberships().add(new MembershipTO.Builder().group("b1f7c12d-ec83-441f-a50e-1691daaedf3b").build());
    userTO = userService.update(newUserTO).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
    }).getEntity();
    assertNotNull(userTO);
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) UserTO(org.apache.syncope.common.lib.to.UserTO) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Aggregations

ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)39 UserTO (org.apache.syncope.common.lib.to.UserTO)24 Test (org.junit.jupiter.api.Test)21 GroupTO (org.apache.syncope.common.lib.to.GroupTO)14 PropagationStatus (org.apache.syncope.common.lib.to.PropagationStatus)12 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)10 Response (javax.ws.rs.core.Response)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)8 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)8 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)8 UserService (org.apache.syncope.common.rest.api.service.UserService)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 GenericType (javax.ws.rs.core.GenericType)6 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)6 StringReplacePatchItem (org.apache.syncope.common.lib.patch.StringReplacePatchItem)5 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)4 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)4 RealmTO (org.apache.syncope.common.lib.to.RealmTO)4 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)4 PatchOperation (org.apache.syncope.common.lib.types.PatchOperation)4