Search in sources :

Example 1 with GuardedString

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

the class DefaultAuthenticationManager method cloneLoginDto.

/**
 * Clone object {@link LoginDto} without inner class {@link IdmJwtAuthentication}
 * @param loginDto
 * @return
 */
private LoginDto cloneLoginDto(LoginDto loginDto) {
    LoginDto clone = new LoginDto();
    clone.setToken(loginDto.getToken());
    clone.setUsername(loginDto.getUsername());
    clone.setAuthenticationModule(loginDto.getAuthenticationModule());
    clone.setSkipMustChange(loginDto.isSkipMustChange());
    clone.setPassword(new GuardedString(loginDto.getPassword().asBytes()));
    return clone;
}
Also used : GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto)

Example 2 with GuardedString

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

the class DefaultSysProvisioningOperationServiceUnitTest method testReplaceGuardedStringsInConnectorObject.

@Test
public void testReplaceGuardedStringsInConnectorObject() {
    ProvisioningContext context = new ProvisioningContext();
    IcConnectorObjectImpl connectorObject = new IcConnectorObjectImpl();
    context.setConnectorObject(connectorObject);
    // 
    // fill properties
    String normalValue = "one";
    IcAttributeImpl normal = new IcAttributeImpl("normal", normalValue);
    connectorObject.getAttributes().add(normal);
    GuardedString guardedValue = new GuardedString("one");
    IcAttributeImpl guarded = new IcAttributeImpl("guarded", guardedValue);
    connectorObject.getAttributes().add(guarded);
    // 
    // run
    Map<String, Serializable> confidentiaValues = service.replaceGuardedStrings(context);
    // 
    // check
    assertEquals(1, confidentiaValues.size());
    assertEquals(guardedValue.asString(), confidentiaValues.get(service.createConnectorObjectPropertyKey(guarded, 0)));
    assertEquals(normalValue, connectorObject.getAttributes().get(0).getValue());
    assertNotEquals(guardedValue, connectorObject.getAttributes().get(1).getValue());
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Serializable(java.io.Serializable) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 3 with GuardedString

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

the class DefaultSysProvisioningServiceTest method testPasswordChangeWithAdditionalAttributesInTwoOperations.

@Test
public void testPasswordChangeWithAdditionalAttributesInTwoOperations() {
    configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_SEND_PASSWORD_ATTRIBUTES_TOGETHER, false);
    try {
        Assert.assertFalse(provisioningConfiguration.isSendPasswordAttributesTogether());
        // prepare account on target system
        SysSystemDto system = helper.createTestResourceSystem(true);
        SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
        SysSystemAttributeMappingDto firtstNameAttribute = systemAttributeMappingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
        firtstNameAttribute.setSendOnPasswordChange(Boolean.TRUE);
        systemAttributeMappingService.save(firtstNameAttribute);
        IdmRoleDto role = helper.createRole();
        helper.createRoleSystem(role, system);
        IdmIdentityDto identity = helper.createIdentity();
        helper.createIdentityRole(identity, role);
        // 
        AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
        filter.setIdentityId(identity.getId());
        AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
        AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
        // Create new password one
        PasswordChangeDto passwordChange = new PasswordChangeDto();
        passwordChange.setAccounts(ImmutableList.of(account.getId().toString()));
        passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
        passwordChange.setIdm(true);
        // 
        // Do change of password for selected accounts
        String firstNameChange = "firstname-change";
        identity.setFirstName(firstNameChange);
        idmIdentityService.passwordChange(identity, passwordChange);
        // 
        // Check correct password One
        TestResource resource = helper.findResource(account.getRealUid());
        Assert.assertNotNull(resource);
        Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
        Assert.assertEquals(firstNameChange, resource.getFirstname());
    } finally {
        configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_SEND_PASSWORD_ATTRIBUTES_TOGETHER, true);
        Assert.assertTrue(provisioningConfiguration.isSendPasswordAttributesTogether());
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 4 with GuardedString

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

the class DefaultSysProvisioningServiceTest method testPasswordChangeWithoutAdditionalAttributes.

@Test
public void testPasswordChangeWithoutAdditionalAttributes() {
    // prepare account on target system
    SysSystemDto system = helper.createTestResourceSystem(true);
    IdmRoleDto role = helper.createRole();
    helper.createRoleSystem(role, system);
    IdmIdentityDto identity = helper.createIdentity();
    helper.createIdentityRole(identity, role);
    // 
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
    // Create new password one
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setAccounts(ImmutableList.of(account.getId().toString()));
    passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
    passwordChange.setIdm(true);
    // 
    // Do change of password for selected accounts
    String previousFirtsName = identity.getFirstName();
    String firstNameChange = "firstname-change";
    identity.setFirstName(firstNameChange);
    idmIdentityService.passwordChange(identity, passwordChange);
    // 
    // Check correct password One
    TestResource resource = helper.findResource(account.getRealUid());
    Assert.assertNotNull(resource);
    Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
    Assert.assertEquals(previousFirtsName, resource.getFirstname());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 5 with GuardedString

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

the class DefaultSysProvisioningServiceTest method testPasswordChangeWithAdditionalAttributesInOneOperation.

@Test
public void testPasswordChangeWithAdditionalAttributesInOneOperation() {
    Assert.assertTrue(provisioningConfiguration.isSendPasswordAttributesTogether());
    // 
    // prepare account on target system
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
    SysSystemAttributeMappingDto firtstNameAttribute = systemAttributeMappingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
    firtstNameAttribute.setSendOnPasswordChange(Boolean.TRUE);
    systemAttributeMappingService.save(firtstNameAttribute);
    IdmRoleDto role = helper.createRole();
    helper.createRoleSystem(role, system);
    IdmIdentityDto identity = helper.createIdentity();
    helper.createIdentityRole(identity, role);
    // 
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
    // Create new password one
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setAccounts(ImmutableList.of(account.getId().toString()));
    passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
    passwordChange.setIdm(true);
    // 
    // Do change of password for selected accounts
    String firstNameChange = "firstname-change";
    identity.setFirstName(firstNameChange);
    idmIdentityService.passwordChange(identity, passwordChange);
    // 
    // Check correct password One
    TestResource resource = helper.findResource(account.getRealUid());
    Assert.assertNotNull(resource);
    Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
    Assert.assertEquals(firstNameChange, resource.getFirstname());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) 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