diff --git a/src/java.base/macosx/classes/apple/security/KeychainStore.java b/src/java.base/macosx/classes/apple/security/KeychainStore.java index c7d42ad28fd..43c0f0b5cbc 100644 --- a/src/java.base/macosx/classes/apple/security/KeychainStore.java +++ b/src/java.base/macosx/classes/apple/security/KeychainStore.java @@ -414,13 +414,15 @@ abstract sealed class KeychainStore extends KeyStoreSpi { } /** - * Returns the creation timestamp (instant) of the entry identified - * by the given alias. + * Returns the creation timestamp as an {@code Instant} value + * of the entry identified by the given alias. * * @param alias the alias name * * @return the creation instant of this entry, or null if the given * alias does not exist + * + * @since 27 */ public Instant engineGetCreationTimestamp(String alias) { final Object entry = entries.get(alias.toLowerCase(Locale.ROOT)); diff --git a/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java b/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java index 0690bd0b4aa..a4c3501d935 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java @@ -222,13 +222,15 @@ public final class JceKeyStore extends KeyStoreSpi { } /** - * Returns the creation timestamp (instant) of the entry identified - * by the given alias. + * Returns the creation timestamp as an {@code Instant} value + * of the entry identified by the given alias. * * @param alias the alias name * * @return the creation instant of this entry, or null if the given * alias does not exist + * + * @since 27 */ public Instant engineGetCreationTimestamp(String alias) { final Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); diff --git a/src/java.base/share/classes/java/security/KeyStore.java b/src/java.base/share/classes/java/security/KeyStore.java index 0f0ea31a865..6d27d09dbc8 100644 --- a/src/java.base/share/classes/java/security/KeyStore.java +++ b/src/java.base/share/classes/java/security/KeyStore.java @@ -1184,7 +1184,8 @@ public class KeyStore { /** * Returns the creation date of the entry identified by the given alias. *

- * Please consider using {@code getCreationTimestamp} instead. + * This method returns a Date, which is mutable and more error-prone. + * Use getCreationTimestamp() instead. * * @param alias the alias name * @@ -1205,8 +1206,8 @@ public class KeyStore { /** - * Returns the creation timestamp (Instant) of the entry identified - * by the given alias. + * Returns the creation timestamp as an {@code Instant} value + * of the entry identified by the given alias. * * @param alias the alias name * @@ -1215,6 +1216,8 @@ public class KeyStore { * * @throws KeyStoreException if the keystore has not been initialized * (loaded). + * + * @since 27 */ public final Instant getCreationTimestamp(String alias) throws KeyStoreException diff --git a/src/java.base/share/classes/java/security/KeyStoreSpi.java b/src/java.base/share/classes/java/security/KeyStoreSpi.java index e59fe2a3bd6..fdf80b59e46 100644 --- a/src/java.base/share/classes/java/security/KeyStoreSpi.java +++ b/src/java.base/share/classes/java/security/KeyStoreSpi.java @@ -129,22 +129,23 @@ public abstract class KeyStoreSpi { public abstract Date engineGetCreationDate(String alias); /** - * Returns the creation timestamp (Instant) of the entry identified - * by the given alias. + * Returns the creation timestamp as an {@code Instant} value + * of the entry identified by the given alias. * - * @implSpec This method simply performs - * {@code engineGetCreationDate(alias)} which returns a {@code Date}. - * If the result is not @{code null} returns - * Instance equivalent to received {@code Date}. + * @implSpec + * The default implementation calls {@code engineGetCreationDate(alias)} + * and returns the output as an {@code Instant} value. * * @param alias the alias name * * @return the creation instant of this entry, or {@code null} * if the given alias does not exist + * + * @since 27 */ public Instant engineGetCreationTimestamp(String alias) { final Date date = engineGetCreationDate(alias); - return date == null? null : date.toInstant(); + return date == null ? null : date.toInstant(); } /** diff --git a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index d202b0df705..95685659d60 100644 --- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -550,13 +550,15 @@ public final class PKCS12KeyStore extends KeyStoreSpi { } /** - * Returns the creation timestamp (Instant) of the entry identified - * by the given alias. + * Returns the creation timestamp as an {@code Instant} value + * of the entry identified by the given alias. * * @param alias the alias name * * @return the creation date of this entry, or null if the given alias does * not exist + * + * @since 27 */ public Instant engineGetCreationTimestamp(String alias) { final Entry entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); diff --git a/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java b/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java index e351f6e332e..56bc2dcd33a 100644 --- a/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java +++ b/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java @@ -236,13 +236,15 @@ abstract class DomainKeyStore extends KeyStoreSpi { } /** - * Returns the creation timestamp (instant) of the entry identified - * by the given alias. + * Returns the creation timestamp as an {@code Instant} value + * of the entry identified by the given alias. * * @param alias the alias name * * @return the creation instant of this entry, or null if the given * alias does not exist + * + * @since 27 */ public Instant engineGetCreationTimestamp(String alias) { diff --git a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java index dca2bdc6a39..e602c017012 100644 --- a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java +++ b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java @@ -237,18 +237,22 @@ public abstract sealed class JavaKeyStore extends KeyStoreSpi { * not exist */ public Date engineGetCreationDate(String alias) { - return Date.from(this.engineGetCreationTimestamp(alias)); + final Instant instant = this.engineGetCreationTimestamp(alias); + return instant == null ? null : Date.from(instant); } /** - * Returns the creation timestamp (instant) of the entry identified by the given alias. + * Returns the creation timestamp as an {@code Instant} value + * of the entry identified by the given alias. * * @param alias the alias name * * @return the creation instant of this entry, or null if the given alias does * not exist + * + * @since 27 */ public Instant engineGetCreationTimestamp(String alias) { final Object entry = entries.get(convertAlias(alias));