/** * Checks if this credentials object contains secrets that comply with the Credentials * API specification. * * @throws IllegalStateException if no secrets are set or any of the secrets' not-before * and not-after properties are malformed. */ public void checkSecrets() { checkSecrets((secretType, secret) -> {}); }
/** * Checks if this credentials object contains secrets that comply with the Credentials * API specification. * * @throws IllegalStateException if no secrets are set or any of the secrets' not-before * and not-after properties are malformed. */ public void checkSecrets() { checkSecrets((secretType, secret) -> {}); }
/** * Checks if this credentials object is in a consistent state. * * @param secretValidator A custom check that is performed for each secret. The validator * should throw an exception to indicate a failure to * validate the secret. * @throws IllegalStateException if any of the properties have invalid/inconsistent values. * The exception's message property may contain a description of the * problem. */ public void checkValidity(final BiConsumer<String, JsonObject> secretValidator) { if (deviceId == null) { throw new IllegalStateException("missing device ID"); } else if (authId == null) { throw new IllegalStateException("missing auth ID"); } else if (type == null) { throw new IllegalStateException("missing type"); } checkSecrets(secretValidator); }
/** * Checks if this credentials object is in a consistent state. * * @param secretValidator A custom check that is performed for each secret. The validator * should throw an exception to indicate a failure to * validate the secret. * @throws IllegalStateException if any of the properties have invalid/inconsistent values. * The exception's message property may contain a description of the * problem. */ public void checkValidity(final BiConsumer<String, JsonObject> secretValidator) { if (deviceId == null) { throw new IllegalStateException("missing device ID"); } else if (authId == null) { throw new IllegalStateException("missing auth ID"); } else if (type == null) { throw new IllegalStateException("missing type"); } checkSecrets(secretValidator); }
switch(type) { case CredentialsConstants.SECRETS_TYPE_HASHED_PASSWORD: checkSecrets(getSecrets(), secret -> { checkHashedPassword(secret); secretValidator.accept(type, secret); }); default: checkSecrets(getSecrets(), secret -> {});
switch(type) { case CredentialsConstants.SECRETS_TYPE_HASHED_PASSWORD: checkSecrets(getSecrets(), secret -> { checkHashedPassword(secret); secretValidator.accept(type, secret); }); default: checkSecrets(getSecrets(), secret -> {});