private void check(final PasswordPolicySpec policySpec)
throws InvalidPasswordPolicySpecException {
if (policySpec.getMinLength() == 0) {
throw new InvalidPasswordPolicySpecException("Minimum length is zero");
}
if (policySpec.isMustEndWithAlpha() && policySpec.isMustntEndWithAlpha()) {
throw new InvalidPasswordPolicySpecException(
"mustEndWithAlpha and mustntEndWithAlpha are both true");
}
if (policySpec.isMustEndWithAlpha() && policySpec.isMustEndWithDigit()) {
throw new InvalidPasswordPolicySpecException(
"mustEndWithAlpha and mustEndWithDigit are both true");
}
if (policySpec.isMustEndWithDigit() && policySpec.isMustntEndWithDigit()) {
throw new InvalidPasswordPolicySpecException(
"mustEndWithDigit and mustntEndWithDigit are both true");
}
if (policySpec.isMustEndWithNonAlpha() && policySpec.isMustntEndWithNonAlpha()) {
throw new InvalidPasswordPolicySpecException(
"mustEndWithNonAlpha and mustntEndWithNonAlpha are both true");
}
if (policySpec.isMustStartWithAlpha() && policySpec.isMustntStartWithAlpha()) {
throw new InvalidPasswordPolicySpecException(
"mustStartWithAlpha and mustntStartWithAlpha are both true");
}
if (policySpec.isMustStartWithAlpha() && policySpec.isMustStartWithDigit()) {
throw new InvalidPasswordPolicySpecException(
"mustStartWithAlpha and mustStartWithDigit are both true");
}
if (policySpec.isMustStartWithDigit() && policySpec.isMustntStartWithDigit()) {
throw new InvalidPasswordPolicySpecException(
"mustStartWithDigit and mustntStartWithDigit are both true");
}
if (policySpec.isMustStartWithNonAlpha() && policySpec.isMustntStartWithNonAlpha()) {
throw new InvalidPasswordPolicySpecException(
"mustStartWithNonAlpha and mustntStartWithNonAlpha are both true");
}
if (policySpec.getMinLength() > policySpec.getMaxLength()) {
throw new InvalidPasswordPolicySpecException("Minimun length (" + policySpec.getMinLength() + ")"
+ "is greater than maximum length (" + policySpec.getMaxLength() + ")");
}
}