Search in sources :

Example 31 with PasswordChangeDto

use of eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto in project CzechIdMng by bcvsolutions.

the class PasswordPreValidationIntegrationTest method testMinChar.

@Test
public void testMinChar() {
    IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
    policy.setName(System.currentTimeMillis() + "");
    policy.setDefaultPolicy(true);
    policy.setMinUpperChar(5);
    policy.setMinLowerChar(10);
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setIdm(true);
    policy = passwordPolicyService.save(policy);
    try {
        idmIdentityService.validatePassword(passwordChange);
    } catch (ResultCodeException ex) {
        assertEquals(5, ex.getError().getError().getParameters().get("minUpperChar"));
        assertEquals(10, ex.getError().getError().getParameters().get("minLowerChar"));
        assertEquals(policy.getName(), ex.getError().getError().getParameters().get("policiesNamesPreValidation"));
        assertEquals(3, ex.getError().getError().getParameters().size());
        policy.setDefaultPolicy(false);
        passwordPolicyService.save(policy);
    }
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 32 with PasswordChangeDto

use of eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto in project CzechIdMng by bcvsolutions.

the class IdentitySaveProcessor method process.

@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
    IdmIdentityDto identity = event.getContent();
    GuardedString password = identity.getPassword();
    identity = service.saveInternal(identity);
    // 
    event.setContent(identity);
    // save password
    if (password != null) {
        PasswordChangeDto passwordDto = new PasswordChangeDto();
        passwordDto.setNewPassword(password);
        passwordProcessor.savePassword(identity, passwordDto);
    }
    // 
    // create default identity contract
    boolean skipCreationDefaultContract = getBooleanProperty(IdmIdentityContractService.SKIP_CREATION_OF_DEFAULT_POSITION, event.getProperties());
    if (!skipCreationDefaultContract && IdentityEventType.CREATE.name() == event.getType().name() && identityConfiguration.isCreateDefaultContractEnabled()) {
        // TODO: skip publish event? But contract is created properly ...
        identityContractService.save(identityContractService.prepareMainContract(identity.getId()));
    }
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Example 33 with PasswordChangeDto

use of eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto 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 34 with PasswordChangeDto

use of eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto 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 35 with PasswordChangeDto

use of eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto in project CzechIdMng by bcvsolutions.

the class BasicIdmAuthenticationFilterTest method testDisableIdmPasswordChange.

@Test
public void testDisableIdmPasswordChange() {
    String testPassword = "testPassword";
    String newTestPassword = "newTestPassword";
    // 
    this.loginAsAdmin(TEST_ADMIN_USERNAME);
    configurationService.setBooleanValue(IdentityConfiguration.PROPERTY_PUBLIC_CHANGE_PASSWORD_FOR_IDM_ENABLED, false);
    // 
    // create identity
    IdmIdentityDto identity = testHelper.createIdentity();
    PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
    passwordChangeDto.setNewPassword(new GuardedString(testPassword));
    passwordService.save(identity, passwordChangeDto);
    this.logout();
    // 
    LoginDto loginDto = new LoginDto();
    loginDto.setUsername(identity.getUsername());
    loginDto.setPassword(new GuardedString(testPassword));
    LoginDto login = loginService.login(loginDto);
    // 
    assertNotNull(login.getAuthentication());
    // 
    passwordChangeDto = new PasswordChangeDto();
    passwordChangeDto.setNewPassword(new GuardedString(newTestPassword));
    passwordChangeDto.setOldPassword(new GuardedString(testPassword));
    passwordChangeDto.setAll(true);
    passwordChangeDto.setIdm(true);
    // 
    List<OperationResult> passwordChangeResults = identityService.passwordChange(identity, passwordChangeDto);
    // 
    assertEquals(1, passwordChangeResults.size());
    OperationResult operationResult = passwordChangeResults.get(0);
    assertEquals(OperationState.EXECUTED, operationResult.getState());
}
Also used : PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) 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) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test)

Aggregations

PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)36 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)30 Test (org.junit.Test)27 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)23 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)21 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)16 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)13 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)13 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)12 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)11 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)11 ArrayList (java.util.ArrayList)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)10 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)9 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)7 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)7 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)5 IdmPasswordDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto)5 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)4 IdmPasswordValidationDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto)4