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