Search in sources :

Example 91 with GuardedString

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

the class CzechIdMIcConnectorService method authenticateObject.

@Override
public IcUidAttribute authenticateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, String username, GuardedString password) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(username);
    String key = connectorInstance.getConnectorKey().toString();
    LOG.debug("Authenticate object - CzechIdM (username= {} {})", username, key);
    throw new IcException(MessageFormat.format("Connector [{0}] not supports authentication operation!", key));
}
Also used : IcException(eu.bcvsolutions.idm.ic.exception.IcException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 92 with GuardedString

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

the class VsReqeustServiceTest method realizeUpdateAndDeleteRequestsTest.

@Test
public void realizeUpdateAndDeleteRequestsTest() {
    String changed = "changed";
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    IdmIdentityDto userOne = identityService.getByUsername(USER_ONE_NAME);
    userOne.setFirstName(changed);
    userOne.setLastName(changed);
    identityService.save(userOne);
    // Delete identity
    identityService.delete(userOne);
    // Test read rights (none requests can be returned for UserOne)
    IdmIdentityDto userTwo = helper.createIdentity("vsUserTwo");
    super.logout();
    loginService.login(new LoginDto(userTwo.getUsername(), new GuardedString("password")));
    requests = requestService.find(requestFilter, null, IdmBasePermission.READ).getContent();
    Assert.assertEquals("We found request without correct rights!", 0, requests.size());
    // Test read rights (3 requests must be returned for UserImplementer)
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    requests = requestService.find(requestFilter, null, IdmBasePermission.READ).getContent();
    Assert.assertEquals(3, requests.size());
    VsRequestDto changeRequest = requests.stream().filter(req -> VsRequestState.IN_PROGRESS == req.getState() && VsOperationType.UPDATE == req.getOperationType()).findFirst().orElse(null);
    Assert.assertNotNull("Request with change not found!", changeRequest);
    VsRequestDto deleteRequest = requests.stream().filter(req -> VsRequestState.IN_PROGRESS == req.getState() && VsOperationType.DELETE == req.getOperationType()).findFirst().orElse(null);
    Assert.assertNotNull("Request with delete not found!", deleteRequest);
    VsRequestDto createRequest = requests.stream().filter(req -> VsRequestState.IN_PROGRESS == req.getState() && VsOperationType.CREATE == req.getOperationType()).findFirst().orElse(null);
    Assert.assertNotNull("Request with create not found!", createRequest);
    // Realize create request
    request = requestService.realize(createRequest);
    // Realize update request
    request = requestService.realize(changeRequest);
    // Realize delete request
    request = requestService.realize(deleteRequest);
    // Find only archived
    requestFilter.setOnlyArchived(Boolean.TRUE);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(3, requests.size());
    boolean foundNotRealized = requests.stream().filter(req -> VsRequestState.REALIZED != req.getState()).findFirst().isPresent();
    Assert.assertTrue("Found not realized requests!", !foundNotRealized);
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 93 with GuardedString

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

the class VsReqeustServiceTest method checkSinglevalueInWishObjectTest.

@Test
public void checkSinglevalueInWishObjectTest() {
    String changed = "changed";
    String firstName = "firstName";
    String lastName = "lastName";
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    IdmIdentityDto userOne = helper.createIdentity(USER_ONE_NAME);
    userOne.setFirstName(firstName);
    userOne.setLastName(lastName);
    identityService.save(userOne);
    this.assignRoleSystem(system, userOne, ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    requestFilter.setState(VsRequestState.IN_PROGRESS);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto createRequest = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, createRequest.getUid());
    Assert.assertEquals(VsOperationType.CREATE, createRequest.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, createRequest.getState());
    VsConnectorObjectDto wish = requestService.getWishConnectorObject(createRequest);
    boolean findAttributeWithouChange = wish.getAttributes().stream().filter(attribute -> !attribute.isChanged()).findFirst().isPresent();
    Assert.assertTrue(!findAttributeWithouChange);
    // Change singlevalue attributes
    userOne.setFirstName(changed);
    userOne.setLastName(changed);
    // Invoke provisioning
    identityService.save(userOne);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(2, requests.size());
    // We realize the create request
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    requestService.realize(createRequest);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    // get wish
    wish = requestService.getWishConnectorObject(requests.get(0));
    Assert.assertEquals(2, wish.getAttributes().stream().filter(attr -> attr.isChanged()).count());
    // Find change for firstName value
    boolean findCorrectChangedFirstName = wish.getAttributes().stream().filter(attr -> attr.getValue().getValue().equals(changed) && attr.getValue().getOldValue().equals(firstName) && VsValueChangeType.UPDATED == attr.getValue().getChange()).findFirst().isPresent();
    Assert.assertTrue(findCorrectChangedFirstName);
    // Find change for lastName value
    boolean findCorrectChangedLastName = wish.getAttributes().stream().filter(attr -> attr.getValue().getValue().equals(changed) && attr.getValue().getOldValue().equals(lastName) && VsValueChangeType.UPDATED == attr.getValue().getChange()).findFirst().isPresent();
    Assert.assertTrue(findCorrectChangedLastName);
}
Also used : VsConnectorObjectDto(eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 94 with GuardedString

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

the class VsReqeustServiceTest method createAndRealizeRequestTest.

@Test
public void createAndRealizeRequestTest() {
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    // We try realize the request
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    request = requestService.realize(request);
    Assert.assertEquals(VsRequestState.REALIZED, request.getState());
    account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNotNull("Account cannot be null, because request was realized!", account);
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 95 with GuardedString

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

the class VsReqeustServiceTest method realizeRequestWithouRightTest.

@Test(expected = ForbiddenEntityException.class)
public void realizeRequestWithouRightTest() {
    String reason = "cancel \"request\" reason!";
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    // We try cancel the request
    super.logout();
    loginService.login(new LoginDto(USER_ONE_NAME, new GuardedString("password")));
    request = requestService.cancel(request, reason);
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) 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