-
Type:
CSR
-
Resolution: Approved
-
Priority:
P4
-
Component/s: security-libs
-
None
-
minimal
-
Does not affect existing `getCreationDate` functionality. The new functionality provides a default implementation for `getCreationInstant(String alias)` which is based on existing `getCreationDate`
-
Java API
-
SE
Summary
Add getCreationInstant() to java.security.KeyStore that returns the creation time as an java.time.Instant.
Problem
In the existing getCreationDate() method in java.security.KeyStore returns the creation time as a java.util.Date which is legacy and mutable.
Solution
Add a new method named getCreationInstant() that returns the creation time as an java.time.Instant. At the same time, an engineGetCreationInstant() method is added to KeyStoreSpi which has a default implementation that simply calls engineGetCreationDate() and returns the output as java.time.Instant.
getCreationDate() is not deprecated as java.util.Date is not deprecated and this method is used by providers. This prevents compatibility issues.
Specification
In addition to existing java.util.Date methods, the java.time.Instant methods are added.
In KeyStore.java:
getCreationInstant:
+ /**
+ * Returns the instant that the entry identified by the given alias was
+ * created.
+ *
+ * @param alias the alias name
+ *
+ * @return the instant that the entry identified by the given alias
+ * was created, or {@code null} if the given alias does not exist
+ *
+ * @throws KeyStoreException if the keystore has not been initialized
+ * (loaded)
+ *
+ * @since 27
+ */
+ public final Instant getCreationInstant(String alias)
+ throws KeyStoreException
+ {
getCreationDatechanged to:
/**
* Returns the creation date of the entry identified by the given alias.
+ * <p>
+ * It is recommended to use the {@link #getCreationInstant(String)}
+ * method instead.
*
* @param alias the alias name
*
In KeyStoreSpi:
engineGetCreationInstant:
+ /**
+ * Returns the instant that the entry identified by the given alias was
+ * created.
+ *
+ * @apiNote Subclasses should override this method to directly return an
+ * instant.
+ *
+ * @implSpec
+ * The default implementation calls {@code engineGetCreationDate(alias)}
+ * and returns the output as an {@code Instant} value.
+ *
+ * @param alias the alias name
+ *
+ * @return the instant that the entry identified by the given alias
+ * was created, or {@code null} if the given alias does not exist
+ *
+ * @since 27
+ */
+ public Instant engineGetCreationInstant(String alias) {
- csr of
-
JDK-8374808 Add new methods to KeyStore and KeyStoreSpi that return the creation date as an Instant instead of Date
-
- In Progress
-