Search in sources :

Example 21 with GuardedString

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

the class AbstractHrProcessIntegrationTest method createTestIdentity.

protected IdmIdentityDto createTestIdentity(String username, boolean disabled) {
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(username);
    identity.setPassword(new GuardedString("password"));
    identity.setFirstName("Test");
    identity.setLastName("User");
    identity.setEmail("test.user@example.tl");
    identity.setState(disabled ? IdentityState.DISABLED : null);
    identity = this.identityService.save(identity);
    // make sure default contract is not created
    identityContractService.findAllByIdentity(identity.getId()).forEach(c -> identityContractService.deleteInternal(c));
    return identity;
}
Also used : GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Example 22 with GuardedString

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

the class AuthenticationManagerTest method loginViaManagerBadCredentials.

@Transactional
@Test(expected = AuthenticationException.class)
public void loginViaManagerBadCredentials() {
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername("test_login_1");
    identity.setLastName("test_login_1");
    identity.setPassword(new GuardedString("test1234"));
    identity = this.identityService.save(identity);
    LoginDto loginDto = new LoginDto();
    loginDto.setPassword(new GuardedString("test12345"));
    loginDto.setUsername("test_login_1");
    authenticationManager.authenticate(loginDto);
    fail();
}
Also used : 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with GuardedString

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

the class AuthenticationManagerTest method loginViaManagerSuccesful.

@Test
@Transactional
public void loginViaManagerSuccesful() {
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername("test_login_2");
    identity.setLastName("test_login_2");
    identity.setPassword(new GuardedString("test1234"));
    identity = this.identityService.save(identity);
    LoginDto loginDto = new LoginDto();
    loginDto.setPassword(new GuardedString("test1234"));
    loginDto.setUsername("test_login_2");
    loginDto = authenticationManager.authenticate(loginDto);
    assertNotNull(loginDto);
    assertNotNull(loginDto.getAuthentication());
    assertEquals("core", loginDto.getAuthenticationModule());
}
Also used : 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with GuardedString

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

the class DefaultAuthorizationManagerIntegrationTest method testPredicate.

@Test
public void testPredicate() {
    loginAsAdmin(InitTestData.TEST_USER_1);
    // prepare role
    IdmRoleDto role = helper.createRole();
    helper.createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.READ);
    helper.createBasePolicy(role.getId(), IdmBasePermission.AUTOCOMPLETE);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    identity.setPassword(new GuardedString("heslo"));
    identityService.save(identity);
    // assign role
    helper.createIdentityRole(identity, role);
    logout();
    // 
    // empty without login
    IdmRoleFilter filter = new IdmRoleFilter();
    assertEquals(0, roleService.find(filter, null, IdmBasePermission.READ).getTotalElements());
    assertEquals(0, roleService.find(filter, null, IdmBasePermission.AUTOCOMPLETE).getTotalElements());
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        // evaluate	access
        assertEquals(1, roleService.find(filter, null, IdmBasePermission.READ).getTotalElements());
        assertEquals(roleService.find(null).getTotalElements(), roleService.find(filter, null, IdmBasePermission.AUTOCOMPLETE).getTotalElements());
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) 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 25 with GuardedString

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

the class DefaultAuthorizationManagerIntegrationTest method testEvaluate.

@Test
public void testEvaluate() {
    loginAsAdmin(InitTestData.TEST_USER_1);
    // prepare role
    IdmRoleDto role = helper.createRole();
    helper.createBasePolicy(role.getId(), IdmBasePermission.READ);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    identity.setPassword(new GuardedString("heslo"));
    identityService.save(identity);
    // assign role
    helper.createIdentityRole(identity, role);
    logout();
    // 
    // without login
    assertFalse(manager.evaluate(role, IdmBasePermission.READ));
    assertFalse(manager.evaluate(role, IdmBasePermission.UPDATE));
    assertFalse(manager.evaluate(role, IdmBasePermission.ADMIN));
    assertFalse(manager.evaluate(role, IdmBasePermission.AUTOCOMPLETE));
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        // evaluate	access
        assertTrue(manager.evaluate(role, IdmBasePermission.READ));
        assertFalse(manager.evaluate(role, IdmBasePermission.UPDATE));
        assertFalse(manager.evaluate(role, IdmBasePermission.ADMIN));
        assertFalse(manager.evaluate(role, IdmBasePermission.AUTOCOMPLETE));
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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)

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