/** * Gets the <em>not before</em> instant of a secret. * * @param secret The secret. * @return The instant or {@code null} if not-before is not set or * uses an invalid time stamp format. */ public static Instant getNotBefore(final JsonObject secret) { if (secret == null) { return null; } else { return getInstant(secret, CredentialsConstants.FIELD_SECRETS_NOT_BEFORE); } }
/** * Gets the <em>not after</em> instant of a secret. * * @param secret The secret. * @return The instant or {@code null} if not-after is not set or * uses an invalid time stamp format. */ public static Instant getNotAfter(final JsonObject secret) { if (secret == null) { return null; } else { return getInstant(secret, CredentialsConstants.FIELD_SECRETS_NOT_AFTER); } }
/** * Gets the <em>not before</em> instant of a secret. * * @param secret The secret. * @return The instant or {@code null} if not-before is not set or * uses an invalid time stamp format. */ public static Instant getNotBefore(final JsonObject secret) { if (secret == null) { return null; } else { return getInstant(secret, CredentialsConstants.FIELD_SECRETS_NOT_BEFORE); } }
/** * Gets the <em>not after</em> instant of a secret. * * @param secret The secret. * @return The instant or {@code null} if not-after is not set or * uses an invalid time stamp format. */ public static Instant getNotAfter(final JsonObject secret) { if (secret == null) { return null; } else { return getInstant(secret, CredentialsConstants.FIELD_SECRETS_NOT_AFTER); } }
private static Instant getTimestampIfPresentForField(final JsonObject secret, final String field) { final String timestamp = secret.getString(field); if (timestamp == null) { return null; } else { final Instant result = getInstant(timestamp); if (result == null) { throw new IllegalArgumentException("invalid " + field + " property"); } else { return result; } } }
private static Instant getTimestampIfPresentForField(final JsonObject secret, final String field) { final String timestamp = secret.getString(field); if (timestamp == null) { return null; } else { final Instant result = getInstant(timestamp); if (result == null) { throw new IllegalArgumentException("invalid " + field + " property"); } else { return result; } } }
private static Instant getInstant(final JsonObject secret, final String field) { final Object value = secret.getValue(field); if (String.class.isInstance(value)) { return getInstant((String) value); } else { return null; } }
private static Instant getInstant(final JsonObject secret, final String field) { final Object value = secret.getValue(field); if (String.class.isInstance(value)) { return getInstant((String) value); } else { return null; } }