Search in sources :

Example 1 with DomainTO

use of org.apache.syncope.common.lib.to.DomainTO in project syncope by apache.

the class DomainITCase method create.

@Test
public void create() {
    DomainTO domain = new DomainTO();
    domain.setKey("last");
    domain.setAdminCipherAlgorithm(CipherAlgorithm.SSHA512);
    domain.setAdminPwd("password");
    try {
        domainService.create(domain);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.NotFound, e.getType());
    }
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 2 with DomainTO

use of org.apache.syncope.common.lib.to.DomainTO 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)

Example 3 with DomainTO

use of org.apache.syncope.common.lib.to.DomainTO in project syncope by apache.

the class DomainITCase method delete.

@Test
public void delete() {
    DomainTO two = domainService.read("Two");
    assertNotNull(two);
    try {
        domainService.delete(two.getKey());
        try {
            domainService.read(two.getKey());
            fail("This should not happen");
        } catch (SyncopeClientException e) {
            assertEquals(ClientExceptionType.NotFound, e.getType());
        }
    } finally {
        restoreTwo();
    }
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 4 with DomainTO

use of org.apache.syncope.common.lib.to.DomainTO in project syncope by apache.

the class DomainDataBinderImpl method getDomainTO.

@Override
public DomainTO getDomainTO(final Domain domain) {
    DomainTO domainTO = new DomainTO();
    domainTO.setKey(domain.getKey());
    domainTO.setAdminCipherAlgorithm(domain.getAdminCipherAlgorithm());
    domainTO.setAdminPwd(domainTO.getAdminPwd());
    return domainTO;
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO)

Example 5 with DomainTO

use of org.apache.syncope.common.lib.to.DomainTO in project syncope by apache.

the class DomainLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_DELETE + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN")
public DomainTO delete(final String key) {
    Domain domain = domainDAO.find(key);
    if (domain == null) {
        LOG.error("Could not find domain '" + key + "'");
        throw new NotFoundException(key);
    }
    DomainTO deleted = binder.getDomainTO(domain);
    domainDAO.delete(key);
    return deleted;
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Domain(org.apache.syncope.core.persistence.api.entity.Domain) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

DomainTO (org.apache.syncope.common.lib.to.DomainTO)8 Test (org.junit.jupiter.api.Test)4 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 URI (java.net.URI)1 AccessControlException (java.security.AccessControlException)1 SyncopeClientFactoryBean (org.apache.syncope.client.lib.SyncopeClientFactoryBean)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 Domain (org.apache.syncope.core.persistence.api.entity.Domain)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1