use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupLogic method deprovision.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> deprovision(final String key, final Collection<String> resources, 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.deprovision(key, resources, nullPriorityAsync);
ProvisioningResult<GroupTO> result = new ProvisioningResult<>();
result.setEntity(binder.getGroupTO(key));
result.getPropagationStatuses().addAll(statuses);
return result;
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupLogic method assign.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> assign(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());
GroupPatch patch = new GroupPatch();
patch.setKey(key);
patch.getResources().addAll(resources.stream().map(resource -> new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(resource).build()).collect(Collectors.toList()));
patch.getADynMembershipConds().putAll(group.getADynMembershipConds());
patch.setUDynMembershipCond(group.getUDynMembershipCond());
return update(patch, nullPriorityAsync);
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupLogic method unlink.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public GroupTO unlink(final String key, final Collection<String> resources) {
// 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());
GroupPatch patch = new GroupPatch();
patch.setKey(key);
patch.getResources().addAll(resources.stream().map(resource -> new StringPatchItem.Builder().operation(PatchOperation.DELETE).value(resource).build()).collect(Collectors.toList()));
patch.setUDynMembershipCond(group.getUDynMembershipCond());
patch.getADynMembershipConds().putAll(group.getADynMembershipConds());
return binder.getGroupTO(provisioningManager.unlink(patch));
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class JAXBTest method provisioningResult.
@Test
public void provisioningResult() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(ProvisioningResult.class);
Marshaller marshaller = context.createMarshaller();
Unmarshaller unmarshaller = context.createUnmarshaller();
GroupTO group = new GroupTO();
group.setName(UUID.randomUUID().toString());
group.setRealm(SyncopeConstants.ROOT_REALM);
group.getVirAttrs().add(new AttrTO.Builder().schema("rvirtualdata").value("rvirtualvalue").build());
group.getADynMembershipConds().put("USER", "username==a*");
ProvisioningResult<GroupTO> original = new ProvisioningResult<>();
original.setEntity(group);
PropagationStatus status = new PropagationStatus();
status.setFailureReason("failed");
status.setBeforeObj(new ConnObjectTO());
original.getPropagationStatuses().add(status);
StringWriter writer = new StringWriter();
marshaller.marshal(original, writer);
Object actual = unmarshaller.unmarshal(new StringReader(writer.toString()));
assertEquals(original, actual);
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class JSONTest method provisioningResult.
@Test
public void provisioningResult() throws IOException {
GroupTO group = new GroupTO();
group.setName(UUID.randomUUID().toString());
group.setRealm(SyncopeConstants.ROOT_REALM);
group.getVirAttrs().add(new AttrTO.Builder().schema("rvirtualdata").value("rvirtualvalue").build());
group.getADynMembershipConds().put("USER", "username==a*");
ProvisioningResult<GroupTO> original = new ProvisioningResult<>();
original.setEntity(group);
PropagationStatus status = new PropagationStatus();
status.setFailureReason("failed");
status.setBeforeObj(new ConnObjectTO());
original.getPropagationStatuses().add(status);
ObjectMapper mapper = new ObjectMapper();
StringWriter writer = new StringWriter();
mapper.writeValue(writer, original);
ProvisioningResult<GroupTO> actual = mapper.readValue(writer.toString(), new TypeReference<ProvisioningResult<GroupTO>>() {
});
assertEquals(original, actual);
}
Aggregations