@Override public void validate(String password) throws InvalidPasswordException { if (password == null) { password = ""; } IdentityProvider<UaaIdentityProviderDefinition> idp = provisioning.retrieveByOrigin(OriginKeys.UAA, IdentityZoneHolder.get().getId()); if (idp==null) { //should never happen return; } PasswordPolicy policy = globalDefaultPolicy; UaaIdentityProviderDefinition idpDefinition = idp.getConfig(); if (idpDefinition != null && idpDefinition.getPasswordPolicy() != null) { policy = idpDefinition.getPasswordPolicy(); } org.passay.PasswordValidator validator = validator(policy, messageResolver); RuleResult result = validator.validate(new PasswordData(password)); if (!result.isValid()) { List<String> errorMessages = new LinkedList<>(); for (String s : validator.getMessages(result)) { errorMessages.add(s); } if (!errorMessages.isEmpty()) { throw new InvalidPasswordException(errorMessages); } } }
@Override public void validate(String clientSecret) throws InvalidClientSecretException { if(clientSecret == null) { throw new InvalidClientSecretException("Client Secret cannot be null."); } ClientSecretPolicy clientSecretPolicy = this.globalDefaultClientSecretPolicy; IdentityZone zone = IdentityZoneHolder.get(); if(zone.getConfig().getClientSecretPolicy().getMinLength() != -1) { clientSecretPolicy = zone.getConfig().getClientSecretPolicy(); } PasswordValidator clientSecretValidator = validator(clientSecretPolicy, messageResolver); RuleResult result = clientSecretValidator.validate(new PasswordData(clientSecret)); if (!result.isValid()) { List<String> errorMessages = new LinkedList<>(); for (String s : clientSecretValidator.getMessages(result)) { errorMessages.add(s); } if (!errorMessages.isEmpty()) { throw new InvalidClientSecretException(errorMessages); } } } }
/** * Checks whether the supplied passwordData has composition. (As suggested by NIST SP-800-63-1) * * @param passwordData to check for composition * * @return true if valid, false otherwise */ private static boolean hasComposition(final PasswordData passwordData) { return COMPOSITION_VALIDATOR.validate(passwordData).isValid(); } }
logger.fine("numberOfCharacteristics: " + numberOfCharacteristics); RuleResult r = currentUser.validate(passwordData); if (r.isValid()) return Collections.emptyList();
pd.setUsername(username); result = validator.validate(pd); if (result.isValid()) { System.out.println("Valid password");
@Override public void validate(String password) throws InvalidPasswordException { if (password == null) { throw new IllegalArgumentException("Password cannot be null"); } IdentityProvider<UaaIdentityProviderDefinition> idp = provisioning.retrieveByOrigin(Origin.UAA, IdentityZoneHolder.get().getId()); if (idp==null) { //should never happen return; } PasswordPolicy policy = globalDefaultPolicy; UaaIdentityProviderDefinition idpDefinition = idp.getConfig(); if (idpDefinition != null && idpDefinition.getPasswordPolicy() != null) { policy = idpDefinition.getPasswordPolicy(); } org.passay.PasswordValidator validator = getPasswordValidator(policy); RuleResult result = validator.validate(new PasswordData(password)); if (!result.isValid()) { List<String> errorMessages = new LinkedList<>(); for (String s : validator.getMessages(result)) { errorMessages.add(s); } if (!errorMessages.isEmpty()) { throw new InvalidPasswordException(errorMessages); } } }
final RuleResult result = validator.validate(new PasswordData(password1)); if (!result.isValid()) { errors.reject("error.password_too_weak");
PasswordValidator validator = new PasswordValidator(Arrays.asList( new LengthRule(8, 255))); RuleResult result = validator.validate(new PasswordData(hashOrPassword)); if(!result.isValid()) { response.addContextualMessage("password", "common.default", Joiner.on(",").join(validator.getMessages(result)));