Search in sources :

Example 46 with IntrospectionException

use of java.beans.IntrospectionException in project CzechIdMng by bcvsolutions.

the class IdentityMonitoredFieldsProcessor method process.

@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
    List<String> fields = getCommaSeparatedValues((String) this.getConfigurationMap().get(PROPERTY_MONITORED_FIELDS));
    String recipientsRole = (String) this.getConfigurationMap().get(PROPERTY_RECIPIENTS_ROLE);
    if (CollectionUtils.isEmpty(fields)) {
        LOG.debug("None monitored fields found in configuration.");
        return new DefaultEventResult<>(event, this);
    }
    List<IdmIdentityDto> recipients = service.findAllByRoleName(recipientsRole);
    if (CollectionUtils.isEmpty(recipients)) {
        LOG.debug("None recievers found in configuration.");
        return new DefaultEventResult<>(event, this);
    }
    IdmIdentityDto newIdentity = event.getContent();
    IdmIdentityDto identity = event.getOriginalSource();
    List<ChangedField> changedFields = new ArrayList<>();
    // Check monitored fields on some changes
    fields.forEach(field -> {
        try {
            Object value = EntityUtils.getEntityValue(identity, field);
            Object newValue = EntityUtils.getEntityValue(newIdentity, field);
            if (value == null && newValue == null) {
                return;
            }
            if (value != null && !value.equals(newValue)) {
                changedFields.add(new ChangedField(field, value.toString(), newValue == null ? null : newValue.toString()));
                return;
            }
            if (newValue != null && !newValue.equals(value)) {
                changedFields.add(new ChangedField(field, value == null ? null : value.toString(), newValue.toString()));
                return;
            }
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
            throw new ResultCodeException(CoreResultCode.BAD_REQUEST, e);
        }
    });
    if (!changedFields.isEmpty()) {
        IdmMessageDto message = new IdmMessageDto.Builder(NotificationLevel.WARNING).addParameter("fullName", service.getNiceLabel(identity)).addParameter("identity", identity).addParameter("changedFields", changedFields).addParameter("url", configurationService.getFrontendUrl(String.format("identity/%s/profile", identity.getId()))).build();
        notificationManager.send(String.format("core:%s", TOPIC), message, recipients);
    }
    return new DefaultEventResult<>(event, this);
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) ArrayList(java.util.ArrayList) IntrospectionException(java.beans.IntrospectionException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Example 47 with IntrospectionException

use of java.beans.IntrospectionException in project CzechIdMng by bcvsolutions.

the class EntityUtils method setEntityValue.

/**
 * Get value from given entity field.
 * If is first parameter in write method String and value is not String, then will be value converted to String.
 *
 * @param entity
 * @param propertyName
 * @param value
 * @return
 * @throws IntrospectionException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 * @throws InvocationTargetException
 */
public static Object setEntityValue(Object entity, String propertyName, Object value) throws IntrospectionException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    Optional<PropertyDescriptor> propertyDescriptionOptional = Arrays.asList(Introspector.getBeanInfo(entity.getClass()).getPropertyDescriptors()).stream().filter(propertyDescriptor -> {
        return propertyName.equals(propertyDescriptor.getName());
    }).findFirst();
    if (!propertyDescriptionOptional.isPresent()) {
        throw new IllegalAccessException("Field " + propertyName + " not found!");
    }
    PropertyDescriptor propertyDescriptor = propertyDescriptionOptional.get();
    Class<?> parameterClass = propertyDescriptor.getWriteMethod().getParameterTypes()[0];
    if (value != null && String.class.equals(parameterClass) && !(value instanceof String)) {
        value = String.valueOf(value);
    }
    if (value != null && !parameterClass.isAssignableFrom(value.getClass()) && !(value.getClass().isPrimitive() || parameterClass.isPrimitive())) {
        throw new IllegalAccessException(MessageFormat.format("Wrong type of value [{0}]. Value must be instance of [{1}] type, but has type [{2}]!", value, parameterClass, value.getClass()));
    }
    return propertyDescriptor.getWriteMethod().invoke(entity, value);
}
Also used : Auditable(eu.bcvsolutions.idm.core.api.domain.Auditable) ValidableEntity(eu.bcvsolutions.idm.core.api.entity.ValidableEntity) Arrays(java.util.Arrays) DateTime(org.joda.time.DateTime) Asserts(org.apache.http.util.Asserts) UUID(java.util.UUID) Field(java.lang.reflect.Field) StringUtils(org.apache.commons.lang3.StringUtils) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MessageFormat(java.text.MessageFormat) Objects(java.util.Objects) LocalDate(org.joda.time.LocalDate) Introspector(java.beans.Introspector) PropertyDescriptor(java.beans.PropertyDescriptor) Optional(java.util.Optional) Assert(org.springframework.util.Assert) PropertyDescriptor(java.beans.PropertyDescriptor)

Example 48 with IntrospectionException

use of java.beans.IntrospectionException in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method fillEntity.

/**
 * Fill entity with attributes from IC module (by mapped attributes).
 *
 * @param mappedAttributes
 * @param uid
 * @param icAttributes
 * @param entity
 * @param create
 *            (is create or update entity situation)
 * @param context
 * @return
 */
protected DTO fillEntity(List<SysSystemAttributeMappingDto> mappedAttributes, String uid, List<IcAttribute> icAttributes, DTO dto, boolean create, SynchronizationContext context) {
    mappedAttributes.stream().filter(attribute -> {
        // Skip disabled attributes
        // Skip extended attributes (we need update/ create entity first)
        // Skip confidential attributes (we need update/ create entity
        // first)
        boolean fastResult = !attribute.isDisabledAttribute() && attribute.isEntityAttribute() && !attribute.isConfidentialAttribute();
        if (!fastResult) {
            return false;
        }
        // Can be value set by attribute strategy?
        return this.canSetValue(uid, attribute, dto, create);
    }).forEach(attribute -> {
        String attributeProperty = attribute.getIdmPropertyName();
        Object transformedValue = getValueByMappedAttribute(attribute, icAttributes, context);
        // Set transformed value from target system to entity
        try {
            EntityUtils.setEntityValue(dto, attributeProperty, transformedValue);
        } catch (IntrospectionException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ProvisioningException e) {
            throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_IDM_FIELD_NOT_SET, ImmutableMap.of("property", attributeProperty, "uid", uid), e);
        }
    });
    return dto;
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) AttributeValueWrapperDto(eu.bcvsolutions.idm.acc.dto.AttributeValueWrapperDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) GroovyScriptService(eu.bcvsolutions.idm.core.api.service.GroovyScriptService) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) Pair(org.apache.commons.lang3.tuple.Pair) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) Map(java.util.Map) SynchronizationUnlinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationUnlinkedActionType) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IcSyncTokenImpl(eu.bcvsolutions.idm.ic.impl.IcSyncTokenImpl) Loggable(eu.bcvsolutions.idm.core.api.domain.Loggable) IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter) Set(java.util.Set) ReconciliationMissingAccountActionType(eu.bcvsolutions.idm.acc.domain.ReconciliationMissingAccountActionType) IntrospectionException(java.beans.IntrospectionException) Serializable(java.io.Serializable) InvocationTargetException(java.lang.reflect.InvocationTargetException) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SynchronizationSituationType(eu.bcvsolutions.idm.acc.domain.SynchronizationSituationType) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) IcSyncResultsHandler(eu.bcvsolutions.idm.ic.api.IcSyncResultsHandler) SynchronizationEventType(eu.bcvsolutions.idm.acc.event.SynchronizationEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) Session(org.hibernate.Session) ArrayList(java.util.ArrayList) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) Lists(com.google.common.collect.Lists) SysSyncConfig(eu.bcvsolutions.idm.acc.entity.SysSyncConfig) IcResultsHandler(eu.bcvsolutions.idm.ic.filter.api.IcResultsHandler) CacheManager(org.springframework.cache.CacheManager) WorkflowProcessInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowProcessInstanceService) SynchronizationLinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationLinkedActionType) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcOrFilter(eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) SysSchemaObjectClass_(eu.bcvsolutions.idm.acc.entity.SysSchemaObjectClass_) IcFilterBuilder(eu.bcvsolutions.idm.ic.filter.impl.IcFilterBuilder) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) Throwables(com.google.common.base.Throwables) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) EntityManager(javax.persistence.EntityManager) LocalDateTime(org.joda.time.LocalDateTime) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) VariableScope(org.activiti.engine.delegate.VariableScope) BaseFilter(eu.bcvsolutions.idm.core.api.dto.filter.BaseFilter) SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SynchronizationEntityExecutor(eu.bcvsolutions.idm.acc.service.api.SynchronizationEntityExecutor) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) SysSyncActionLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncActionLogService) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) OperationResultType(eu.bcvsolutions.idm.acc.domain.OperationResultType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IcSyncDeltaTypeEnum(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SynchronizationMissingEntityActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationMissingEntityActionType) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Pageable(org.springframework.data.domain.Pageable) SysSyncConfigService(eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService) SysSyncLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncLogService) AbstractLongRunningTaskExecutor(eu.bcvsolutions.idm.core.scheduler.api.service.AbstractLongRunningTaskExecutor) ImmutableMap(com.google.common.collect.ImmutableMap) ReadWriteDtoService(eu.bcvsolutions.idm.core.api.service.ReadWriteDtoService) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) List(java.util.List) EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) Optional(java.util.Optional) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) ValueWrapper(org.springframework.cache.Cache.ValueWrapper) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) Cache(org.springframework.cache.Cache) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) HashMap(java.util.HashMap) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) HashSet(java.util.HashSet) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) CollectionUtils(org.apache.commons.collections.CollectionUtils) SynchronizationActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationActionType) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) CorrelationFilter(eu.bcvsolutions.idm.core.api.dto.filter.CorrelationFilter) IcSyncDelta(eu.bcvsolutions.idm.ic.api.IcSyncDelta) IcAndFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) DateTime(org.joda.time.DateTime) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Beta(com.google.common.annotations.Beta) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SynchronizationService(eu.bcvsolutions.idm.acc.service.api.SynchronizationService) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IcFilterOperationType(eu.bcvsolutions.idm.ic.domain.IcFilterOperationType) SysSyncItemLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncItemLogService) IcSyncToken(eu.bcvsolutions.idm.ic.api.IcSyncToken) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IntrospectionException(java.beans.IntrospectionException) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 49 with IntrospectionException

use of java.beans.IntrospectionException in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemAttributeMappingService method getAttributeValue.

/**
 * Find value for this mapped attribute by property name. Returned value can be list of objects. Returns transformed value.
 *
 * @param uid - Account identifier
 * @param entity
 * @param attributeHandling
 * @param idmValue
 * @return
 * @throws IntrospectionException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
@Override
public Object getAttributeValue(String uid, AbstractDto entity, AttributeMapping attributeHandling) {
    Object idmValue = null;
    // 
    SysSchemaAttributeDto schemaAttributeDto = getSchemaAttribute(attributeHandling);
    // 
    if (attributeHandling.isExtendedAttribute() && entity != null && formService.isFormable(entity.getClass())) {
        List<IdmFormValueDto> formValues = formService.getValues(entity, attributeHandling.getIdmPropertyName());
        if (formValues.isEmpty()) {
            idmValue = null;
        } else if (schemaAttributeDto.isMultivalued()) {
            // Multiple value extended attribute
            List<Object> values = new ArrayList<>();
            formValues.stream().forEachOrdered(formValue -> {
                values.add(formValue.getValue());
            });
            idmValue = values;
        } else {
            // Single value extended attribute
            IdmFormValueDto formValue = formValues.get(0);
            if (formValue.isConfidential()) {
                Object confidentialValue = formService.getConfidentialPersistentValue(formValue);
                // If is confidential value String and schema attribute is GuardedString type, then convert to GuardedString will be did.
                if (confidentialValue instanceof String && schemaAttributeDto.getClassType().equals(GuardedString.class.getName())) {
                    idmValue = new GuardedString((String) confidentialValue);
                } else {
                    idmValue = confidentialValue;
                }
            } else {
                idmValue = formValue.getValue();
            }
        }
    } else // Find value from entity
    if (attributeHandling.isEntityAttribute()) {
        if (attributeHandling.isConfidentialAttribute()) {
            // If is attribute isConfidential, then we will find value in
            // secured storage
            idmValue = confidentialStorage.getGuardedString(entity.getId(), entity.getClass(), attributeHandling.getIdmPropertyName());
        } else {
            try {
                // We will search value directly in entity by property name
                idmValue = EntityUtils.getEntityValue(entity, attributeHandling.getIdmPropertyName());
            } catch (IntrospectionException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ProvisioningException o_O) {
                throw new ProvisioningException(AccResultCode.PROVISIONING_IDM_FIELD_NOT_FOUND, ImmutableMap.of("property", attributeHandling.getIdmPropertyName(), "entityType", entity.getClass()), o_O);
            }
        }
    } else {
    // If Attribute value is not in entity nor in extended attribute, then idmValue is null.
    // It means attribute is static ... we will call transformation to resource.
    }
    return this.transformValueToResource(uid, idmValue, attributeHandling, entity);
}
Also used : IdmScriptCategory(eu.bcvsolutions.idm.core.api.domain.IdmScriptCategory) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSystemAttributeMappingRepository(eu.bcvsolutions.idm.acc.repository.SysSystemAttributeMappingRepository) FormPropertyManager(eu.bcvsolutions.idm.acc.service.api.FormPropertyManager) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) PluginRegistry(org.springframework.plugin.core.PluginRegistry) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) GroovyScriptService(eu.bcvsolutions.idm.core.api.service.GroovyScriptService) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) Pageable(org.springframework.data.domain.Pageable) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) ImmutableMap(com.google.common.collect.ImmutableMap) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysSyncConfigRepository(eu.bcvsolutions.idm.acc.repository.SysSyncConfigRepository) List(java.util.List) SysRoleSystemAttributeRepository(eu.bcvsolutions.idm.acc.repository.SysRoleSystemAttributeRepository) Optional(java.util.Optional) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) OrderAwarePluginRegistry(org.springframework.plugin.core.OrderAwarePluginRegistry) IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) HashMap(java.util.HashMap) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) Service(org.springframework.stereotype.Service) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) AbstractReadWriteDtoService(eu.bcvsolutions.idm.core.api.service.AbstractReadWriteDtoService) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) SysSchemaObjectClass_(eu.bcvsolutions.idm.acc.entity.SysSchemaObjectClass_) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractScriptEvaluator(eu.bcvsolutions.idm.core.script.evaluator.AbstractScriptEvaluator) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) ArrayList(java.util.ArrayList) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 50 with IntrospectionException

use of java.beans.IntrospectionException in project CzechIdMng by bcvsolutions.

the class CzechIdMIcConvertUtil method convertIcConnectorConfiguration.

public static ConfigurationClass convertIcConnectorConfiguration(IcConnectorConfiguration configuration, Class<? extends ConfigurationClass> configurationClass) {
    if (configuration == null || configuration.getConfigurationProperties() == null || configuration.getConfigurationProperties().getProperties() == null) {
        return null;
    }
    List<IcConfigurationProperty> properties = configuration.getConfigurationProperties().getProperties();
    try {
        ConfigurationClass configurationClassInstance = configurationClass.newInstance();
        PropertyDescriptor[] descriptors;
        descriptors = Introspector.getBeanInfo(configurationClass).getPropertyDescriptors();
        Lists.newArrayList(descriptors).stream().forEach(descriptor -> {
            String propertyName = descriptor.getName();
            Method writeMethod = descriptor.getWriteMethod();
            IcConfigurationProperty propertyToConvert = properties.stream().filter(property -> propertyName.equals(property.getName())).findFirst().orElse(null);
            if (propertyToConvert == null) {
                return;
            }
            try {
                writeMethod.invoke(configurationClassInstance, propertyToConvert.getValue());
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                throw new IcException(e);
            }
        });
        return configurationClassInstance;
    } catch (IntrospectionException | InstantiationException | IllegalAccessException e) {
        throw new IcException(e);
    }
}
Also used : ConfigurationClass(eu.bcvsolutions.idm.core.api.domain.ConfigurationClass) PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException) IcException(eu.bcvsolutions.idm.ic.exception.IcException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)

Aggregations

IntrospectionException (java.beans.IntrospectionException)111 PropertyDescriptor (java.beans.PropertyDescriptor)65 Method (java.lang.reflect.Method)46 BeanInfo (java.beans.BeanInfo)44 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)24 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)17 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)10 Field (java.lang.reflect.Field)9 EventSetDescriptor (java.beans.EventSetDescriptor)7 List (java.util.List)6 Map (java.util.Map)6 MessageFormat (java.text.MessageFormat)5 UUID (java.util.UUID)5 Assert (org.springframework.util.Assert)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Optional (java.util.Optional)4 RecursiveChildrenListManager (cern.gp.explorer.test.helpers.RecursiveChildrenListManager)3 SimpleDemoBean (cern.gp.explorer.test.helpers.SimpleDemoBean)3