Search in sources :

Example 1 with ConnectorService

use of org.apache.syncope.common.rest.api.service.ConnectorService in project syncope by apache.

the class ConnectorITCase method authorizations.

@Test
public void authorizations() {
    SyncopeClient puccini = clientFactory.create("puccini", ADMIN_PWD);
    ConnectorService pcs = puccini.getService(ConnectorService.class);
    // 1. list connectors: get only the ones allowed
    List<ConnInstanceTO> connInstances = pcs.list(null);
    assertEquals(2, connInstances.size());
    assertTrue(connInstances.stream().allMatch(connInstance -> "a6d017fd-a705-4507-bb7c-6ab6a6745997".equals(connInstance.getKey()) || "44c02549-19c3-483c-8025-4919c3283c37".equals(connInstance.getKey())));
    // 2. attempt to read a connector with a different admin realm: fail
    try {
        pcs.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", null);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.DelegatedAdministration, e.getType());
    }
    // 3. read and upate a connector in the realm for which entitlements are owned: succeed
    try {
        ConnInstanceTO scriptedsql = pcs.read("a6d017fd-a705-4507-bb7c-6ab6a6745997", null);
        ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
        assertEquals("true", reloadScriptOnExecution.getValues().get(0).toString());
        reloadScriptOnExecution.getValues().set(0, "false");
        pcs.update(scriptedsql);
        scriptedsql = pcs.read(scriptedsql.getKey(), null);
        reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
        assertEquals("false", reloadScriptOnExecution.getValues().get(0).toString());
    } finally {
        ConnInstanceTO scriptedsql = connectorService.read("a6d017fd-a705-4507-bb7c-6ab6a6745997", null);
        ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
        reloadScriptOnExecution.getValues().set(0, "true");
        connectorService.update(scriptedsql);
    }
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) SerializationUtils(org.apache.commons.lang3.SerializationUtils) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) GuardedString(org.identityconnectors.common.security.GuardedString) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) Locale(java.util.Locale) ItemTO(org.apache.syncope.common.lib.to.ItemTO) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AbstractITCase(org.apache.syncope.fit.AbstractITCase) EnumSet(java.util.EnumSet) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) Properties(java.util.Properties) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) MappingTO(org.apache.syncope.common.lib.to.MappingTO) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) UUID(java.util.UUID) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) Response(javax.ws.rs.core.Response) ConnectorCapability(org.apache.syncope.common.lib.types.ConnectorCapability) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) InputStream(java.io.InputStream) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) ConnBundleTO(org.apache.syncope.common.lib.to.ConnBundleTO) ConnPoolConfTO(org.apache.syncope.common.lib.to.ConnPoolConfTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) Test(org.junit.jupiter.api.Test)

Example 2 with ConnectorService

use of org.apache.syncope.common.rest.api.service.ConnectorService in project syncope by apache.

the class ConnectorRestClient method getObjectClasses.

public List<String> getObjectClasses(final String connectorKey) {
    List<String> result = new ArrayList<>();
    ConnectorService service = getService(ConnectorService.class);
    ConnInstanceTO connInstance = service.read(connectorKey, SyncopeConsoleSession.get().getLocale().getLanguage());
    if (connInstance != null) {
        result.addAll(service.buildObjectClassInfo(connInstance, true).stream().map(input -> input.getType()).collect(Collectors.toList()));
    }
    return result;
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ArrayList(java.util.ArrayList) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService)

Example 3 with ConnectorService

use of org.apache.syncope.common.rest.api.service.ConnectorService in project syncope by apache.

the class ConnectorRestClient method create.

public ConnInstanceTO create(final ConnInstanceTO connectorTO) {
    List<ConnConfProperty> filteredConf = filterProperties(connectorTO.getConf());
    connectorTO.getConf().clear();
    connectorTO.getConf().addAll(filteredConf);
    ConnectorService service = getService(ConnectorService.class);
    Response response = service.create(connectorTO);
    return getObject(service, response.getLocation(), ConnInstanceTO.class);
}
Also used : Response(javax.ws.rs.core.Response) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService)

Aggregations

ConnectorService (org.apache.syncope.common.rest.api.service.ConnectorService)3 Response (javax.ws.rs.core.Response)2 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)2 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Properties (java.util.Properties)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 SerializationUtils (org.apache.commons.lang3.SerializationUtils)1 ExceptionUtils (org.apache.commons.lang3.exception.ExceptionUtils)1 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1