Search in sources :

Example 76 with GuardedString

use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.

the class CodeableEvaluatorIntegrationTest method testPermissionByWrongUuid.

@Test
public void testPermissionByWrongUuid() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // prepare role
    IdmRoleDto role = helper.createRole();
    // 
    IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
    dto.setRole(role.getId());
    dto.setEvaluator(CodeableEvaluator.class);
    dto.setGroupPermission(CoreGroupPermission.ROLE.getName());
    dto.setAuthorizableType(IdmRole.class.getCanonicalName());
    dto.getEvaluatorProperties().put(CodeableEvaluator.PARAMETER_IDENTIFIER, "wrong");
    dto.setPermissions(IdmBasePermission.READ);
    authorizationPolicyService.save(dto);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    identity.setPassword(new GuardedString("heslo"));
    identityService.save(identity);
    // assign role
    helper.createIdentityRole(identity, role);
    logout();
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        // evaluate	access
        assertEquals(0, roleService.find(null, IdmBasePermission.READ).getTotalElements());
        ;
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 77 with GuardedString

use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.

the class ConfigurationEvaluatorIntegrationTest method testUpdateWithoutPermissions.

@Test(expected = ForbiddenEntityException.class)
public void testUpdateWithoutPermissions() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // prepare role
    IdmRoleDto role = helper.createRole();
    // 
    IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
    dto.setRole(role.getId());
    dto.setEvaluator(ConfigurationEvaluator.class);
    dto.setGroupPermission(CoreGroupPermission.CONFIGURATION.getName());
    dto.setAuthorizableType(IdmConfiguration.class.getCanonicalName());
    dto.setPermissions(IdmBasePermission.READ);
    authorizationPolicyService.save(dto);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    identity.setPassword(new GuardedString("heslo"));
    identityService.save(identity);
    // assign role
    helper.createIdentityRole(identity, role);
    logout();
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        publicConfig.setValue("update");
        configurationService.save(publicConfig, IdmBasePermission.UPDATE);
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 78 with GuardedString

use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.

the class IdentityTransitiveEvaluatorsIntegrationTest method testChangePassword.

@Test
public void testChangePassword() {
    IdmIdentityDto identity = prepareIdentityProfile();
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
        passwordChangeDto.setIdm(true);
        passwordChangeDto.setAll(true);
        passwordChangeDto.setOldPassword(identity.getPassword());
        passwordChangeDto.setNewPassword(new GuardedString("heslo2"));
        passwordChangeController.passwordChange(identity.getId().toString(), passwordChangeDto);
    } finally {
        logout();
    }
}
Also used : PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 79 with GuardedString

use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.

the class IdentityTransitiveEvaluatorsIntegrationTest method testChangeForeignPassword.

@Test(expected = ForbiddenEntityException.class)
public void testChangeForeignPassword() {
    IdmIdentityDto identity = prepareIdentityProfile();
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
        passwordChangeDto.setIdm(true);
        passwordChangeDto.setOldPassword(identity.getPassword());
        passwordChangeDto.setNewPassword(new GuardedString("heslo2"));
        passwordChangeController.passwordChange(InitTestData.TEST_ADMIN_USERNAME, passwordChangeDto);
    } finally {
        logout();
    }
}
Also used : PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 80 with GuardedString

use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.

the class RoleForRequestEvaluatorIntegrationTest method deleteRoleAsUser.

private Exception deleteRoleAsUser(IdmIdentityDto user, IdmRoleDto role) {
    try {
        loginService.login(new LoginDto(user.getUsername(), new GuardedString(TEST_PWD)));
        roleService.delete(role, IdmBasePermission.DELETE);
    } catch (Exception ex) {
        return ex;
    } finally {
        logout();
    }
    return null;
}
Also used : GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto)

Aggregations

GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)97 Test (org.junit.Test)61 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)59 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)49 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)40 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)30 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)26 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)20 ArrayList (java.util.ArrayList)13 IdmAuthorizationPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto)11 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)11 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)10 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)9 HashMap (java.util.HashMap)9 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)8 Transactional (org.springframework.transaction.annotation.Transactional)8 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)7 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)7 IdmRole (eu.bcvsolutions.idm.core.model.entity.IdmRole)7 List (java.util.List)7