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);
}
}
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);
}
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();
}
}
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();
}
}
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());
}
Aggregations