Search in sources :

Example 6 with IdmPasswordDto

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

the class PasswordExpiredIntegrationTest method testNotSendWarningMessageToDisabledIdentity.

@Test
public void testNotSendWarningMessageToDisabledIdentity() {
    // prepare date
    IdmIdentityDto identity = helper.createIdentity();
    // 
    try {
        IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
        password.setValidTill(new LocalDate().minusDays(1));
        passwordService.save(password);
        // disable identity
        identity.setDisabled(true);
        identityService.save(identity);
        // prepare task
        IdmScheduledTaskDto scheduledTask = scheduledTaskService.save(SchedulerTestUtils.createIdmScheduledTask(UUID.randomUUID().toString()));
        IdmLongRunningTaskDto longRunningTask = longRunningService.save(SchedulerTestUtils.createIdmLongRunningTask(scheduledTask, PasswordExpiredTaskExecutor.class));
        PasswordExpiredTaskExecutor executor = AutowireHelper.autowireBean(new PasswordExpiredTaskExecutor());
        executor.setLongRunningTaskId(longRunningTask.getId());
        executor.init(ImmutableMap.of(PasswordExpirationWarningTaskExecutor.PARAMETER_DAYS_BEFORE, "2"));
        // first process
        Boolean result = executor.process();
        Page<IdmProcessedTaskItemDto> logItems = itemService.findLogItems(longRunningTask, null);
        // check
        Assert.assertTrue(result);
        Assert.assertFalse(logItems.getContent().stream().map(IdmProcessedTaskItemDto::getReferencedEntityId).anyMatch(password.getId()::equals));
    } finally {
        identityService.delete(identity);
    }
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LocalDate(org.joda.time.LocalDate) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with IdmPasswordDto

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

the class DefaultIdmPasswordServiceIntegrationTest method testCreatePasswordMultiplePolicies.

@Test
public void testCreatePasswordMultiplePolicies() {
    IdmPasswordPolicyDto policy1 = getTestPolicy(true, IdmPasswordPolicyType.VALIDATE, 365);
    assertNotNull(policy1);
    IdmPasswordPolicyDto policy2 = getTestPolicy(true, IdmPasswordPolicyType.VALIDATE, 5);
    IdmIdentityDto identity = testHelper.createIdentity();
    // 
    IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
    assertEquals(LocalDate.now(), password.getValidFrom());
    assertEquals(identity.getId(), password.getIdentity());
    // default password policy may be only one
    assertEquals(LocalDate.now().plusDays(policy2.getMaxPasswordAge()), password.getValidTill());
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) 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 8 with IdmPasswordDto

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

the class DefaultIdmPasswordServiceIntegrationTest method testCreatePasswordDefaultPolicy.

@Test
public void testCreatePasswordDefaultPolicy() {
    IdmPasswordPolicyDto policy = getTestPolicy(true);
    IdmIdentityDto identity = testHelper.createIdentity();
    // 
    IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
    assertEquals(LocalDate.now(), password.getValidFrom());
    assertEquals(identity.getId(), password.getIdentity());
    assertEquals(LocalDate.now().plusDays(policy.getMaxPasswordAge()), password.getValidTill());
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) 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 9 with IdmPasswordDto

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

the class DefaultIdmPasswordServiceIntegrationTest method testResetUsuccessfulAttemptsAfterPasswordChange.

@Test
@Transactional
public void testResetUsuccessfulAttemptsAfterPasswordChange() {
    IdmIdentityDto identity = testHelper.createIdentity();
    // login
    LoginDto loginDto = new LoginDto();
    loginDto.setUsername(identity.getUsername());
    loginDto.setPassword(new GuardedString("wrong"));
    try {
        loginController.login(loginDto);
    } catch (IdmAuthenticationException ex) {
    // nothing
    }
    try {
        loginController.login(loginDto);
    } catch (IdmAuthenticationException ex) {
    // nothing
    }
    IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
    // 
    Assert.assertEquals(2, password.getUnsuccessfulAttempts());
    // 
    // password change
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setIdm(true);
    passwordChange.setNewPassword(new GuardedString("new"));
    passwordService.save(identity, passwordChange);
    // 
    password = passwordService.findOneByIdentity(identity.getId());
    // 
    Assert.assertEquals(0, password.getUnsuccessfulAttempts());
}
Also used : PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmAuthenticationException(eu.bcvsolutions.idm.core.security.exception.IdmAuthenticationException) 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) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with IdmPasswordDto

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

the class PasswordExpirationWarningTaskExecutor method getItemsToProcess.

@Override
public Page<IdmPasswordDto> getItemsToProcess(Pageable pageable) {
    IdmPasswordFilter filter = new IdmPasswordFilter();
    filter.setValidTill(expiration);
    filter.setIdentityDisabled(Boolean.FALSE);
    Page<IdmPasswordDto> result = passwordService.find(filter, pageable);
    return result;
}
Also used : IdmPasswordFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordFilter) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto)

Aggregations

IdmPasswordDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto)20 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)14 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)11 Test (org.junit.Test)11 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)6 LocalDate (org.joda.time.LocalDate)5 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)4 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)4 IdmProcessedTaskItemDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto)4 IdmScheduledTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto)4 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)3 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)3 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)3 Transactional (org.springframework.transaction.annotation.Transactional)3 PasswordChangeType (eu.bcvsolutions.idm.core.api.domain.PasswordChangeType)2 IdmPasswordValidationDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto)2 ArrayList (java.util.ArrayList)2 DateTime (org.joda.time.DateTime)2 AccModuleDescriptor (eu.bcvsolutions.idm.acc.AccModuleDescriptor)1 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1