public StatusBean(final RealmTO realm, final String resource) { this.key = realm.getKey(); this.name = realm.getFullPath(); this.resource = resource; }
@Override protected List<String> load() { return new RealmRestClient().list().stream(). filter(realm -> authRealms.stream(). anyMatch(authRealm -> realm.getFullPath().startsWith(authRealm))). map(RealmTO::getFullPath). sorted(). collect(Collectors.toList()); } };
@Override protected void onClickEdit(final AjaxRequestTarget target, final RealmTO realmTO) { this.wizardBuilder.setParentPath(realmTO.getFullPath()); send(this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<RealmTO>(realmTO, target) { @Override public String getEventDescription() { return "realm.edit"; } }); }
@Override public Response create(final String parentPath, final RealmTO realmTO) { ProvisioningResult<RealmTO> created = logic.create(StringUtils.prependIfMissing(parentPath, SyncopeConstants.ROOT_REALM), realmTO); URI location = uriInfo.getAbsolutePathBuilder().path(created.getEntity().getName()).build(); Response.ResponseBuilder builder = Response.created(location). header(RESTHeaders.RESOURCE_KEY, created.getEntity().getFullPath()); return applyPreference(created, builder).build(); }
@PreAuthorize("hasRole('" + StandardEntitlement.REALM_UPDATE + "')") public ProvisioningResult<RealmTO> update(final RealmTO realmTO) { Realm realm = realmDAO.findByFullPath(realmTO.getFullPath()); if (realm == null) { LOG.error("Could not find realm '" + realmTO.getFullPath() + "'"); throw new NotFoundException(realmTO.getFullPath()); } PropagationByResource propByRes = binder.update(realm, realmTO); realm = realmDAO.save(realm); List<PropagationTaskInfo> taskInfos = propagationManager.createTasks(realm, propByRes, null); PropagationReporter propagationReporter = taskExecutor.execute(taskInfos, false); ProvisioningResult<RealmTO> result = new ProvisioningResult<>(); result.setEntity(binder.getRealmTO(realm, true)); result.getPropagationStatuses().addAll(propagationReporter.getStatuses()); return result; }
private Realm update(final RealmTO realmTO, final ConnectorObject beforeObj, final ProvisioningReport result) { Realm realm = realmDAO.findByFullPath(realmTO.getFullPath()); PropagationByResource propByRes = binder.update(realm, realmTO); realm = realmDAO.save(realm); List<PropagationTaskInfo> taskInfos = propagationManager.createTasks(realm, propByRes, null); if (!taskInfos.isEmpty()) { taskInfos.get(0).setBeforeObj(Optional.ofNullable(beforeObj)); PropagationReporter reporter = new DefaultPropagationReporter(); taskExecutor.execute(taskInfos.get(0), reporter); reportPropagation(result, reporter); } return realm; }
jexlContext.set("fullPath", ((Realm) object).getFullPath()); } else if (object instanceof RealmTO) { jexlContext.set("fullPath", ((RealmTO) object).getFullPath());
@Override public Response update(final RealmTO realmTO) { realmTO.setFullPath(StringUtils.prependIfMissing(realmTO.getFullPath(), SyncopeConstants.ROOT_REALM)); ProvisioningResult<RealmTO> updated = logic.update(realmTO); return modificationResponse(updated); }
public UserTemplateWizardBuilder( final TemplatableTO templatable, final List<String> anyTypeClasses, final UserFormLayoutInfo formLayoutInfo, final PageReference pageRef) { super(anyTypeClasses, formLayoutInfo, pageRef); this.templatable = templatable; if (templatable.getTemplates().containsKey(AnyTypeKind.USER.name())) { setItem(new UserWrapper(UserTO.class.cast(templatable.getTemplates().get(AnyTypeKind.USER.name())))); } else { UserTO userTO = new UserTO(); if (templatable instanceof RealmTO) { userTO.setRealm(String.format("'%s'", RealmTO.class.cast(templatable).getFullPath())); } setItem(new UserWrapper(userTO)); } }
public GroupTemplateWizardBuilder( final TemplatableTO templatable, final List<String> anyTypeClasses, final GroupFormLayoutInfo formLayoutInfo, final PageReference pageRef) { super(null, anyTypeClasses, formLayoutInfo, pageRef); this.templatable = templatable; if (templatable.getTemplates().containsKey(AnyTypeKind.GROUP.name())) { setItem(new GroupWrapper(GroupTO.class.cast(templatable.getTemplates().get(AnyTypeKind.GROUP.name())))); } else { GroupTO groupTO = new GroupTO(); if (templatable instanceof RealmTO) { groupTO.setRealm(String.format("'%s'", RealmTO.class.cast(templatable).getFullPath())); } setItem(new GroupWrapper(groupTO)); } }
public AnyObjectTemplateWizardBuilder( final TemplatableTO templatable, final String anyType, final List<String> anyTypeClasses, final AnyObjectFormLayoutInfo formLayoutInfo, final PageReference pageRef) { super(null, anyTypeClasses, formLayoutInfo, pageRef); this.templatable = templatable; if (templatable.getTemplates().containsKey(anyType)) { setItem(new AnyWrapper<>(AnyObjectTO.class.cast(templatable.getTemplates().get(anyType)))); } else { AnyObjectTO anyObjectTO = new AnyObjectTO(); anyObjectTO.setType(anyType); if (templatable instanceof RealmTO) { anyObjectTO.setRealm(String.format("'%s'", RealmTO.class.cast(templatable).getFullPath())); } setItem(new AnyWrapper<>(anyObjectTO)); } }
@Override protected void onClickCreate(final AjaxRequestTarget target) { this.wizardBuilder.setParentPath(realmChoicePanel.getCurrentRealm().getFullPath()); send(this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<RealmTO>(new RealmTO(), target) { @Override public String getEventDescription() { return "realm.new"; } }); }
@Override protected RealmTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException { String fullPath = null; if (ArrayUtils.isNotEmpty(args)) { for (int i = 0; fullPath == null && i < args.length; i++) { if (args[i] instanceof String) { fullPath = (String) args[i]; } else if (args[i] instanceof RealmTO) { fullPath = ((RealmTO) args[i]).getFullPath(); } } } if (fullPath != null) { try { return binder.getRealmTO(realmDAO.findByFullPath(fullPath), true); } catch (Throwable e) { LOG.debug("Unresolved reference", e); throw new UnresolvedReferenceException(e); } } throw new UnresolvedReferenceException(); }
@Override protected void onClickDelete(final AjaxRequestTarget target, final RealmTO realmTO) { try { if (realmTO.getKey() == null) { throw new Exception("Root realm cannot be deleted"); } realmRestClient.delete(realmTO.getFullPath()); RealmTO parent = realmChoicePanel.moveToParentRealm(realmTO.getKey()); target.add(realmChoicePanel.reloadRealmTree(target)); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); updateRealmContent(parent, selectedIndex); target.add(content); } catch (Exception e) { LOG.error("While deleting realm", e); // Escape line breaks SyncopeConsoleSession.get().error(e.getMessage().replace("\n", " ")); } ((BasePage) Realms.this.getPage()).getNotificationPanel().refresh(target); } });
if (realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) { precond = StringUtils.EMPTY; } else {
private List<ProvisioningReport> provision(final SyncDelta delta, final OrgUnit orgUnit) throws JobExecutionException { if (!profile.getTask().isPerformCreate()) { LOG.debug("PullTask not configured for create"); finalize(UnmatchingRule.toEventName(UnmatchingRule.PROVISION), Result.SUCCESS, null, null, delta); return Collections.<ProvisioningReport>emptyList(); } RealmTO realmTO = connObjectUtils.getRealmTO(delta.getObject(), profile.getTask(), orgUnit); if (realmTO.getFullPath() == null) { if (realmTO.getParent() == null) { realmTO.setParent(profile.getTask().getDestinatioRealm().getFullPath()); } realmTO.setFullPath(realmTO.getParent() + "/" + realmTO.getName()); } ProvisioningReport result = new ProvisioningReport(); result.setOperation(ResourceOperation.CREATE); result.setAnyType(REALM_TYPE); result.setStatus(ProvisioningReport.Status.SUCCESS); result.setName(realmTO.getFullPath()); if (profile.isDryRun()) { result.setKey(null); finalize(UnmatchingRule.toEventName(UnmatchingRule.PROVISION), Result.SUCCESS, null, null, delta); } else { for (PullActions action : profile.getActions()) { action.beforeProvision(profile, delta, realmTO); } create(realmTO, delta, UnmatchingRule.PROVISION, result); } return Collections.singletonList(result); }
result.setMessage(String.format("Realm '%s' not found", key)); } else { result.setName(before.getFullPath());
private List<ProvisioningReport> assign(final SyncDelta delta, final OrgUnit orgUnit) throws JobExecutionException { if (!profile.getTask().isPerformCreate()) { LOG.debug("PullTask not configured for create"); finalize(UnmatchingRule.toEventName(UnmatchingRule.ASSIGN), Result.SUCCESS, null, null, delta); return Collections.<ProvisioningReport>emptyList(); } RealmTO realmTO = connObjectUtils.getRealmTO(delta.getObject(), profile.getTask(), orgUnit); if (realmTO.getFullPath() == null) { if (realmTO.getParent() == null) { realmTO.setParent(profile.getTask().getDestinatioRealm().getFullPath()); } realmTO.setFullPath(realmTO.getParent() + "/" + realmTO.getName()); } realmTO.getResources().add(profile.getTask().getResource().getKey()); ProvisioningReport result = new ProvisioningReport(); result.setOperation(ResourceOperation.CREATE); result.setAnyType(REALM_TYPE); result.setStatus(ProvisioningReport.Status.SUCCESS); result.setName(realmTO.getFullPath()); if (profile.isDryRun()) { result.setKey(null); finalize(UnmatchingRule.toEventName(UnmatchingRule.ASSIGN), Result.SUCCESS, null, null, delta); } else { for (PullActions action : profile.getActions()) { action.beforeAssign(profile, delta, realmTO); } create(realmTO, delta, UnmatchingRule.ASSIGN, result); } return Collections.singletonList(result); }
final ActionsPanel<RealmTO> actionPanel = new ActionsPanel<>("actions", null); if (realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) {
if (realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) { realm = realmTO.getFullPath(); dynRealm = null; } else { userTO.setRealm(realmTO.getFullPath()); panel = new UserDirectoryPanel.Builder( anyTypeClassRestClient.list(anyTypeTO.getClasses()), groupTO.setRealm(realmTO.getFullPath()); panel = new GroupDirectoryPanel.Builder( anyTypeClassRestClient.list(anyTypeTO.getClasses()), anyObjectTO.setRealm(realmTO.getFullPath()); anyObjectTO.setType(anyTypeTO.getKey()); panel = new AnyObjectDirectoryPanel.Builder(