use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordPolicyServiceIntegrationTest method testValidationProhibitedChars.
@Test
public void testValidationProhibitedChars() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName("test_14");
policy.setType(IdmPasswordPolicyType.GENERATE);
policy.setGenerateType(IdmPasswordPolicyGenerateType.RANDOM);
policy.setMaxPasswordLength(5);
policy.setMinPasswordLength(1);
policy.setProhibitedCharacters("12abcDEF^-!@");
IdmPasswordValidationDto password = new IdmPasswordValidationDto();
try {
password.setPassword("test");
this.passwordPolicyService.validate(password, policy);
password.setPassword("ABde");
this.passwordPolicyService.validate(password, policy);
} catch (Exception e) {
fail("Password validate prohibited characters. " + policy);
}
try {
password.setPassword("tEst");
this.passwordPolicyService.validate(password, policy);
fail("Password validate prohibited characters. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("eddD");
this.passwordPolicyService.validate(password, policy);
fail("Password validate prohibited characters. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("5416");
this.passwordPolicyService.validate(password, policy);
fail("Password validate prohibited characters. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("test!");
this.passwordPolicyService.validate(password, policy);
fail("Password validate prohibited characters. " + policy);
} catch (Exception e) {
// nothing, success
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordPolicyServiceIntegrationTest method testValidateWithForbiddenBeginEnd.
@Test
public void testValidateWithForbiddenBeginEnd() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName("test_14_1");
policy.setType(IdmPasswordPolicyType.VALIDATE);
policy.setMinPasswordLength(0);
policy.setMinNumber(0);
policy.setMinLowerChar(0);
policy.setMinSpecialChar(0);
policy.setMinUpperChar(0);
policy.setProhibitedBeginCharacters("A");
policy.setProhibitedEndCharacters("B");
IdmPasswordValidationDto password = new IdmPasswordValidationDto();
password.setPassword("aAsdfg12B3");
this.passwordPolicyService.validate(password, policy);
try {
password.setPassword("Asdfg12s");
this.passwordPolicyService.validate(password, policy);
fail("A forbidden character at the beginning of the password was not detected");
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("asdfg12B");
this.passwordPolicyService.validate(password, policy);
fail("A forbidden character at the end of the password was not detected");
} catch (Exception e) {
// nothing, success
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordPolicyServiceIntegrationTest method testContainsPersonalNumber.
@Test
public void testContainsPersonalNumber() {
IdmIdentityDto identity = this.getHelper().createIdentity((GuardedString) null);
identity.setExternalCode("123-456-789-0_EEE");
identity = identityService.save(identity);
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setType(IdmPasswordPolicyType.VALIDATE);
policy.setEnchancedControl(true);
policy.setIdentityAttributeCheck(IdmPasswordPolicyIdentityAttributes.EXTERNALCODE.name());
IdmPasswordValidationDto validation = new IdmPasswordValidationDto();
validation.setIdentity(identity);
validation.setPassword("123456789");
// Numbers only
try {
passwordPolicyService.validate(validation, policy);
fail("Password pass.");
} catch (ResultCodeException e) {
// Success
} catch (Exception e) {
fail(e.getMessage());
}
validation.setPassword("jenda123");
try {
passwordPolicyService.validate(validation, policy);
fail("Password pass.");
} catch (ResultCodeException e) {
// Success
} catch (Exception e) {
fail(e.getMessage());
}
// Works with letters
validation.setPassword("999999999ĚÉE");
try {
passwordPolicyService.validate(validation, policy);
fail("Password pass.");
} catch (ResultCodeException e) {
// Success
} catch (Exception e) {
fail(e.getMessage());
}
// Success
validation.setPassword("XXXXXX0");
try {
passwordPolicyService.validate(validation, policy);
} catch (ResultCodeException e) {
fail("Password not pass.");
} catch (Exception e) {
fail(e.getMessage());
}
validation.setPassword("987-654-321");
try {
passwordPolicyService.validate(validation, policy);
} catch (ResultCodeException e) {
fail("Password not pass.");
} catch (Exception e) {
fail(e.getMessage());
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto 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();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordValidationDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordPolicyServiceIntegrationTest method testValidateComplex.
@Test
public void testValidateComplex() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName("test_16");
policy.setType(IdmPasswordPolicyType.GENERATE);
policy.setGenerateType(IdmPasswordPolicyGenerateType.RANDOM);
policy.setMaxPasswordLength(20);
policy.setMinPasswordLength(6);
policy.setMinNumber(3);
policy.setMinLowerChar(3);
policy.setMinSpecialChar(3);
policy.setMinUpperChar(3);
policy.setSpecialCharBase("@#");
policy.setNumberBase("0");
policy.setProhibitedCharacters("*/^mn");
IdmPasswordValidationDto password = new IdmPasswordValidationDto();
try {
password.setPassword("000abc@@@DEF");
this.passwordPolicyService.validate(password, policy);
password.setPassword("F0a@0Ec0b@@D");
this.passwordPolicyService.validate(password, policy);
password.setPassword("#3aBb@C3A1#0c00");
this.passwordPolicyService.validate(password, policy);
} catch (Exception e) {
fail("Password complex validation. " + policy);
}
try {
password.setPassword("001abc@@@DEF");
this.passwordPolicyService.validate(password, policy);
fail("Password complex validation. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("000abc##$DEF");
this.passwordPolicyService.validate(password, policy);
fail("Password complex validation. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("000abc)()DEF");
this.passwordPolicyService.validate(password, policy);
fail("Password complex validation. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("#3aBb@C3A1#0c00idheff");
this.passwordPolicyService.validate(password, policy);
fail("Password complex validation. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("#3aBmb@C3A1#0c00");
this.passwordPolicyService.validate(password, policy);
fail("Password complex validation. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("#3aBb@C3A1n#0c00");
this.passwordPolicyService.validate(password, policy);
fail("Password complex validation. " + policy);
} catch (Exception e) {
// nothing, success
}
try {
password.setPassword("#3mBb*@C3A1n#0c00");
this.passwordPolicyService.validate(password, policy);
fail("Password complex validation. " + policy);
} catch (Exception e) {
// nothing, success
}
}
Aggregations