Search in sources :

Example 6 with IdmPasswordHistoryFilter

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

the class AbstractPasswordFilterIntegrationTest method checkChangeInIdm.

protected void checkChangeInIdm(IdmIdentityDto identity, int count) {
    IdmPasswordHistoryFilter filter = new IdmPasswordHistoryFilter();
    filter.setIdentityId(identity.getId());
    List<IdmPasswordHistoryDto> histories = passwordHistoryService.find(filter, null).getContent();
    assertEquals(count, histories.size());
}
Also used : IdmPasswordHistoryFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordHistoryFilter) IdmPasswordHistoryDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordHistoryDto)

Example 7 with IdmPasswordHistoryFilter

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

the class DefaultIdmPasswordHistoryService method getPasswordHistoryForIdentity.

/**
 * Return list of {@link IdmPasswordHistoryDto} for given identity id.
 *
 * @param identityId
 * @param count
 * @return
 */
private List<IdmPasswordHistoryDto> getPasswordHistoryForIdentity(UUID identityId, int count) {
    IdmPasswordHistoryFilter filter = new IdmPasswordHistoryFilter();
    filter.setIdentityId(identityId);
    return this.find(filter, PageRequest.of(0, count, new Sort(Direction.DESC, IdmPasswordHistory_.created.getName()))).getContent();
}
Also used : IdmPasswordHistoryFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordHistoryFilter) Sort(org.springframework.data.domain.Sort)

Example 8 with IdmPasswordHistoryFilter

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

the class DefaultPasswordHistoryIntegrationTest method testFilteringByValidTill.

@Test
public void testFilteringByValidTill() {
    String password = "password-" + System.currentTimeMillis();
    GuardedString passwordAsGuardedString = new GuardedString(password);
    // Change 1
    IdmIdentityDto identity = testHelper.createIdentity(passwordAsGuardedString);
    ZonedDateTime tillOne = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setOldPassword(passwordAsGuardedString);
    passwordChange.setAll(true);
    passwordChange.setIdm(true);
    passwordChange.setNewPassword(new GuardedString(password));
    // Change 2
    identityService.passwordChange(identity, passwordChange);
    getHelper().waitForResult(null, 1, 1);
    ZonedDateTime tillTwo = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    // Change 3
    identityService.passwordChange(identity, passwordChange);
    getHelper().waitForResult(null, 1, 1);
    ZonedDateTime tillThree = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    // Change 4
    identityService.passwordChange(identity, passwordChange);
    getHelper().waitForResult(null, 1, 1);
    ZonedDateTime tillFour = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    IdmPasswordHistoryFilter filter = new IdmPasswordHistoryFilter();
    filter.setIdentityId(identity.getId());
    filter.setTill(tillOne);
    List<IdmPasswordHistoryDto> content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(1, content.size());
    filter.setTill(tillTwo);
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(2, content.size());
    filter.setTill(tillThree);
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(3, content.size());
    filter.setTill(tillFour);
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(4, content.size());
}
Also used : IdmPasswordHistoryFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordHistoryFilter) ZonedDateTime(java.time.ZonedDateTime) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordHistoryDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordHistoryDto) 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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 9 with IdmPasswordHistoryFilter

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

the class DefaultPasswordHistoryIntegrationTest method testFilteringByValidFrom.

@Test
public void testFilteringByValidFrom() {
    String password = "password-" + System.currentTimeMillis();
    GuardedString passwordAsGuardedString = new GuardedString(password);
    // Change 1
    IdmIdentityDto identity = testHelper.createIdentity(passwordAsGuardedString);
    ZonedDateTime fromOne = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setOldPassword(passwordAsGuardedString);
    passwordChange.setAll(true);
    passwordChange.setIdm(true);
    passwordChange.setNewPassword(new GuardedString(password));
    // Change 2
    identityService.passwordChange(identity, passwordChange);
    getHelper().waitForResult(null, 1, 1);
    ZonedDateTime fromTwo = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    // Change 3
    identityService.passwordChange(identity, passwordChange);
    getHelper().waitForResult(null, 1, 1);
    ZonedDateTime fromThree = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    // Change 4
    identityService.passwordChange(identity, passwordChange);
    getHelper().waitForResult(null, 1, 1);
    ZonedDateTime fromFour = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    ;
    IdmPasswordHistoryFilter filter = new IdmPasswordHistoryFilter();
    filter.setIdentityId(identity.getId());
    filter.setFrom(fromOne);
    List<IdmPasswordHistoryDto> content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(3, content.size());
    filter.setFrom(fromTwo);
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(2, content.size());
    filter.setFrom(fromThree);
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(1, content.size());
    filter.setFrom(fromFour);
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(0, content.size());
}
Also used : IdmPasswordHistoryFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordHistoryFilter) ZonedDateTime(java.time.ZonedDateTime) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordHistoryDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordHistoryDto) 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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 10 with IdmPasswordHistoryFilter

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

the class DefaultPasswordHistoryIntegrationTest method testFilteringByCreatorTwo.

@Test
public void testFilteringByCreatorTwo() {
    String password = "password-" + System.currentTimeMillis();
    GuardedString passwordAsGuardedString = new GuardedString(password);
    IdmIdentityDto adminOne = testHelper.createIdentity();
    IdmIdentityDto adminTwo = testHelper.createIdentity();
    loginAsAdmin(adminOne.getUsername());
    // Change 1
    IdmIdentityDto identity = testHelper.createIdentity(passwordAsGuardedString);
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setOldPassword(passwordAsGuardedString);
    passwordChange.setAll(true);
    passwordChange.setIdm(true);
    passwordChange.setNewPassword(new GuardedString(password));
    // Change 2
    identityService.passwordChange(identity, passwordChange);
    logout();
    loginAsAdmin(adminTwo.getUsername());
    // Change 3
    identityService.passwordChange(identity, passwordChange);
    // Change 4
    identityService.passwordChange(identity, passwordChange);
    // Change 5
    identityService.passwordChange(identity, passwordChange);
    IdmPasswordHistoryFilter filter = new IdmPasswordHistoryFilter();
    filter.setCreator(adminOne.getCode());
    List<IdmPasswordHistoryDto> content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(2, content.size());
    filter.setCreator(adminTwo.getCode());
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(3, content.size());
    filter = new IdmPasswordHistoryFilter();
    filter.setIdentityId(identity.getId());
    content = passwordHistoryService.find(filter, null).getContent();
    assertEquals(5, content.size());
}
Also used : IdmPasswordHistoryFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordHistoryFilter) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordHistoryDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordHistoryDto) 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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmPasswordHistoryFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordHistoryFilter)11 IdmPasswordHistoryDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordHistoryDto)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)8 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)8 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)8 Test (org.junit.Test)8 ZonedDateTime (java.time.ZonedDateTime)3 IdmPasswordDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto)1 Sort (org.springframework.data.domain.Sort)1