@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_READ + "')") @Transactional(readOnly = true) public AnyTypeTO read(final String key) { AnyType anyType = anyTypeDAO.find(key); if (anyType == null) { LOG.error("Could not find anyType '" + key + "'"); throw new NotFoundException(key); } return binder.getAnyTypeTO(anyType); }
protected Pair<TO, List<LogicActions>> beforeCreate(final TO input) { Realm realm = realmDAO.findByFullPath(input.getRealm()); if (realm == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRealm); sce.getElements().add(input.getRealm()); throw sce; } AnyType anyType = input instanceof UserTO ? anyTypeDAO.findUser() : input instanceof GroupTO ? anyTypeDAO.findGroup() : anyTypeDAO.find(input.getType()); if (anyType == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType); sce.getElements().add(input.getType()); throw sce; } TO any = input; templateUtils.apply(any, realm.getTemplate(anyType)); List<LogicActions> actions = getActions(realm); for (LogicActions action : actions) { any = action.beforeCreate(any); } LOG.debug("Input: {}\nOutput: {}\n", input, any); return ImmutablePair.of(any, actions); }
AnyType anyType = anyTypeDAO.find(type); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), type); AnyType anyType = anyTypeDAO.find(typeExtTO.getAnyType()); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), typeExtTO.getAnyType());
final AnyType anyType = anyTypeDAO.find(intAttrName.getRelationshipAnyType()); if (relationshipType == null || groupableRelatable.getRelationships(relationshipType).isEmpty()) { LOG.warn("No relationship for type {} in {}, ignoring",
AnyType anyType = anyTypeDAO.find(entry.getKey()); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), entry.getKey()); AnyType anyType = anyTypeDAO.find(typeExtTO.getAnyType()); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), typeExtTO.getAnyType());
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_DELETE + "')") public AnyTypeTO delete(final String key) { AnyType anyType = anyTypeDAO.find(key); if (anyType == null) { LOG.error("Could not find anyType '" + key + "'"); throw new NotFoundException(key); } Integer anyObjects = anyObjectDAO.countByType().get(anyType); if (anyObjects != null && anyObjects > 0) { LOG.error("{} AnyObject instances found for {}, aborting", anyObjects, anyType); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType); sce.getElements().add("AnyObject instances found for " + key); throw sce; } try { return binder.delete(anyType); } catch (IllegalArgumentException e) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add(e.getMessage()); throw sce; } }
AnyType anyType = anyTypeDAO.find(type); if (anyType == null) { LOG.debug("Invalid AnyType {} specified, ignoring...", type);
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_CREATE + "')") public AnyTypeTO create(final AnyTypeTO anyTypeTO) { if (StringUtils.isBlank(anyTypeTO.getKey())) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing); sce.getElements().add(AnyType.class.getSimpleName() + " key"); throw sce; } if (anyTypeDAO.find(anyTypeTO.getKey()) != null) { throw new DuplicateException(anyTypeTO.getKey()); } return binder.getAnyTypeTO(anyTypeDAO.save(binder.create(anyTypeTO))); }
@Override public DynRealm update(final DynRealm toBeUpdated, final DynRealmTO dynRealmTO) { toBeUpdated.setKey(dynRealmTO.getKey()); DynRealm dynRealm = dynRealmDAO.save(toBeUpdated); for (Iterator<? extends DynRealmMembership> itor = dynRealm.getDynMemberships().iterator(); itor.hasNext();) { DynRealmMembership memb = itor.next(); memb.setDynRealm(null); itor.remove(); } dynRealmDAO.clearDynMembers(dynRealm); dynRealmTO.getDynMembershipConds().forEach((type, fiql) -> { AnyType anyType = anyTypeDAO.find(type); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), type); } else { setDynMembership(dynRealm, anyType, fiql); } }); return dynRealmDAO.saveAndRefreshDynMemberships(dynRealm); }
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 protected AnyTypeTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException { String key = null; if (ArrayUtils.isNotEmpty(args)) { for (int i = 0; key == null && i < args.length; i++) { if (args[i] instanceof String) { key = (String) args[i]; } else if (args[i] instanceof AnyTypeTO) { key = ((AnyTypeTO) args[i]).getKey(); } } } if (StringUtils.isNotBlank(key)) { try { return binder.getAnyTypeTO(anyTypeDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); }
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_UPDATE + "')") public AnyTypeTO update(final AnyTypeTO anyTypeTO) { AnyType anyType = anyTypeDAO.find(anyTypeTO.getKey()); if (anyType == null) { LOG.error("Could not find anyType '" + anyTypeTO.getKey() + "'"); throw new NotFoundException(anyTypeTO.getKey()); } binder.update(anyType, anyTypeTO); anyType = anyTypeDAO.save(anyType); return binder.getAnyTypeTO(anyTypeDAO.save(anyType)); }
private void setTemplates(final RealmTO realmTO, final Realm realm) { // validate JEXL expressions from templates and proceed if fine templateUtils.check(realmTO.getTemplates(), ClientExceptionType.InvalidRealm); realmTO.getTemplates().forEach((key, template) -> { AnyType type = anyTypeDAO.find(key); if (type == null) { LOG.debug("Invalid AnyType {} specified, ignoring...", key); } else { AnyTemplateRealm anyTemplate = realm.getTemplate(type).orElse(null); if (anyTemplate == null) { anyTemplate = entityFactory.newEntity(AnyTemplateRealm.class); anyTemplate.setAnyType(type); anyTemplate.setRealm(realm); realm.add(anyTemplate); } anyTemplate.set(template); } }); // remove all templates not contained in the TO realm.getTemplates(). removeIf(template -> !realmTO.getTemplates().containsKey(template.getAnyType().getKey())); }
forEachOrdered((entry) -> { AnyType anyType = anyTypeDAO.find(entry.getKey()); if (anyType == null) { LOG.debug("Invalid AnyType {} specified, ignoring...", entry.getKey());
@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); }
AnyType anyType = anyTypeDAO.find(anyTypeKey); if (anyType == null) { throw new NotFoundException("AnyType '" + anyTypeKey + "'");
throw sce; AnyType anyType = anyTypeDAO.find(schemaTO.getAnyType()); if (anyType == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSchemaDefinition);
@Override public void create(final AnyObject anyObject, final AnyObjectTO anyObjectTO) { AnyType type = anyTypeDAO.find(anyObjectTO.getType()); if (type == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType);