use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class SyncopeLogic method searchAssignableGroups.
@PreAuthorize("isAuthenticated()")
public Pair<Integer, List<GroupTO>> searchAssignableGroups(final String realm, final String term, final int page, final int size) {
AssignableCond assignableCond = new AssignableCond();
assignableCond.setRealmFullPath(realm);
SearchCond searchCond;
if (StringUtils.isNotBlank(term)) {
AnyCond termCond = new AnyCond(AttributeCond.Type.ILIKE);
termCond.setSchema("name");
String termSearchableValue = (term.startsWith("*") && !term.endsWith("*")) ? term + "%" : (!term.startsWith("*") && term.endsWith("*")) ? "%" + term : (term.startsWith("*") && term.endsWith("*") ? term : "%" + term + "%");
termCond.setExpression(termSearchableValue);
searchCond = SearchCond.getAndCond(SearchCond.getLeafCond(assignableCond), SearchCond.getLeafCond(termCond));
} else {
searchCond = SearchCond.getLeafCond(assignableCond);
}
int count = searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS, searchCond, AnyTypeKind.GROUP);
OrderByClause orderByClause = new OrderByClause();
orderByClause.setField("name");
orderByClause.setDirection(OrderByClause.Direction.ASC);
List<Group> matching = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCond, page, size, Collections.singletonList(orderByClause), AnyTypeKind.GROUP);
List<GroupTO> result = matching.stream().map(group -> groupDataBinder.getGroupTO(group, false)).collect(Collectors.toList());
return Pair.of(count, result);
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class RemediationLogic method remedy.
@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_REMEDY + "')")
public ProvisioningResult<?> remedy(final String key, final AnyTO anyTO, final boolean nullPriorityAsync) {
Remediation remediation = remediationDAO.find(key);
if (remediation == null) {
LOG.error("Could not find remediation '" + key + "'");
throw new NotFoundException(key);
}
ProvisioningResult<?> result;
switch(remediation.getAnyType().getKind()) {
case USER:
default:
result = userLogic.create((UserTO) anyTO, true, nullPriorityAsync);
break;
case GROUP:
result = groupLogic.create((GroupTO) anyTO, nullPriorityAsync);
break;
case ANY_OBJECT:
result = anyObjectLogic.create((AnyObjectTO) anyTO, nullPriorityAsync);
}
remediationDAO.delete(remediation);
return result;
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> update(final GroupPatch groupPatch, final boolean nullPriorityAsync) {
GroupTO groupTO = binder.getGroupTO(groupPatch.getKey());
Set<String> dynRealmsBefore = new HashSet<>(groupTO.getDynRealms());
Pair<GroupPatch, List<LogicActions>> before = beforeUpdate(groupPatch, groupTO.getRealm());
String realm = before.getLeft().getRealm() != null && StringUtils.isNotBlank(before.getLeft().getRealm().getValue()) ? before.getLeft().getRealm().getValue() : groupTO.getRealm();
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_UPDATE), realm);
boolean authDynRealms = securityChecks(effectiveRealms, realm, before.getLeft().getKey());
Pair<GroupPatch, List<PropagationStatus>> updated = provisioningManager.update(groupPatch, nullPriorityAsync);
return afterUpdate(binder.getGroupTO(updated.getLeft().getKey()), updated.getRight(), before.getRight(), authDynRealms, dynRealmsBefore);
}
use of org.apache.syncope.common.lib.to.GroupTO 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;
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupLogic method unassign.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> unassign(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());
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.getADynMembershipConds().putAll(group.getADynMembershipConds());
patch.setUDynMembershipCond(group.getUDynMembershipCond());
return update(patch, nullPriorityAsync);
}
Aggregations