Search in sources :

Example 6 with AnyTypeTO

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

the class AnyTypeITCase method issueSYNCOPE754.

@Test
public void issueSYNCOPE754() {
    AnyTypeClassTO other = anyTypeClassService.read("other");
    assertNotNull(other);
    AnyTypeTO group = anyTypeService.read(AnyTypeKind.GROUP.name());
    try {
        assertFalse(group.getClasses().contains("other"));
        group.getClasses().add("other");
        anyTypeService.update(group);
        group = anyTypeService.read(AnyTypeKind.GROUP.name());
        assertTrue(group.getClasses().contains("other"));
        other = anyTypeClassService.read("other");
        assertEquals(2, other.getInUseByTypes().size());
        assertTrue(other.getInUseByTypes().contains(AnyTypeKind.USER.name()));
        assertTrue(other.getInUseByTypes().contains(AnyTypeKind.GROUP.name()));
    } finally {
        group.getClasses().remove("other");
        anyTypeService.update(group);
    }
}
Also used : AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Example 7 with AnyTypeTO

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

the class AnyTypeITCase method createInvalidKind.

@Test
public void createInvalidKind() {
    AnyTypeTO newType = new AnyTypeTO();
    newType.setKey("new type");
    newType.setKind(AnyTypeKind.USER);
    try {
        anyTypeService.create(newType);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.InvalidAnyType, e.getType());
    }
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) Test(org.junit.jupiter.api.Test)

Example 8 with AnyTypeTO

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

the class AnyTypeDataBinderImpl method delete.

@Override
public AnyTypeTO delete(final AnyType anyType) {
    AnyTypeTO deleted = getAnyTypeTO(anyType);
    anyTypeDAO.delete(anyType.getKey());
    final Set<String> removed = EntitlementsHolder.getInstance().removeFor(deleted.getKey());
    if (!adminUser.equals(AuthContextUtils.getUsername())) {
        AccessToken accessToken = accessTokenDAO.findByOwner(AuthContextUtils.getUsername());
        try {
            Set<SyncopeGrantedAuthority> authorities = new HashSet<>(POJOHelper.deserialize(ENCRYPTOR.decode(new String(accessToken.getAuthorities()), CipherAlgorithm.AES), new TypeReference<Set<SyncopeGrantedAuthority>>() {
            }));
            authorities.removeAll(authorities.stream().filter(authority -> removed.contains(authority.getAuthority())).collect(Collectors.toList()));
            accessToken.setAuthorities(ENCRYPTOR.encode(POJOHelper.serialize(authorities), CipherAlgorithm.AES).getBytes());
            accessTokenDAO.save(accessToken);
        } catch (Exception e) {
            LOG.error("Could not fetch or store authorities", e);
        }
    }
    return deleted;
}
Also used : SyncopeGrantedAuthority(org.apache.syncope.core.spring.security.SyncopeGrantedAuthority) AccessToken(org.apache.syncope.core.persistence.api.entity.AccessToken) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) TypeReference(com.fasterxml.jackson.core.type.TypeReference) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) HashSet(java.util.HashSet)

Example 9 with AnyTypeTO

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

the class AnyTypeDataBinderImpl method getAnyTypeTO.

@Override
public AnyTypeTO getAnyTypeTO(final AnyType anyType) {
    AnyTypeTO anyTypeTO = new AnyTypeTO();
    anyTypeTO.setKey(anyType.getKey());
    anyTypeTO.setKind(anyType.getKind());
    anyType.getClasses().forEach(anyTypeClass -> {
        anyTypeTO.getClasses().add(anyTypeClass.getKey());
    });
    return anyTypeTO;
}
Also used : AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO)

Example 10 with AnyTypeTO

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

the class AnyTypeITCase method read.

@Test
public void read() {
    AnyTypeTO userType = anyTypeService.read(AnyTypeKind.USER.name());
    assertNotNull(userType);
    assertEquals(AnyTypeKind.USER, userType.getKind());
    assertEquals(AnyTypeKind.USER.name(), userType.getKey());
    assertFalse(userType.getClasses().isEmpty());
    AnyTypeTO groupType = anyTypeService.read(AnyTypeKind.GROUP.name());
    assertNotNull(groupType);
    assertEquals(AnyTypeKind.GROUP, groupType.getKind());
    assertEquals(AnyTypeKind.GROUP.name(), groupType.getKey());
    assertFalse(groupType.getClasses().isEmpty());
    AnyTypeTO otherType = anyTypeService.read("PRINTER");
    assertNotNull(otherType);
    assertEquals(AnyTypeKind.ANY_OBJECT, otherType.getKind());
    assertEquals("PRINTER", otherType.getKey());
}
Also used : AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) Test(org.junit.jupiter.api.Test)

Aggregations

AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)18 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)9 Test (org.junit.jupiter.api.Test)9 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)6 ArrayList (java.util.ArrayList)5 Response (javax.ws.rs.core.Response)4 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)4 EntityTO (org.apache.syncope.common.lib.to.EntityTO)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 AnyTypeClassRestClient (org.apache.syncope.client.console.rest.AnyTypeClassRestClient)2 AnyTypeRestClient (org.apache.syncope.client.console.rest.AnyTypeRestClient)2 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)2 WizardMgtPanel (org.apache.syncope.client.console.wizards.WizardMgtPanel)2 DerSchemaTO (org.apache.syncope.common.lib.to.DerSchemaTO)2 RoleTO (org.apache.syncope.common.lib.to.RoleTO)2 UserTO (org.apache.syncope.common.lib.to.UserTO)2 VirSchemaTO (org.apache.syncope.common.lib.to.VirSchemaTO)2