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();
}
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);
}
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);
}
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");
}
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();
}
}
Aggregations