@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_DELETE + "')") public ResourceTO delete(final String key) { ExternalResource resource = resourceDAO.authFind(key); if (resource == null) { throw new NotFoundException("Resource '" + key + "'"); } Set<String> effectiveRealms = RealmUtils.getEffective( AuthContextUtils.getAuthorizations().get(StandardEntitlement.RESOURCE_DELETE), resource.getConnector().getAdminRealm().getFullPath()); securityChecks(effectiveRealms, resource.getConnector().getAdminRealm().getFullPath(), resource.getKey()); ResourceTO resourceToDelete = binder.getResourceTO(resource); resourceDAO.delete(key); return resourceToDelete; }
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_HISTORY_LIST + "')") @Transactional(readOnly = true) public List<ResourceHistoryConfTO> list(final String key) { ExternalResource resource = resourceDAO.find(key); if (resource == null) { throw new NotFoundException("Resource '" + key + "'"); } return resourceHistoryConfDAO.findByEntity(resource).stream(). map(binder::getResourceHistoryConfTO).collect(Collectors.toList()); }
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_LIST + "')") @Transactional(readOnly = true) public List<ResourceTO> list() { return resourceDAO.findAll().stream().map(binder::getResourceTO).collect(Collectors.toList()); }
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_UPDATE + "')") public ResourceTO update(final ResourceTO resourceTO) { ExternalResource resource = resourceDAO.authFind(resourceTO.getKey()); if (resource == null) { throw new NotFoundException("Resource '" + resourceTO.getKey() + "'"); } Set<String> effectiveRealms = RealmUtils.getEffective( AuthContextUtils.getAuthorizations().get(StandardEntitlement.RESOURCE_UPDATE), resource.getConnector().getAdminRealm().getFullPath()); securityChecks(effectiveRealms, resource.getConnector().getAdminRealm().getFullPath(), resource.getKey()); return binder.getResourceTO(resourceDAO.save(binder.update(resource, resourceTO))); }
@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); } }
@Override public void delete(final String key) { ConnInstance connInstance = find(key); if (connInstance == null) { return; } connInstance.getResources().stream(). map(Entity::getKey).collect(Collectors.toList()). forEach(resource -> resourceDAO.delete(resource)); connInstanceHistoryConfDAO.deleteByEntity(connInstance); entityManager().remove(connInstance); connRegistry.unregisterConnector(key); } }
inUse = !resourceDAO.findByTransformer(implementation).isEmpty(); break; inUse = !resourceDAO.findByPropagationActions(implementation).isEmpty(); break;
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_READ + "')") @Transactional(readOnly = true) public ResourceTO read(final String key) { ExternalResource resource = resourceDAO.authFind(key); if (resource == null) { throw new NotFoundException("Resource '" + key + "'"); } return binder.getResourceTO(resource); }
@Override public void delete(final String key) { VirSchema schema = find(key); if (schema == null) { return; } schema.getLabels().forEach(label -> label.setSchema(null)); resourceDAO.deleteMapping(key); if (schema.getAnyTypeClass() != null) { schema.getAnyTypeClass().getVirSchemas().remove(schema); } entityManager().remove(schema); } }
numbersInfo.setTotalResources(resourceDAO.count());
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_CREATE + "')") public ResourceTO create(final ResourceTO resourceTO) { if (StringUtils.isBlank(resourceTO.getKey())) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing); sce.getElements().add("Resource key"); throw sce; } ConnInstance connInstance = connInstanceDAO.authFind(resourceTO.getConnector()); if (connInstance == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidExternalResource); sce.getElements().add("Connector " + resourceTO.getConnector()); throw sce; } Set<String> effectiveRealms = RealmUtils.getEffective( AuthContextUtils.getAuthorizations().get(StandardEntitlement.RESOURCE_CREATE), connInstance.getAdminRealm().getFullPath()); securityChecks(effectiveRealms, connInstance.getAdminRealm().getFullPath(), null); if (resourceDAO.authFind(resourceTO.getKey()) != null) { throw new DuplicateException(resourceTO.getKey()); } return binder.getResourceTO(resourceDAO.save(binder.create(resourceTO))); }
policyTO.setDescription(policy.getDescription()); for (ExternalResource resource : resourceDAO.findByPolicy(policy)) { policyTO.getUsedByResources().add(resource.getKey());
private Triple<ExternalResource, AnyType, Provision> connObjectInit( final String resourceKey, final String anyTypeKey) { ExternalResource resource = resourceDAO.authFind(resourceKey); if (resource == null) { throw new NotFoundException("Resource '" + resourceKey + "'"); } AnyType anyType = anyTypeDAO.find(anyTypeKey); if (anyType == null) { throw new NotFoundException("AnyType '" + anyTypeKey + "'"); } Optional<? extends Provision> provision = resource.getProvision(anyType); if (!provision.isPresent()) { throw new NotFoundException("Provision on resource '" + resourceKey + "' for type '" + anyTypeKey + "'"); } return ImmutableTriple.of(resource, anyType, provision.get()); }
@Override public void delete(final String key) { final DerSchema schema = find(key); if (schema == null) { return; } schema.getLabels().forEach(label -> label.setSchema(null)); resourceDAO.deleteMapping(key); if (schema.getAnyTypeClass() != null) { schema.getAnyTypeClass().getDerSchemas().remove(schema); } entityManager().remove(schema); } }
type, resourceDAO.find(resource), notificationDAO.find(notification), anyTypeKind, entityKey); type, resourceDAO.find(resource), notificationDAO.find(notification), anyTypeKind, entityKey, page, size, orderByClauses).stream(). <T>map(task -> binder.getTaskTO(task, taskUtilsFactory.getInstance(type), details)).
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_UPDATE + "')") public void removeSyncToken(final String key, final String anyTypeKey) { ExternalResource resource = resourceDAO.authFind(key); if (resource == null) { throw new NotFoundException("Resource '" + key + "'"); } if (SyncopeConstants.REALM_ANYTYPE.equals(anyTypeKey)) { if (resource.getOrgUnit() == null) { throw new NotFoundException("Realm provision not enabled for Resource '" + key + "'"); } resource.getOrgUnit().setSyncToken(null); } else { AnyType anyType = anyTypeDAO.find(anyTypeKey); if (anyType == null) { throw new NotFoundException("AnyType '" + anyTypeKey + "'"); } Optional<? extends Provision> provision = resource.getProvision(anyType); if (!provision.isPresent()) { throw new NotFoundException("Provision for AnyType '" + anyTypeKey + "' in Resource '" + key + "'"); } provision.get().setSyncToken(null); } Set<String> effectiveRealms = RealmUtils.getEffective( AuthContextUtils.getAuthorizations().get(StandardEntitlement.RESOURCE_UPDATE), resource.getConnector().getAdminRealm().getFullPath()); securityChecks(effectiveRealms, resource.getConnector().getAdminRealm().getFullPath(), resource.getKey()); resourceDAO.save(resource); }
@Transactional(readOnly = true) @Override public void load() { // This is needed in order to avoid encoding problems when sending error messages via REST CurrentLocale.set(Locale.ENGLISH); // Load all connector bundles connIdBundleManager.getConnManagers(); // Load all resource-specific connectors int connectors = 0; for (ExternalResource resource : resourceDAO.findAll()) { LOG.info("Registering resource-connector pair {}-{}", resource, resource.getConnector()); try { registerConnector(resource); connectors++; } catch (Exception e) { LOG.error("While registering resource-connector pair {}-{}", resource, resource.getConnector(), e); } } LOG.info("Done loading {} connectors", connectors); }
OperationOptions options; if (SyncopeConstants.REALM_ANYTYPE.equals(anyTypeKey)) { resource = resourceDAO.authFind(key); if (resource == null) { throw new NotFoundException("Resource '" + key + "'");
@Override public void delete(final String key) { PlainSchema schema = find(key); if (schema == null) { return; } schema.getLabels().forEach(label -> label.setSchema(null)); deleteAttrs(schema); resourceDAO.deleteMapping(key); if (schema.getAnyTypeClass() != null) { schema.getAnyTypeClass().getPlainSchemas().remove(schema); } entityManager().remove(schema); } }