Search in sources :

Example 66 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class SCIMConfManager method set.

@PreAuthorize("hasRole('" + SCIMEntitlement.SCIM_CONF_SET + "')")
public void set(final SCIMConf conf) {
    try {
        schemaLogic.read(SchemaType.PLAIN, SCIMConf.KEY);
    } catch (NotFoundException e) {
        PlainSchemaTO scimConf = new PlainSchemaTO();
        scimConf.setKey(SCIMConf.KEY);
        scimConf.setType(AttrSchemaType.Binary);
        scimConf.setMimeType(MediaType.APPLICATION_JSON);
        schemaLogic.create(SchemaType.PLAIN, scimConf);
    }
    conf.setLastChangeDate(new Date());
    configurationLogic.set(new AttrTO.Builder().schema(SCIMConf.KEY).value(Base64.encode(POJOHelper.serialize(conf).getBytes())).build());
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 67 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class ConnIdBundleManagerImpl method getConfigurationProperties.

@Override
public ConfigurationProperties getConfigurationProperties(final ConnectorInfo info) {
    if (info == null) {
        throw new NotFoundException("Invalid: connector info is null");
    }
    // create default configuration
    APIConfiguration apiConfig = info.createDefaultAPIConfiguration();
    // retrieve the ConfigurationProperties.
    ConfigurationProperties properties = apiConfig.getConfigurationProperties();
    if (properties == null) {
        throw new NotFoundException("Configuration properties");
    }
    if (LOG.isDebugEnabled()) {
        properties.getPropertyNames().forEach(propName -> {
            LOG.debug("Property Name: {}" + "\nProperty Type: {}", properties.getProperty(propName).getName(), properties.getProperty(propName).getType());
        });
    }
    return properties;
}
Also used : APIConfiguration(org.identityconnectors.framework.api.APIConfiguration) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties)

Example 68 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class ConnIdBundleManagerImpl method initRemote.

private void initRemote(final URI location) {
    // 1. Extract conf params for remote connection from given URI
    String host = location.getHost();
    int port = location.getPort();
    GuardedString key = new GuardedString(location.getUserInfo().toCharArray());
    boolean useSSL = location.getScheme().equals("connids");
    List<TrustManager> trustManagers = new ArrayList<>();
    String[] params = StringUtils.isBlank(location.getQuery()) ? null : location.getQuery().split("&");
    if (params != null && params.length > 0) {
        final String[] trustAllCerts = params[0].split("=");
        if (trustAllCerts != null && trustAllCerts.length > 1 && "trustAllCerts".equalsIgnoreCase(trustAllCerts[0]) && "true".equalsIgnoreCase(trustAllCerts[1])) {
            trustManagers.add(new X509TrustManager() {

                @Override
                public void checkClientTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
                // no checks, trust all
                }

                @Override
                public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
                // no checks, trust all
                }

                @Override
                public X509Certificate[] getAcceptedIssuers() {
                    return null;
                }
            });
        }
    }
    LOG.debug("Configuring remote connector server:" + "\n\tHost: {}" + "\n\tPort: {}" + "\n\tKey: {}" + "\n\tUseSSL: {}" + "\n\tTrustAllCerts: {}", host, port, key, useSSL, !trustManagers.isEmpty());
    RemoteFrameworkConnectionInfo info = new RemoteFrameworkConnectionInfo(host, port, key, useSSL, trustManagers, 60 * 1000);
    LOG.debug("Remote connection info: {}", info);
    // 2. Get connector info manager
    ConnectorInfoManager manager = ConnectorInfoManagerFactory.getInstance().getRemoteManager(info);
    if (manager == null) {
        throw new NotFoundException("Remote ConnectorInfoManager");
    }
    connInfoManagers.put(location, manager);
}
Also used : ArrayList(java.util.ArrayList) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) CertificateException(java.security.cert.CertificateException) GuardedString(org.identityconnectors.common.security.GuardedString) GuardedString(org.identityconnectors.common.security.GuardedString) X509Certificate(java.security.cert.X509Certificate) TrustManager(javax.net.ssl.TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) X509TrustManager(javax.net.ssl.X509TrustManager) RemoteFrameworkConnectionInfo(org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)

Example 69 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class TaskDataBinderImpl method createSchedTask.

@Override
public SchedTask createSchedTask(final SchedTaskTO taskTO, final TaskUtils taskUtils) {
    Class<? extends TaskTO> taskTOClass = taskUtils.taskTOClass();
    if (taskTOClass == null || !taskTOClass.equals(taskTO.getClass())) {
        throw new IllegalArgumentException(String.format("Expected %s, found %s", taskTOClass, taskTO.getClass()));
    }
    SchedTask task = taskUtils.newTask();
    task.setStartAt(taskTO.getStartAt());
    task.setCronExpression(taskTO.getCronExpression());
    task.setName(taskTO.getName());
    task.setDescription(taskTO.getDescription());
    task.setActive(taskTO.isActive());
    if (taskUtils.getType() == TaskType.SCHEDULED) {
        Implementation implementation = implementationDAO.find(taskTO.getJobDelegate());
        if (implementation == null) {
            throw new NotFoundException("Implementation " + taskTO.getJobDelegate());
        }
        task.setJobDelegate(implementation);
    } else if (taskTO instanceof ProvisioningTaskTO) {
        ProvisioningTaskTO provisioningTaskTO = (ProvisioningTaskTO) taskTO;
        ExternalResource resource = resourceDAO.find(provisioningTaskTO.getResource());
        if (resource == null) {
            throw new NotFoundException("Resource " + provisioningTaskTO.getResource());
        }
        ((ProvisioningTask) task).setResource(resource);
        fill((ProvisioningTask) task, provisioningTaskTO);
    }
    return task;
}
Also used : SchedTask(org.apache.syncope.core.persistence.api.entity.task.SchedTask) ProvisioningTaskTO(org.apache.syncope.common.lib.to.ProvisioningTaskTO) ProvisioningTask(org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation)

Example 70 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class FlowableUserWorkflowAdapter method exportDiagram.

@Override
public void exportDiagram(final String key, final OutputStream os) {
    ProcessDefinition procDef = getProcessDefinitionByKey(key);
    if (procDef == null) {
        throw new NotFoundException("Workflow process definition for " + key);
    }
    exportProcessResource(procDef.getDeploymentId(), procDef.getDiagramResourceName(), os);
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ProcessDefinition(org.flowable.engine.repository.ProcessDefinition)

Aggregations

NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)110 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)87 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)41 Transactional (org.springframework.transaction.annotation.Transactional)21 Date (java.util.Date)12 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)10 SchedulerException (org.quartz.SchedulerException)10 ArrayList (java.util.ArrayList)8 List (java.util.List)8 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)8 Report (org.apache.syncope.core.persistence.api.entity.Report)8 SchedTask (org.apache.syncope.core.persistence.api.entity.task.SchedTask)8 User (org.apache.syncope.core.persistence.api.entity.user.User)8 HashMap (java.util.HashMap)7 Collectors (java.util.stream.Collectors)7 Pair (org.apache.commons.lang3.tuple.Pair)7 ExecTO (org.apache.syncope.common.lib.to.ExecTO)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 StringUtils (org.apache.commons.lang3.StringUtils)6 DuplicateException (org.apache.syncope.core.persistence.api.dao.DuplicateException)6