private SyncopeClientException checkMandatoryOnResources( final Any<?> any, final Collection<? extends ExternalResource> resources) { SyncopeClientException reqValMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing); resources.forEach(resource -> { Optional<? extends Provision> provision = resource.getProvision(any.getType()); if (resource.isEnforceMandatoryCondition() && provision.isPresent()) { List<String> missingAttrNames = evaluateMandatoryCondition(provision.get(), any); if (!missingAttrNames.isEmpty()) { LOG.error("Mandatory schemas {} not provided with values", missingAttrNames); reqValMissing.getElements().addAll(missingAttrNames); } } }); return reqValMissing; }
protected void doHandle( final List<? extends Any<?>> anys, final SyncopePushResultHandler handler, final ExternalResource resource) throws JobExecutionException { for (int i = 0; i < anys.size() && !interrupt; i++) { try { handler.handle(anys.get(i).getKey()); reportHandled( anys.get(i).getType().getKey(), (anys.get(i) instanceof User ? ((User) anys.get(i)).getUsername() : anys.get(i) instanceof Group ? ((Group) anys.get(i)).getName() : ((AnyObject) anys.get(i)).getName())); } catch (Exception e) { LOG.warn("Failure pushing '{}' on '{}'", anys.get(i), resource, e); throw new JobExecutionException("While pushing " + anys.get(i) + " on " + resource, e); } } }
protected Map<String, String> getConnObjectKeys(final Any<?> any, final AnyUtils anyUtils) { Map<String, String> connObjectKeys = new HashMap<>(); anyUtils.getAllResources(any). forEach(resource -> resource.getProvision(any.getType()). filter(provision -> provision.getMapping() != null). ifPresent(provision -> { MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision). orElseThrow(() -> new NotFoundException( "ConnObjectKey mapping for " + any.getType().getKey() + " " + any.getKey() + " on resource '" + resource.getKey() + "'")); mappingManager.getConnObjectKeyValue(any, provision). ifPresent(value -> connObjectKeys.put(resource.getKey(), value)); })); return connObjectKeys; } }
@Transactional @Override public void refreshDynMemberships(final Any<?> any) { findAll().forEach(dynRealm -> { Optional<? extends DynRealmMembership> memb = dynRealm.getDynMembership(any.getType()); if (memb.isPresent()) { Query delete = entityManager().createNativeQuery( "DELETE FROM " + DYNMEMB_TABLE + " WHERE dynRealm_id=? AND any_id=?"); delete.setParameter(1, dynRealm.getKey()); delete.setParameter(2, any.getKey()); delete.executeUpdate(); if (jpaAnySearchDAO().matches(any, SearchCondConverter.convert(memb.get().getFIQLCond()))) { Query insert = entityManager().createNativeQuery("INSERT INTO " + DYNMEMB_TABLE + " VALUES(?, ?)"); insert.setParameter(1, any.getKey()); insert.setParameter(2, dynRealm.getKey()); insert.executeUpdate(); } } }); }
@SuppressWarnings("unchecked") private Pair<Any<?>, Provision> init(final AnyTypeKind anyTypeKind, final String anyKey, final String resourceKey) { AnyUtils anyUtils = anyUtilsFactory.getInstance(anyTypeKind); Any<?> any = anyUtils.dao().authFind(anyKey); if (any == null) { throw new NotFoundException(anyTypeKind + " '" + anyKey + "'"); } ExternalResource resource = resourceDAO.find(resourceKey); if (resource == null) { throw new NotFoundException("Resource '" + resourceKey + "'"); } Provision provision = resource.getProvision(any.getType()).orElseThrow(() -> new NotFoundException("Provision for " + any.getType() + " on Resource '" + resourceKey + "'")); if (provision.getMapping() == null) { throw new NotFoundException("Mapping for " + any.getType() + " on Resource '" + resourceKey + "'"); } return (Pair<Any<?>, Provision>) Pair.of(any, provision); }
typeOwnClasses.addAll(any.getType().getClasses()); typeOwnClasses.addAll(any.getAuxClasses()); ((AnyObject) any).getMemberships().forEach(memb -> { memb.getRightEnd().getTypeExtensions().stream(). filter(typeExtension -> any.getType().equals(typeExtension.getAnyType())). forEachOrdered((typeExtension) -> { typeExtensionClasses.put(memb.getRightEnd(), typeExtension.getAuxClasses());
typeOwnClasses.addAll(any.getType().getClasses()); typeOwnClasses.addAll(any.getAuxClasses()); if (!typeOwnClasses.stream().anyMatch(clazz -> clazz.getPlainSchemas().contains(schema))) {
Provision provision = resource.getProvision(any.getType()).orElse(null); Optional<? extends MappingItem> connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision); final String connObjectKeyValue = connObjectKeyItem.isPresent()
any = getAnyUtils().dao().authFind(anyKey); Provision provision = profile.getTask().getResource().getProvision(any.getType()).orElse(null); if (provision == null) { throw new JobExecutionException("No provision found on " + profile.getTask().getResource() + " for " + any.getType().getKey()); ignoreResult = new ProvisioningReport(); ignoreResult.setKey(anyKey); ignoreResult.setAnyType(any == null ? null : any.getType().getKey());
if (ownedResources.contains(schema.getProvision().getResource())) { VirAttrCacheValue virAttrCacheValue = virAttrCache.get(any.getType().getKey(), any.getKey(), schema.getKey()); } else if (schema.getProvision().getAnyType().equals(any.getType())) { Set<VirSchema> schemasToRead = toRead.get(schema.getProvision()); if (schemasToRead == null) { virAttrCacheValue.setValues(attr.getValue()); virAttrCache.put( any.getType().getKey(), any.getKey(), schema.getKey(), virAttrCacheValue); LOG.debug("Values for {} set in cache: {}", schema, virAttrCacheValue);
@Override public <T extends Any<?>> boolean matches(final T any, final SearchCond cond) { AnyCond keycond = new AnyCond(AttributeCond.Type.EQ); keycond.setSchema("key"); keycond.setExpression(any.getKey()); return !search(SearchCond.getAndCond(SearchCond.getLeafCond(keycond), cond), any.getType().getKind()).isEmpty(); } }
protected void provision(final Any<?> any, final Boolean enable, final ProvisioningReport result) { AnyTO before = getAnyTO(any.getKey()); List<String> noPropResources = new ArrayList<>(before.getResources()); noPropResources.remove(profile.getTask().getResource().getKey()); PropagationByResource propByRes = new PropagationByResource(); propByRes.add(ResourceOperation.CREATE, profile.getTask().getResource().getKey()); List<PropagationTaskInfo> taskInfos = propagationManager.getCreateTasks( any.getType().getKind(), any.getKey(), enable, propByRes, before.getVirAttrs(), noPropResources); if (!taskInfos.isEmpty()) { taskInfos.get(0).setBeforeObj(Optional.ofNullable(null)); PropagationReporter reporter = new DefaultPropagationReporter(); taskExecutor.execute(taskInfos.get(0), reporter); reportPropagation(result, reporter); } }
protected void update( final Any<?> any, final Boolean enable, final ConnectorObject beforeObj, final ProvisioningReport result) { boolean changepwd = any instanceof User; List<String> ownedResources = getAnyUtils().getAllResources(any).stream(). map(Entity::getKey).collect(Collectors.toList()); List<String> noPropResources = new ArrayList<>(ownedResources); noPropResources.remove(profile.getTask().getResource().getKey()); PropagationByResource propByRes = new PropagationByResource(); propByRes.add(ResourceOperation.UPDATE, profile.getTask().getResource().getKey()); propByRes.addOldConnObjectKey(profile.getTask().getResource().getKey(), beforeObj.getUid().getUidValue()); List<PropagationTaskInfo> taskInfos = propagationManager.getUpdateTasks( any.getType().getKind(), any.getKey(), changepwd, enable, propByRes, null, noPropResources); if (!taskInfos.isEmpty()) { taskInfos.get(0).setBeforeObj(Optional.of(beforeObj)); PropagationReporter reporter = new DefaultPropagationReporter(); taskExecutor.execute(taskInfos.get(0), reporter); reportPropagation(result, reporter); } }
filter(resource -> resource.getProvision(any.getType()).isPresent() && resource.getProvision(any.getType()).get().getMapping() != null). forEach(resource -> { MappingUtils.getPropagationItems( resource.getProvision(any.getType()).get().getMapping().getItems()).stream(). filter(item -> (schema.getKey().equals(item.getIntAttrName()))). forEach(item -> {
private ConnObjectTO getOnResource(final Any<?> any, final Provision provision) { -> new NotFoundException("ConnObjectKey for " + any.getType() + " on resource '" + provision.getResource().getKey() + "'")); String connObjectKeyValue = mappingManager.getConnObjectKeyValue(any, provision).orElse(null);
virtualResources.addAll(propByRes.get(ResourceOperation.CREATE)); virtualResources.addAll(propByRes.get(ResourceOperation.UPDATE)); virtualResources.addAll(dao(any.getType().getKind()).findAllResourceKeys(any.getKey())); Provision provision = resource == null ? null : resource.getProvision(any.getType()).orElse(null); List<? extends Item> mappingItems = provision == null ? Collections.<Item>emptyList() } else if (provision == null) { LOG.error("No provision specified on resource {} for type {}, ignoring...", resource, any.getType()); } else if (mappingItems.isEmpty()) { LOG.warn("Requesting propagation for {} but no propagation mapping provided for {}", any.getType(), resource); } else { PropagationTaskInfo task = new PropagationTaskInfo(); task.setResource(resource.getKey()); task.setObjectClassName(provision.getObjectClass().getObjectClassValue()); task.setAnyTypeKind(any.getType().getKind()); task.setAnyType(any.getType().getKey()); if (!deleteOnResource) { task.setEntityKey(any.getKey());
protected void deprovision(final Any<?> any, final ConnectorObject beforeObj, final ProvisioningReport result) { AnyTO before = getAnyTO(any.getKey()); List<String> noPropResources = new ArrayList<>(before.getResources()); noPropResources.remove(profile.getTask().getResource().getKey()); PropagationByResource propByRes = new PropagationByResource(); propByRes.add(ResourceOperation.DELETE, profile.getTask().getResource().getKey()); propByRes.addOldConnObjectKey(profile.getTask().getResource().getKey(), beforeObj.getUid().getUidValue()); List<PropagationTaskInfo> taskInfos = propagationManager.getDeleteTasks( any.getType().getKind(), any.getKey(), propByRes, noPropResources); if (!taskInfos.isEmpty()) { taskInfos.get(0).setBeforeObj(Optional.of(beforeObj)); PropagationReporter reporter = new DefaultPropagationReporter(); taskExecutor.execute(taskInfos.get(0), reporter); reportPropagation(result, reporter); } }
if (any != null) { task.setEntityKey(any.getKey()); task.setAnyTypeKind(any.getType().getKind());
AllowedSchemas<PlainSchema> allowedPlainSchemas = ApplicationContextProvider.getApplicationContext().getBean(AnyUtilsFactory.class). getInstance(any.getType().getKind()).dao().findAllowedSchemas(any, PlainSchema.class);