use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE136AES.
@Test
public void issueSYNCOPE136AES() {
// 1. read configured cipher algorithm in order to be able to restore it at the end of test
AttrTO pwdCipherAlgo = configurationService.get("password.cipher.algorithm");
String origpwdCipherAlgo = pwdCipherAlgo.getValues().get(0);
// 2. set AES password cipher algorithm
pwdCipherAlgo.getValues().set(0, "AES");
configurationService.set(pwdCipherAlgo);
UserTO userTO = null;
try {
// 3. create user with no resources
userTO = UserITCase.getUniqueSampleTO("syncope136_AES@apache.org");
userTO.getResources().clear();
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
// 4. update user, assign a propagation priority resource but don't provide any password
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_LDAP).build());
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_LDAP).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
assertNotNull(result);
userTO = result.getEntity();
assertNotNull(userTO);
// 5. verify that propagation was successful
List<PropagationStatus> props = result.getPropagationStatuses();
assertNotNull(props);
assertEquals(1, props.size());
PropagationStatus prop = props.iterator().next();
assertNotNull(prop);
assertEquals(RESOURCE_NAME_LDAP, prop.getResource());
assertEquals(PropagationTaskExecStatus.SUCCESS, prop.getStatus());
} finally {
// restore initial cipher algorithm
pwdCipherAlgo.getValues().set(0, origpwdCipherAlgo);
configurationService.set(pwdCipherAlgo);
if (userTO != null) {
deleteUser(userTO.getKey());
}
}
}
use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.
the class Realm method customResultBody.
@Override
@SuppressWarnings("unchecked")
protected Panel customResultBody(final String panelId, final RealmTO item, final Serializable result) {
if (!(result instanceof ProvisioningResult)) {
throw new IllegalStateException("Unsupported result type");
}
final MultilevelPanel mlp = new MultilevelPanel(panelId);
add(mlp);
final PropagationStatus syncope = new PropagationStatus();
syncope.setStatus(PropagationTaskExecStatus.SUCCESS);
syncope.setResource(Constants.SYNCOPE);
ArrayList<PropagationStatus> propagations = new ArrayList<>();
propagations.add(syncope);
propagations.addAll(((ProvisioningResult) result).getPropagationStatuses());
ListViewPanel.Builder<PropagationStatus> builder = new ListViewPanel.Builder<PropagationStatus>(PropagationStatus.class, pageRef) {
private static final long serialVersionUID = -6809736686861678498L;
@Override
protected Component getValueComponent(final String key, final PropagationStatus bean) {
if ("afterObj".equalsIgnoreCase(key)) {
ConnObjectTO afterObj = bean.getAfterObj();
String remoteId = afterObj == null || afterObj.getAttrs().isEmpty() || !afterObj.getAttr(ConnIdSpecialName.NAME).isPresent() || afterObj.getAttr(ConnIdSpecialName.NAME).get().getValues() == null || afterObj.getAttr(ConnIdSpecialName.NAME).get().getValues().isEmpty() ? StringUtils.EMPTY : afterObj.getAttr(ConnIdSpecialName.NAME).get().getValues().get(0);
return new Label("field", remoteId);
} else if ("status".equalsIgnoreCase(key)) {
return StatusUtils.getStatusImagePanel("field", bean.getStatus());
} else {
return super.getValueComponent(key, bean);
}
}
};
builder.setItems(propagations);
builder.includes("resource", "afterObj", "status");
builder.withChecks(ListViewPanel.CheckAvailability.NONE);
builder.setReuseItem(false);
builder.addAction(new ActionLink<PropagationStatus>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
protected boolean statusCondition(final PropagationStatus bean) {
return !Constants.SYNCOPE.equals(bean.getResource()) && (PropagationTaskExecStatus.CREATED == bean.getStatus() || PropagationTaskExecStatus.SUCCESS == bean.getStatus());
}
@Override
public void onClick(final AjaxRequestTarget target, final PropagationStatus bean) {
mlp.next(bean.getResource(), new RemoteRealmPanel(bean), target);
}
}, ActionLink.ActionType.VIEW, StandardEntitlement.RESOURCE_GET_CONNOBJECT);
mlp.setFirstLevel(builder.build(MultilevelPanel.FIRST_LEVEL_ID));
return mlp;
}
use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.
the class UserRestClient method reactivate.
public BulkActionResult reactivate(final String etag, final String userKey, final List<StatusBean> statuses) {
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses, true);
statusPatch.setKey(userKey);
statusPatch.setType(StatusPatchType.REACTIVATE);
BulkActionResult result;
synchronized (this) {
result = new BulkActionResult();
Map<String, BulkActionResult.Status> res = result.getResults();
UserService service = getService(etag, UserService.class);
@SuppressWarnings("unchecked") ProvisioningResult<UserTO> provisions = (ProvisioningResult<UserTO>) service.status(statusPatch).readEntity(ProvisioningResult.class);
if (statusPatch.isOnSyncope()) {
res.put(StringUtils.capitalize(Constants.SYNCOPE), "active".equalsIgnoreCase(provisions.getEntity().getStatus()) ? BulkActionResult.Status.SUCCESS : BulkActionResult.Status.FAILURE);
}
for (PropagationStatus status : provisions.getPropagationStatuses()) {
res.put(status.getResource(), BulkActionResult.Status.valueOf(status.getStatus().name()));
}
resetClient(UserService.class);
}
return result;
}
use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.
the class UserLogic method doDelete.
protected ProvisioningResult<UserTO> doDelete(final UserTO userTO, final boolean self, final boolean nullPriorityAsync) {
Pair<UserTO, List<LogicActions>> before = beforeDelete(userTO);
if (!self) {
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.USER_DELETE), before.getLeft().getRealm());
securityChecks(effectiveRealms, before.getLeft().getRealm(), before.getLeft().getKey());
}
List<Group> ownedGroups = groupDAO.findOwnedByUser(before.getLeft().getKey());
if (!ownedGroups.isEmpty()) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.GroupOwnership);
sce.getElements().addAll(ownedGroups.stream().map(group -> group.getKey() + " " + group.getName()).collect(Collectors.toList()));
throw sce;
}
List<PropagationStatus> statuses = provisioningManager.delete(before.getLeft().getKey(), nullPriorityAsync);
UserTO deletedTO;
if (userDAO.find(before.getLeft().getKey()) == null) {
deletedTO = new UserTO();
deletedTO.setKey(before.getLeft().getKey());
} else {
deletedTO = binder.getUserTO(before.getLeft().getKey());
}
return afterDelete(binder.returnUserTO(deletedTO), statuses, before.getRight());
}
use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.
the class GroupLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_DELETE + "')")
@Override
public ProvisioningResult<GroupTO> delete(final String key, final boolean nullPriorityAsync) {
GroupTO group = binder.getGroupTO(key);
Pair<GroupTO, List<LogicActions>> before = beforeDelete(group);
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_DELETE), before.getLeft().getRealm());
securityChecks(effectiveRealms, before.getLeft().getRealm(), before.getLeft().getKey());
List<Group> ownedGroups = groupDAO.findOwnedByGroup(before.getLeft().getKey());
if (!ownedGroups.isEmpty()) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.GroupOwnership);
sce.getElements().addAll(ownedGroups.stream().map(g -> g.getKey() + " " + g.getName()).collect(Collectors.toList()));
throw sce;
}
List<PropagationStatus> statuses = provisioningManager.delete(before.getLeft().getKey(), nullPriorityAsync);
GroupTO groupTO = new GroupTO();
groupTO.setKey(before.getLeft().getKey());
return afterDelete(groupTO, statuses, before.getRight());
}
Aggregations