use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupServiceImpl method update.
@Override
public Response update(final GroupTO groupTO) {
groupTO.setKey(getActualKey(groupTO.getKey()));
GroupTO before = logic.read(groupTO.getKey());
checkETag(before.getETagValue());
ProvisioningResult<GroupTO> updated = logic.update(AnyOperations.diff(groupTO, before, false), isNullPriorityAsync());
return modificationResponse(updated);
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE710.
@Test
public void issueSYNCOPE710() {
// 1. create groups for indirect resource assignment
GroupTO ldapGroup = GroupITCase.getBasicSampleTO("syncope710.ldap");
ldapGroup.getResources().add(RESOURCE_NAME_LDAP);
ldapGroup = createGroup(ldapGroup).getEntity();
GroupTO dbGroup = GroupITCase.getBasicSampleTO("syncope710.db");
dbGroup.getResources().add(RESOURCE_NAME_TESTDB);
dbGroup = createGroup(dbGroup).getEntity();
// 2. create user with memberships for the groups created above
UserTO userTO = UserITCase.getUniqueSampleTO("syncope710@syncope.apache.org");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getMemberships().add(new MembershipTO.Builder().group(ldapGroup.getKey()).build());
userTO.getMemberships().add(new MembershipTO.Builder().group(dbGroup.getKey()).build());
ProvisioningResult<UserTO> result = createUser(userTO);
assertEquals(2, result.getPropagationStatuses().size());
userTO = result.getEntity();
// 3. request to propagate passwod only to db
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_TESTDB).value("newpassword123").build());
result = updateUser(userPatch);
assertEquals(1, result.getPropagationStatuses().size());
assertEquals(RESOURCE_NAME_TESTDB, result.getPropagationStatuses().get(0).getResource());
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupDetails method details.
public void details() {
if (input.parameterNumber() == 0) {
try {
final Map<String, String> details = new LinkedHashMap<>();
final List<GroupTO> groupTOs = groupSyncopeOperations.list();
int withoudResources = 0;
int withoudAttributes = 0;
int onRootRealm = 0;
for (final GroupTO groupTO : groupTOs) {
if (groupTO.getResources() == null || groupTO.getResources().isEmpty()) {
withoudResources++;
}
if ((groupTO.getPlainAttrs() == null || groupTO.getPlainAttrs().isEmpty()) && (groupTO.getDerAttrs() == null || groupTO.getDerAttrs().isEmpty()) && (groupTO.getVirAttrs() == null || groupTO.getVirAttrs().isEmpty())) {
withoudAttributes++;
}
if (SyncopeConstants.ROOT_REALM.equals(groupTO.getRealm())) {
onRootRealm++;
}
}
details.put("Total number", String.valueOf(groupTOs.size()));
details.put("Without resources", String.valueOf(withoudResources));
details.put("Without attributes", String.valueOf(withoudAttributes));
details.put("On root realm", String.valueOf(onRootRealm));
details.put("On the other realm", String.valueOf(groupTOs.size() - onRootRealm));
groupResultManager.printDetails(details);
} catch (final SyncopeClientException ex) {
LOG.error("Error reading details about realm", ex);
groupResultManager.genericError(ex.getMessage());
}
} else {
groupResultManager.unnecessaryParameters(input.listParameters(), DETAILS_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class AnyPanel method getDirectoryPanel.
protected Panel getDirectoryPanel(final String id) {
final Panel panel;
String fiql;
final String realm;
final String dynRealm;
if (realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) {
realm = realmTO.getFullPath();
dynRealm = null;
} else {
realm = SyncopeConstants.ROOT_REALM;
dynRealm = realmTO.getKey();
}
switch(anyTypeTO.getKind()) {
case USER:
fiql = dynRealm == null ? SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue().query() : SyncopeClient.getUserSearchConditionBuilder().inDynRealms(dynRealm).query();
final UserTO userTO = new UserTO();
userTO.setRealm(realmTO.getFullPath());
panel = new UserDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef).setRealm(realm).setFiltered(true).setFiql(fiql).setWizardInModal(true).addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(userTO, anyTypeTO.getClasses(), formLayoutInfo.getLeft(), pageRef)).build(id);
MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER, StandardEntitlement.USER_SEARCH);
break;
case GROUP:
fiql = dynRealm == null ? SyncopeClient.getGroupSearchConditionBuilder().is("key").notNullValue().query() : SyncopeClient.getGroupSearchConditionBuilder().inDynRealms(dynRealm).query();
final GroupTO groupTO = new GroupTO();
groupTO.setRealm(realmTO.getFullPath());
panel = new GroupDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef).setRealm(realm).setFiltered(true).setFiql(fiql).setWizardInModal(true).addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(groupTO, anyTypeTO.getClasses(), formLayoutInfo.getMiddle(), pageRef)).build(id);
// list of group is available to all authenticated users
break;
case ANY_OBJECT:
fiql = dynRealm == null ? SyncopeClient.getAnyObjectSearchConditionBuilder(anyTypeTO.getKey()).is("key").notNullValue().query() : SyncopeClient.getAnyObjectSearchConditionBuilder(anyTypeTO.getKey()).inDynRealms(dynRealm).query();
final AnyObjectTO anyObjectTO = new AnyObjectTO();
anyObjectTO.setRealm(realmTO.getFullPath());
anyObjectTO.setType(anyTypeTO.getKey());
panel = new AnyObjectDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef).setRealm(realm).setFiltered(true).setFiql(fiql).setWizardInModal(true).addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(anyObjectTO, anyTypeTO.getClasses(), formLayoutInfo.getRight().get(anyTypeTO.getKey()), pageRef)).build(id);
MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER, AnyEntitlement.SEARCH.getFor(anyTypeTO.getKey()));
break;
default:
panel = new LabelPanel(id, null);
}
return panel;
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class RemediationDirectoryPanel method getActions.
@Override
protected ActionsPanel<RemediationTO> getActions(final IModel<RemediationTO> model) {
ActionsPanel<RemediationTO> panel = super.getActions(model);
panel.add(new ActionLink<RemediationTO>() {
private static final long serialVersionUID = 6193210574968203299L;
@Override
public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
modal.header(new ResourceModel("error"));
modal.setContent(new ExecMessageModal(model.getObject().getError()));
modal.show(true);
target.add(modal);
}
}, ActionLink.ActionType.VIEW_DETAILS, StandardEntitlement.REMEDIATION_READ);
if (model.getObject().getOperation() == ResourceOperation.DELETE) {
String entitlements = StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_DELETE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_DELETE : AnyEntitlement.DELETE.getFor(model.getObject().getAnyType()) }, ",");
panel.add(new ActionLink<RemediationTO>() {
private static final long serialVersionUID = 6193210574968203299L;
@Override
public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
try {
restClient.remedy(model.getObject().getKey(), model.getObject().getKeyPayload());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While performing remediation {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.CLOSE, entitlements, true);
} else {
String entitlements = model.getObject().getOperation() == ResourceOperation.CREATE ? StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_CREATE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_CREATE : AnyEntitlement.CREATE.getFor(model.getObject().getAnyType()) }, ",") : StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_UPDATE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_UPDATE : AnyEntitlement.UPDATE.getFor(model.getObject().getAnyType()) }, ",");
panel.add(new ActionLink<RemediationTO>() {
private static final long serialVersionUID = 6193210574968203299L;
@Override
public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
modal.setFormModel(new CompoundPropertyModel<>(model.getObject()));
RemediationTO remediationTO = model.getObject();
switch(remediationTO.getAnyType()) {
case "USER":
UserTO newUserTO;
UserTO previousUserTO;
if (remediationTO.getAnyPatchPayload() == null) {
newUserTO = (UserTO) remediationTO.getAnyTOPayload();
previousUserTO = null;
} else {
previousUserTO = new UserRestClient().read(remediationTO.getAnyPatchPayload().getKey());
newUserTO = AnyOperations.patch(previousUserTO, (UserPatch) remediationTO.getAnyPatchPayload());
}
AjaxWizard.EditItemActionEvent<UserTO> userEvent = new AjaxWizard.EditItemActionEvent<>(newUserTO, target);
userEvent.forceModalPanel(new RemediationUserWizardBuilder(model.getObject(), previousUserTO, newUserTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getLeft(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
send(RemediationDirectoryPanel.this, Broadcast.EXACT, userEvent);
break;
case "GROUP":
GroupTO newGroupTO;
GroupTO previousGroupTO;
if (remediationTO.getAnyPatchPayload() == null) {
newGroupTO = (GroupTO) remediationTO.getAnyTOPayload();
previousGroupTO = null;
} else {
previousGroupTO = new GroupRestClient().read(remediationTO.getAnyPatchPayload().getKey());
newGroupTO = AnyOperations.patch(previousGroupTO, (GroupPatch) remediationTO.getAnyPatchPayload());
}
AjaxWizard.EditItemActionEvent<GroupTO> groupEvent = new AjaxWizard.EditItemActionEvent<>(newGroupTO, target);
groupEvent.forceModalPanel(new RemediationGroupWizardBuilder(model.getObject(), previousGroupTO, newGroupTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getMiddle(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
send(RemediationDirectoryPanel.this, Broadcast.EXACT, groupEvent);
break;
default:
AnyObjectTO newAnyObjectTO;
AnyObjectTO previousAnyObjectTO;
if (remediationTO.getAnyPatchPayload() == null) {
newAnyObjectTO = (AnyObjectTO) remediationTO.getAnyTOPayload();
previousAnyObjectTO = null;
} else {
previousAnyObjectTO = new AnyObjectRestClient().read(remediationTO.getAnyPatchPayload().getKey());
newAnyObjectTO = AnyOperations.patch(previousAnyObjectTO, (AnyObjectPatch) remediationTO.getAnyPatchPayload());
}
AjaxWizard.EditItemActionEvent<AnyObjectTO> anyObjectEvent = new AjaxWizard.EditItemActionEvent<>(newAnyObjectTO, target);
anyObjectEvent.forceModalPanel(new RemediationAnyObjectWizardBuilder(model.getObject(), previousAnyObjectTO, newAnyObjectTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getRight().values().iterator().next(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
send(RemediationDirectoryPanel.this, Broadcast.EXACT, anyObjectEvent);
}
}
}, ActionLink.ActionType.EDIT, entitlements);
}
panel.add(new ActionLink<RemediationTO>() {
private static final long serialVersionUID = 6193210574968203299L;
@Override
public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
try {
restClient.delete(model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.REMEDIATION_DELETE, true);
return panel;
}
Aggregations