Search in sources :

Example 81 with IdmPasswordDto

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

the class DefaultIdmPasswordPolicyServiceIntegrationTest method testValidateMinPasswordAgeFailedEnforce.

@Test(expected = PasswordChangeException.class)
public void testValidateMinPasswordAgeFailedEnforce() {
    IdmIdentityDto manager = getHelper().createIdentity();
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmPasswordDto password = getHelper().getPassword(identity);
    password.setValidFrom(LocalDate.now());
    password = passwordService.save(password);
    // 
    IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
    policy.setType(IdmPasswordPolicyType.VALIDATE);
    policy.setMinPasswordAge(1);
    // 
    IdmPasswordValidationDto validation = new IdmPasswordValidationDto();
    validation.setIdentity(identity);
    validation.setPassword(getHelper().createName());
    validation.setEnforceMinPasswordAgeValidation(true);
    // 
    try {
        getHelper().login(manager);
        // 
        passwordPolicyService.validate(validation, Lists.newArrayList(policy));
    } finally {
        getHelper().logout();
    }
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) IdmPasswordValidationDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 82 with IdmPasswordDto

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

the class DefaultPasswordFilterManagerIntegrationTest method testValidateWithMinPasswordAgeGreenLine.

@Test
public void testValidateWithMinPasswordAgeGreenLine() {
    SysSystemDto system = createSystem(false);
    IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
    policy.setName(getHelper().createName());
    policy.setType(IdmPasswordPolicyType.VALIDATE);
    policy.setMinPasswordAge(1);
    policy = passwordPolicyService.save(policy);
    system.setPasswordPolicyValidate(policy.getId());
    system = systemService.save(system);
    IdmIdentityDto identity = createIdentity(system);
    setPasswordFilter(system, true);
    assignSystem(createUniformDefinition(true), system);
    cleanProvivisioning(identity, system);
    checkChangeInIdm(identity, 0);
    String password = getHelper().createName();
    PasswordRequest request = prepareRequest(identity.getUsername(), system.getCode(), password);
    IdmPasswordDto idmPassword = passwordService.findOneByIdentity(identity.getId());
    Assert.assertNull(idmPassword);
    checkEmptyProvisioning(identity, system);
    checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
    checkChangeInIdm(identity, 0);
    processValidate(request, true);
    checkEcho(identity, system, EchoCheck.VALIDATE);
    checkChangeInIdm(identity, 0);
    checkEmptyProvisioning(identity, system);
    processChange(request, true);
    checkEcho(identity, system, EchoCheck.VALIDATE_AND_CHANGE);
    checkChangeInIdm(identity, 1);
    checkEmptyProvisioning(identity, system);
    idmPassword = passwordService.findOneByIdentity(identity.getId());
    Assert.assertNotNull(idmPassword);
    // under different user, but set
    Assert.assertNotNull(idmPassword.getValidFrom());
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractPasswordFilterIntegrationTest(eu.bcvsolutions.idm.acc.AbstractPasswordFilterIntegrationTest)

Example 83 with IdmPasswordDto

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

the class DefaultPasswordFilterManagerIntegrationTest method testCheckPasswordValidity10Days.

@Test
public void testCheckPasswordValidity10Days() {
    IdmPasswordPolicyDto passwordPolicy = createPasswordPolicy(null, null, null, null, null, true);
    passwordPolicy.setMaxPasswordAge(10);
    passwordPolicy = passwordPolicyService.save(passwordPolicy);
    SysSystemDto system = createSystem(false);
    IdmIdentityDto identity = createIdentity(system);
    assignSystem(createUniformDefinition(true), system);
    String password = getHelper().createName();
    PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
    passwordChangeDto.setAll(true);
    passwordChangeDto.setNewPassword(new GuardedString(password));
    List<OperationResult> results = identityService.passwordChange(identity, passwordChangeDto);
    assertEquals(2, results.size());
    checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
    checkPassword(prepareUid(identity, system), password, true);
    checkActivePasswordOperation(identity, system, 0, password);
    loginToIdm(identity, password, true);
    IdmPasswordDto passwordDto = passwordService.findOneByIdentity(identity.getId());
    assertNotNull(passwordDto);
    assertEquals(LocalDate.now().plusDays(10), passwordDto.getValidTill());
    Assert.assertNull(passwordDto.getValidFrom());
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) 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) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractPasswordFilterIntegrationTest(eu.bcvsolutions.idm.acc.AbstractPasswordFilterIntegrationTest)

Example 84 with IdmPasswordDto

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

the class DefaultPasswordFilterManagerIntegrationTest method testCheckPasswordValidityPasswordFilterWithoutUniformPassword.

@Test
public void testCheckPasswordValidityPasswordFilterWithoutUniformPassword() {
    SysSystemDto system = createSystem(false);
    IdmIdentityDto identity = createIdentity(system);
    setPasswordFilter(system, true);
    IdmPasswordPolicyDto passwordPolicyDto = createPasswordPolicy(null, null, null, null, null, true);
    passwordPolicyDto.setMaxPasswordAge(50);
    passwordPolicyDto = passwordPolicyService.save(passwordPolicyDto);
    assignSystem(createUniformDefinition(false), system);
    cleanProvivisioning(identity, system);
    checkChangeInIdm(identity, 0);
    String password = getHelper().createName();
    PasswordRequest request = prepareRequest(identity.getUsername(), system.getCode(), password);
    loginToIdm(identity, password, false);
    checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
    checkChangeInIdm(identity, 0);
    processValidate(request, true);
    checkEcho(identity, system, EchoCheck.VALIDATE);
    processChange(request, true);
    loginToIdm(identity, password, false);
    checkEcho(identity, system, EchoCheck.VALIDATE_AND_CHANGE);
    IdmPasswordDto passwordDto = passwordService.findOneByIdentity(identity.getId());
    assertNull(passwordDto);
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractPasswordFilterIntegrationTest(eu.bcvsolutions.idm.acc.AbstractPasswordFilterIntegrationTest)

Example 85 with IdmPasswordDto

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

the class DefaultPasswordFilterManagerIntegrationTest method testCheckPasswordValidityPasswordFilter50daysUniformPassword.

@Test
public void testCheckPasswordValidityPasswordFilter50daysUniformPassword() {
    SysSystemDto system = createSystem(false);
    IdmIdentityDto identity = createIdentity(system);
    setPasswordFilter(system, true);
    IdmPasswordPolicyDto passwordPolicyDto = createPasswordPolicy(null, null, null, null, null, true);
    passwordPolicyDto.setMaxPasswordAge(50);
    passwordPolicyDto = passwordPolicyService.save(passwordPolicyDto);
    assignSystem(createUniformDefinition(true), system);
    cleanProvivisioning(identity, system);
    checkChangeInIdm(identity, 0);
    String password = getHelper().createName();
    PasswordRequest request = prepareRequest(identity.getUsername(), system.getCode(), password);
    loginToIdm(identity, password, false);
    checkEcho(identity, system, EchoCheck.DOESNT_EXIST);
    checkChangeInIdm(identity, 0);
    processValidate(request, true);
    checkEcho(identity, system, EchoCheck.VALIDATE);
    processChange(request, true);
    loginToIdm(identity, password, true);
    checkEcho(identity, system, EchoCheck.VALIDATE_AND_CHANGE);
    IdmPasswordDto passwordDto = passwordService.findOneByIdentity(identity.getId());
    assertNotNull(passwordDto);
    assertEquals(LocalDate.now().plusDays(50), passwordDto.getValidTill());
    assertEquals(LocalDate.now(), passwordDto.getValidFrom());
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractPasswordFilterIntegrationTest(eu.bcvsolutions.idm.acc.AbstractPasswordFilterIntegrationTest)

Aggregations

IdmPasswordDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto)88 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)71 Test (org.junit.Test)65 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)53 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)52 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)28 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)20 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)19 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)11 Transactional (org.springframework.transaction.annotation.Transactional)11 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)10 AbstractPasswordFilterIntegrationTest (eu.bcvsolutions.idm.acc.AbstractPasswordFilterIntegrationTest)9 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)9 IdmProcessedTaskItemDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto)9 IdmScheduledTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto)9 ZonedDateTime (java.time.ZonedDateTime)9 UUID (java.util.UUID)9 IdmPasswordFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordFilter)8 IdmAuthenticationException (eu.bcvsolutions.idm.core.security.api.exception.IdmAuthenticationException)8 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)7