Realm realm = realmDAO.findByFullPath(userTO.getRealm()); if (realm != null) { realmDAO.findAncestors(realm).stream(). filter(ancestor -> ancestor.getPasswordPolicy() != null). forEach(ancestor -> {
RealmUtils.normalize(adminRealms).forEach(realmPath -> { if (realmPath.startsWith("/")) { Realm realm = realmDAO.findByFullPath(realmPath); if (realm == null) { SyncopeClientException noRealm = SyncopeClientException.build(ClientExceptionType.InvalidRealm); throw noRealm; } else { realmKeys.addAll(realmDAO.findDescendants(realm).stream(). map(Entity::getKey).collect(Collectors.toSet())); realmKeys.addAll(realmDAO.findAll().stream(). map(Entity::getKey).collect(Collectors.toSet()));
switch (connObjectKeyItem.get().getIntAttrName()) { case "key": realm = realmDAO.find(connObjectKey); if (realm != null) { result.add(realm.getKey()); if (orgUnit.isIgnoreCaseMatch()) { final String realmName = connObjectKey; result.addAll(realmDAO.findAll().stream(). filter(r -> r.getName().equalsIgnoreCase(realmName)). map(Entity::getKey).collect(Collectors.toList())); } else { result.addAll(realmDAO.findByName(connObjectKey).stream(). map(Entity::getKey).collect(Collectors.toList())); realm = realmDAO.findByFullPath(connObjectKey); if (realm != null) { result.add(realm.getKey());
@PreAuthorize("isAuthenticated()") @Transactional(readOnly = true) public List<RealmTO> list(final String fullPath) { Realm realm = realmDAO.findByFullPath(fullPath); if (realm == null) { LOG.error("Could not find realm '" + fullPath + "'"); throw new NotFoundException(fullPath); } final boolean admin = AuthContextUtils.getAuthorizations().keySet().contains(StandardEntitlement.REALM_LIST); return realmDAO.findDescendants(realm).stream(). map(descendant -> binder.getRealmTO(descendant, admin)).collect(Collectors.toList()); }
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; }
protected Realm check(final AssignableCond cond) { Realm realm = realmDAO.findByFullPath(cond.getRealmFullPath()); if (realm == null) { LOG.error("Could not find realm for '" + cond.getRealmFullPath() + "'"); throw new IllegalArgumentException(); } return realm; }
@PreAuthorize("hasRole('" + StandardEntitlement.REALM_DELETE + "')") public ProvisioningResult<RealmTO> delete(final String fullPath) { Realm realm = realmDAO.findByFullPath(fullPath); if (realm == null) { LOG.error("Could not find realm '" + fullPath + "'"); if (!realmDAO.findChildren(realm).isEmpty()) { throw SyncopeClientException.build(ClientExceptionType.HasChildren); result.getPropagationStatuses().addAll(propagationReporter.getStatuses()); realmDAO.delete(realm);
Realm parent; if (StringUtils.isBlank(realmTO.getParent())) { parent = realmDAO.findByFullPath(parentPath); if (parent == null) { LOG.error("Could not find parent realm " + parentPath); parent = realmDAO.find(realmTO.getParent()); if (parent == null) { LOG.error("Could not find parent realm " + realmTO.getParent()); if (realmDAO.findByFullPath(fullPath) != null) { throw new DuplicateException(fullPath); Realm realm = realmDAO.save(binder.create(parent, realmTO));
result.setStatus(ProvisioningReport.Status.SUCCESS); Realm realm = realmDAO.find(key); RealmTO before = binder.getRealmTO(realm, true); if (before == null) { if (!realmDAO.findChildren(realm).isEmpty()) { throw SyncopeClientException.build(ClientExceptionType.HasChildren); taskExecutor.execute(taskInfos, false); realmDAO.delete(realm);
private List<AccountPolicy> getAccountPolicies(final User user) { List<AccountPolicy> policies = new ArrayList<>(); // add resource policies findAllResources(user).stream(). map(resource -> resource.getAccountPolicy()). filter(policy -> policy != null). forEachOrdered(policy -> policies.add(policy)); // add realm policies realmDAO.findAncestors(user.getRealm()).stream(). map(realm -> realm.getAccountPolicy()). filter(policy -> policy != null). forEachOrdered(policy -> policies.add(policy)); return policies; }
protected String getQuery( final AssignableCond cond, final List<Object> parameters, final SearchSupport svs) { Realm realm; try { realm = check(cond); } catch (IllegalArgumentException e) { return EMPTY_QUERY; } StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM "). append(svs.field().name).append(" WHERE ("); if (cond.isFromGroup()) { realmDAO.findDescendants(realm).forEach(current -> { query.append("realm_id=?").append(setParameter(parameters, current.getKey())).append(" OR "); }); query.setLength(query.length() - 4); } else { for (Realm current = realm; current.getParent() != null; current = current.getParent()) { query.append("realm_id=?").append(setParameter(parameters, current.getKey())).append(" OR "); } query.append("realm_id=?").append(setParameter(parameters, realmDAO.getRoot().getKey())); } query.append(')'); return query.toString(); }
@Transactional(propagation = Propagation.REQUIRES_NEW) @Override public boolean handle(final String realmKey) { Realm realm = null; try { realm = realmDAO.find(realmKey); doHandle(realm); return true; } catch (IgnoreProvisionException e) { ProvisioningReport result = new ProvisioningReport(); result.setOperation(ResourceOperation.NONE); result.setAnyType(realm == null ? null : REALM_TYPE); result.setStatus(ProvisioningReport.Status.IGNORE); result.setKey(realmKey); profile.getResults().add(result); LOG.warn("Ignoring during push", e); return true; } catch (JobExecutionException e) { LOG.error("Push failed", e); return false; } }
handler.setProfile(profile); for (Realm realm : realmDAO.findDescendants(profile.getTask().getSourceRealm())) {
@Override public <T extends Policy> void delete(final T policy) { realmDAO.findByPolicy(policy).forEach(realm -> { if (policy instanceof AccountPolicy) { realm.setAccountPolicy(null); } else if (policy instanceof PasswordPolicy) { realm.setPasswordPolicy(null); } }); resourceDAO.findByPolicy(policy).forEach(resource -> { if (policy instanceof AccountPolicy) { resource.setAccountPolicy(null); } else if (policy instanceof PasswordPolicy) { resource.setPasswordPolicy(null); } else if (policy instanceof PullPolicy) { resource.setPullPolicy(null); } else if (policy instanceof PushPolicy) { resource.setPushPolicy(null); } }); entityManager().remove(policy); } }
List<Map<String, String>> realmRows = new ArrayList<>(rows); rows.clear(); realmDAO.findAll().forEach(realm -> { realmRows.stream().filter(row -> { String id = row.get("ID");
Realm realm = realmDAO.save(binder.create(profile.getTask().getDestinatioRealm(), realmTO));
Realm parent = realmDAO.findByFullPath(parentFullPath); if (parent == null) { LOG.warn("Could not find Realm with path {}, ignoring", parentFullPath);
@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 List<PasswordPolicy> getPasswordPolicies(final User user) { List<PasswordPolicy> policies = new ArrayList<>(); PasswordPolicy policy; // add resource policies for (ExternalResource resource : findAllResources(user)) { policy = resource.getPasswordPolicy(); if (policy != null) { policies.add(policy); } } // add realm policies for (Realm realm : realmDAO.findAncestors(user.getRealm())) { policy = realm.getPasswordPolicy(); if (policy != null) { policies.add(policy); } } return policies; }