io.imunity.scim.user.mapping.evaluation.ReferenceMappingEvaluator Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package io.imunity.scim.user.mapping.evaluation;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import jakarta.ws.rs.core.UriBuilder;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;
import io.imunity.scim.config.AttributeDefinitionWithMapping;
import io.imunity.scim.config.ReferenceAttributeMapping;
import io.imunity.scim.config.ReferenceAttributeMapping.ReferenceType;
import io.imunity.scim.group.GroupRestController;
import io.imunity.scim.user.UserRestController;
import pl.edu.icm.unity.base.exceptions.EngineException;
import pl.edu.icm.unity.base.utils.Log;
@Component
class ReferenceMappingEvaluator implements MappingEvaluator
{
private static final Logger log = Log.getLogger(Log.U_SERVER_SCIM, ReferenceMappingEvaluator.class);
private final MVELEvaluator mvelEvaluator;
private final DataArrayResolver dataArrayResolver;
ReferenceMappingEvaluator(MVELEvaluator mvelEvaluator, DataArrayResolver dataArrayResolver)
{
this.mvelEvaluator = mvelEvaluator;
this.dataArrayResolver = dataArrayResolver;
}
@Override
public String getId()
{
return ReferenceAttributeMapping.id;
}
@Override
public EvaluationResult eval(AttributeDefinitionWithMapping attributeDefinitionWithMapping,
EvaluatorContext context, MappingEvaluatorRegistry registry) throws EngineException
{
log.debug("Eval reference mapping for attribute {}", attributeDefinitionWithMapping.attributeDefinition.name);
ReferenceAttributeMapping mapping = (ReferenceAttributeMapping) attributeDefinitionWithMapping.attributeMapping;
return attributeDefinitionWithMapping.attributeDefinition.multiValued
? evalMulti(attributeDefinitionWithMapping, context, registry, mapping)
: evalSingle(attributeDefinitionWithMapping, context, registry, mapping);
}
private EvaluationResult evalMulti(AttributeDefinitionWithMapping attributeDefinitionWithMapping,
EvaluatorContext context, MappingEvaluatorRegistry registry, ReferenceAttributeMapping mapping)
throws EngineException
{
if (attributeDefinitionWithMapping.attributeMapping.getDataArray().isEmpty())
{
return EvaluationResult.builder().withAttributeName(attributeDefinitionWithMapping.attributeDefinition.name)
.build();
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy