Search in sources :

Example 1 with SyncopeClientFactoryBean

use of org.apache.syncope.client.lib.SyncopeClientFactoryBean in project syncope by apache.

the class SyncopeServices method testUsernameAndPassword.

public static void testUsernameAndPassword(final String username, final String password) {
    final Properties properties = new Properties();
    try (InputStream is = Files.newInputStream(Paths.get(InstallConfigFileTemplate.configurationFilePath()))) {
        properties.load(is);
    } catch (final IOException e) {
        LOG.error("Error opening properties file", e);
    }
    final SyncopeClient syncopeClient = new SyncopeClientFactoryBean().setAddress(properties.getProperty("syncope.rest.services")).create(username, password);
    syncopeClient.getService(SyncopeService.class).platform();
}
Also used : SyncopeService(org.apache.syncope.common.rest.api.service.SyncopeService) InputStream(java.io.InputStream) SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) IOException(java.io.IOException) Properties(java.util.Properties) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient)

Example 2 with SyncopeClientFactoryBean

use of org.apache.syncope.client.lib.SyncopeClientFactoryBean in project syncope by apache.

the class SyncopeServices method get.

public static <T> T get(final Class<T> clazz) {
    final Properties properties = new Properties();
    try (InputStream is = Files.newInputStream(Paths.get(InstallConfigFileTemplate.configurationFilePath()))) {
        properties.load(is);
    } catch (final IOException e) {
        LOG.error("Error opening properties file", e);
    }
    String syncopeAdminPassword = JasyptUtils.get().decrypt(properties.getProperty("syncope.admin.password"));
    SYNCOPE_ADDRESS = properties.getProperty("syncope.rest.services");
    String useGZIPCompression = properties.getProperty("useGZIPCompression");
    SyncopeClient syncopeClient = new SyncopeClientFactoryBean().setAddress(SYNCOPE_ADDRESS).setUseCompression(BooleanUtils.toBoolean(useGZIPCompression)).create(properties.getProperty("syncope.admin.user"), syncopeAdminPassword);
    LOG.debug("Creating service for {}", clazz.getName());
    return syncopeClient.getService(clazz);
}
Also used : InputStream(java.io.InputStream) SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) IOException(java.io.IOException) Properties(java.util.Properties) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient)

Example 3 with SyncopeClientFactoryBean

use of org.apache.syncope.client.lib.SyncopeClientFactoryBean in project syncope by apache.

the class SAML2ITCase method setup.

@BeforeAll
public static void setup() {
    anonymous = new SyncopeClientFactoryBean().setAddress(ADDRESS).create(new AnonymousAuthenticationHandler(ANONYMOUS_UNAME, ANONYMOUS_KEY));
    WSSConfig.init();
    OpenSAMLUtil.initSamlEngine(false);
}
Also used : SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) AnonymousAuthenticationHandler(org.apache.syncope.client.lib.AnonymousAuthenticationHandler) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with SyncopeClientFactoryBean

use of org.apache.syncope.client.lib.SyncopeClientFactoryBean in project syncope by apache.

the class MultitenancyITCase method restSetup.

@BeforeAll
public static void restSetup() {
    clientFactory = new SyncopeClientFactoryBean().setAddress(ADDRESS).setDomain("Two");
    String envContentType = System.getProperty(ENV_KEY_CONTENT_TYPE);
    if (StringUtils.isNotBlank(envContentType)) {
        clientFactory.setContentType(envContentType);
    }
    LOG.info("Performing IT with content type {}", clientFactory.getContentType().getMediaType());
    adminClient = clientFactory.create(ADMIN_UNAME, "password2");
}
Also used : SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with SyncopeClientFactoryBean

use of org.apache.syncope.client.lib.SyncopeClientFactoryBean in project syncope by apache.

the class DomainITCase method update.

@Test
public void update() {
    DomainTO two = domainService.read("Two");
    assertNotNull(two);
    try {
        // 1. change admin pwd for domain Two
        two.setAdminCipherAlgorithm(CipherAlgorithm.AES);
        two.setAdminPwd("password3");
        domainService.update(two);
        // 2. attempt to access with old pwd -> fail
        try {
            new SyncopeClientFactoryBean().setAddress(ADDRESS).setDomain("Two").setContentType(clientFactory.getContentType()).create(ADMIN_UNAME, "password2").self();
        } catch (AccessControlException e) {
            assertNotNull(e);
        }
        // 3. access with new pwd -> succeed
        new SyncopeClientFactoryBean().setAddress(ADDRESS).setDomain("Two").setContentType(clientFactory.getContentType()).create(ADMIN_UNAME, "password3").self();
    } finally {
        restoreTwo();
    }
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) AccessControlException(java.security.AccessControlException) Test(org.junit.jupiter.api.Test)

Aggregations

SyncopeClientFactoryBean (org.apache.syncope.client.lib.SyncopeClientFactoryBean)13 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)7 IOException (java.io.IOException)5 Properties (java.util.Properties)4 InputStream (java.io.InputStream)3 AnonymousAuthenticationHandler (org.apache.syncope.client.lib.AnonymousAuthenticationHandler)3 SAML2SPService (org.apache.syncope.common.rest.api.service.SAML2SPService)3 ServletException (javax.servlet.ServletException)2 WebClient (org.apache.cxf.jaxrs.client.WebClient)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 Serializable (java.io.Serializable)1 URL (java.net.URL)1 AccessControlException (java.security.AccessControlException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Response (javax.ws.rs.core.Response)1 FileUtils (org.apache.commons.io.FileUtils)1