src/java.base/share/classes/java/security/KeyStore.java
changeset 58242 94bb65cb37d3
parent 53018 8bf9268df0e2
equal deleted inserted replaced
58241:33de7752835c 58242:94bb65cb37d3
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   294          * "{@docRoot}/../specs/security/standard-names.html#cipher-algorithm-names">
   294          * "{@docRoot}/../specs/security/standard-names.html#cipher-algorithm-names">
   295          * Java Security Standard Algorithm Names Specification</a>
   295          * Java Security Standard Algorithm Names Specification</a>
   296          *     for information about standard encryption algorithm names.
   296          *     for information about standard encryption algorithm names.
   297          * @param protectionParameters the encryption algorithm parameter
   297          * @param protectionParameters the encryption algorithm parameter
   298          *     specification, which may be {@code null}
   298          *     specification, which may be {@code null}
   299          * @exception NullPointerException if {@code protectionAlgorithm} is
   299          * @throws    NullPointerException if {@code protectionAlgorithm} is
   300          *     {@code null}
   300          *     {@code null}
   301          *
   301          *
   302          * @since 1.8
   302          * @since 1.8
   303          */
   303          */
   304         public PasswordProtection(char[] password, String protectionAlgorithm,
   304         public PasswordProtection(char[] password, String protectionAlgorithm,
   344          * responsibility to zero out the password information
   344          * responsibility to zero out the password information
   345          * after it is no longer needed.
   345          * after it is no longer needed.
   346          *
   346          *
   347          * @see #destroy()
   347          * @see #destroy()
   348          * @return the password, which may be {@code null}
   348          * @return the password, which may be {@code null}
   349          * @exception IllegalStateException if the password has
   349          * @throws    IllegalStateException if the password has
   350          *              been cleared (destroyed)
   350          *              been cleared (destroyed)
   351          */
   351          */
   352         public synchronized char[] getPassword() {
   352         public synchronized char[] getPassword() {
   353             if (destroyed) {
   353             if (destroyed) {
   354                 throw new IllegalStateException("password has been cleared");
   354                 throw new IllegalStateException("password has been cleared");
   357         }
   357         }
   358 
   358 
   359         /**
   359         /**
   360          * Clears the password.
   360          * Clears the password.
   361          *
   361          *
   362          * @exception DestroyFailedException if this method was unable
   362          * @throws    DestroyFailedException if this method was unable
   363          *      to clear the password
   363          *      to clear the password
   364          */
   364          */
   365         public synchronized void destroy() throws DestroyFailedException {
   365         public synchronized void destroy() throws DestroyFailedException {
   366             destroyed = true;
   366             destroyed = true;
   367             if (password != null) {
   367             if (password != null) {
   392         /**
   392         /**
   393          * Constructs a new CallbackHandlerProtection from a
   393          * Constructs a new CallbackHandlerProtection from a
   394          * CallbackHandler.
   394          * CallbackHandler.
   395          *
   395          *
   396          * @param handler the CallbackHandler
   396          * @param handler the CallbackHandler
   397          * @exception NullPointerException if handler is null
   397          * @throws    NullPointerException if handler is null
   398          */
   398          */
   399         public CallbackHandlerProtection(CallbackHandler handler) {
   399         public CallbackHandlerProtection(CallbackHandler handler) {
   400             if (handler == null) {
   400             if (handler == null) {
   401                 throw new NullPointerException("handler must not be null");
   401                 throw new NullPointerException("handler must not be null");
   402             }
   402             }
   483          *      representing the certificate chain.
   483          *      representing the certificate chain.
   484          *      The chain must be ordered and contain a
   484          *      The chain must be ordered and contain a
   485          *      {@code Certificate} at index 0
   485          *      {@code Certificate} at index 0
   486          *      corresponding to the private key.
   486          *      corresponding to the private key.
   487          *
   487          *
   488          * @exception NullPointerException if
   488          * @throws    NullPointerException if
   489          *      {@code privateKey} or {@code chain}
   489          *      {@code privateKey} or {@code chain}
   490          *      is {@code null}
   490          *      is {@code null}
   491          * @exception IllegalArgumentException if the specified chain has a
   491          * @throws    IllegalArgumentException if the specified chain has a
   492          *      length of 0, if the specified chain does not contain
   492          *      length of 0, if the specified chain does not contain
   493          *      {@code Certificate}s of the same type,
   493          *      {@code Certificate}s of the same type,
   494          *      or if the {@code PrivateKey} algorithm
   494          *      or if the {@code PrivateKey} algorithm
   495          *      does not match the algorithm of the {@code PublicKey}
   495          *      does not match the algorithm of the {@code PublicKey}
   496          *      in the end entity {@code Certificate} (at index 0)
   496          *      in the end entity {@code Certificate} (at index 0)
   512          *      The chain must be ordered and contain a
   512          *      The chain must be ordered and contain a
   513          *      {@code Certificate} at index 0
   513          *      {@code Certificate} at index 0
   514          *      corresponding to the private key.
   514          *      corresponding to the private key.
   515          * @param attributes the attributes
   515          * @param attributes the attributes
   516          *
   516          *
   517          * @exception NullPointerException if {@code privateKey}, {@code chain}
   517          * @throws    NullPointerException if {@code privateKey}, {@code chain}
   518          *      or {@code attributes} is {@code null}
   518          *      or {@code attributes} is {@code null}
   519          * @exception IllegalArgumentException if the specified chain has a
   519          * @throws    IllegalArgumentException if the specified chain has a
   520          *      length of 0, if the specified chain does not contain
   520          *      length of 0, if the specified chain does not contain
   521          *      {@code Certificate}s of the same type,
   521          *      {@code Certificate}s of the same type,
   522          *      or if the {@code PrivateKey} algorithm
   522          *      or if the {@code PrivateKey} algorithm
   523          *      does not match the algorithm of the {@code PublicKey}
   523          *      does not match the algorithm of the {@code PublicKey}
   524          *      in the end entity {@code Certificate} (at index 0)
   524          *      in the end entity {@code Certificate} (at index 0)
   649          * Constructs a {@code SecretKeyEntry} with a
   649          * Constructs a {@code SecretKeyEntry} with a
   650          * {@code SecretKey}.
   650          * {@code SecretKey}.
   651          *
   651          *
   652          * @param secretKey the {@code SecretKey}
   652          * @param secretKey the {@code SecretKey}
   653          *
   653          *
   654          * @exception NullPointerException if {@code secretKey}
   654          * @throws    NullPointerException if {@code secretKey}
   655          *      is {@code null}
   655          *      is {@code null}
   656          */
   656          */
   657         public SecretKeyEntry(SecretKey secretKey) {
   657         public SecretKeyEntry(SecretKey secretKey) {
   658             if (secretKey == null) {
   658             if (secretKey == null) {
   659                 throw new NullPointerException("invalid null input");
   659                 throw new NullPointerException("invalid null input");
   670          * in the new {@code SecretKeyEntry} object.
   670          * in the new {@code SecretKeyEntry} object.
   671          *
   671          *
   672          * @param secretKey the {@code SecretKey}
   672          * @param secretKey the {@code SecretKey}
   673          * @param attributes the attributes
   673          * @param attributes the attributes
   674          *
   674          *
   675          * @exception NullPointerException if {@code secretKey} or
   675          * @throws    NullPointerException if {@code secretKey} or
   676          *     {@code attributes} is {@code null}
   676          *     {@code attributes} is {@code null}
   677          *
   677          *
   678          * @since 1.8
   678          * @since 1.8
   679          */
   679          */
   680         public SecretKeyEntry(SecretKey secretKey, Set<Attribute> attributes) {
   680         public SecretKeyEntry(SecretKey secretKey, Set<Attribute> attributes) {
   732          * Constructs a {@code TrustedCertificateEntry} with a
   732          * Constructs a {@code TrustedCertificateEntry} with a
   733          * trusted {@code Certificate}.
   733          * trusted {@code Certificate}.
   734          *
   734          *
   735          * @param trustedCert the trusted {@code Certificate}
   735          * @param trustedCert the trusted {@code Certificate}
   736          *
   736          *
   737          * @exception NullPointerException if
   737          * @throws    NullPointerException if
   738          *      {@code trustedCert} is {@code null}
   738          *      {@code trustedCert} is {@code null}
   739          */
   739          */
   740         public TrustedCertificateEntry(Certificate trustedCert) {
   740         public TrustedCertificateEntry(Certificate trustedCert) {
   741             if (trustedCert == null) {
   741             if (trustedCert == null) {
   742                 throw new NullPointerException("invalid null input");
   742                 throw new NullPointerException("invalid null input");
   753          * in the new {@code TrustedCertificateEntry} object.
   753          * in the new {@code TrustedCertificateEntry} object.
   754          *
   754          *
   755          * @param trustedCert the trusted {@code Certificate}
   755          * @param trustedCert the trusted {@code Certificate}
   756          * @param attributes the attributes
   756          * @param attributes the attributes
   757          *
   757          *
   758          * @exception NullPointerException if {@code trustedCert} or
   758          * @throws    NullPointerException if {@code trustedCert} or
   759          *     {@code attributes} is {@code null}
   759          *     {@code attributes} is {@code null}
   760          *
   760          *
   761          * @since 1.8
   761          * @since 1.8
   762          */
   762          */
   763         public TrustedCertificateEntry(Certificate trustedCert,
   763         public TrustedCertificateEntry(Certificate trustedCert,
  1031      * @param password the password for recovering the key
  1031      * @param password the password for recovering the key
  1032      *
  1032      *
  1033      * @return the requested key, or null if the given alias does not exist
  1033      * @return the requested key, or null if the given alias does not exist
  1034      * or does not identify a key-related entry.
  1034      * or does not identify a key-related entry.
  1035      *
  1035      *
  1036      * @exception KeyStoreException if the keystore has not been initialized
  1036      * @throws    KeyStoreException if the keystore has not been initialized
  1037      * (loaded).
  1037      * (loaded).
  1038      * @exception NoSuchAlgorithmException if the algorithm for recovering the
  1038      * @throws    NoSuchAlgorithmException if the algorithm for recovering the
  1039      * key cannot be found
  1039      * key cannot be found
  1040      * @exception UnrecoverableKeyException if the key cannot be recovered
  1040      * @throws    UnrecoverableKeyException if the key cannot be recovered
  1041      * (e.g., the given password is wrong).
  1041      * (e.g., the given password is wrong).
  1042      */
  1042      */
  1043     public final Key getKey(String alias, char[] password)
  1043     public final Key getKey(String alias, char[] password)
  1044         throws KeyStoreException, NoSuchAlgorithmException,
  1044         throws KeyStoreException, NoSuchAlgorithmException,
  1045             UnrecoverableKeyException
  1045             UnrecoverableKeyException
  1061      *
  1061      *
  1062      * @return the certificate chain (ordered with the user's certificate first
  1062      * @return the certificate chain (ordered with the user's certificate first
  1063      * followed by zero or more certificate authorities), or null if the given alias
  1063      * followed by zero or more certificate authorities), or null if the given alias
  1064      * does not exist or does not contain a certificate chain
  1064      * does not exist or does not contain a certificate chain
  1065      *
  1065      *
  1066      * @exception KeyStoreException if the keystore has not been initialized
  1066      * @throws    KeyStoreException if the keystore has not been initialized
  1067      * (loaded).
  1067      * (loaded).
  1068      */
  1068      */
  1069     public final Certificate[] getCertificateChain(String alias)
  1069     public final Certificate[] getCertificateChain(String alias)
  1070         throws KeyStoreException
  1070         throws KeyStoreException
  1071     {
  1071     {
  1094      * @param alias the alias name
  1094      * @param alias the alias name
  1095      *
  1095      *
  1096      * @return the certificate, or null if the given alias does not exist or
  1096      * @return the certificate, or null if the given alias does not exist or
  1097      * does not contain a certificate.
  1097      * does not contain a certificate.
  1098      *
  1098      *
  1099      * @exception KeyStoreException if the keystore has not been initialized
  1099      * @throws    KeyStoreException if the keystore has not been initialized
  1100      * (loaded).
  1100      * (loaded).
  1101      */
  1101      */
  1102     public final Certificate getCertificate(String alias)
  1102     public final Certificate getCertificate(String alias)
  1103         throws KeyStoreException
  1103         throws KeyStoreException
  1104     {
  1104     {
  1114      * @param alias the alias name
  1114      * @param alias the alias name
  1115      *
  1115      *
  1116      * @return the creation date of this entry, or null if the given alias does
  1116      * @return the creation date of this entry, or null if the given alias does
  1117      * not exist
  1117      * not exist
  1118      *
  1118      *
  1119      * @exception KeyStoreException if the keystore has not been initialized
  1119      * @throws    KeyStoreException if the keystore has not been initialized
  1120      * (loaded).
  1120      * (loaded).
  1121      */
  1121      */
  1122     public final Date getCreationDate(String alias)
  1122     public final Date getCreationDate(String alias)
  1123         throws KeyStoreException
  1123         throws KeyStoreException
  1124     {
  1124     {
  1145      * @param password the password to protect the key
  1145      * @param password the password to protect the key
  1146      * @param chain the certificate chain for the corresponding public
  1146      * @param chain the certificate chain for the corresponding public
  1147      * key (only required if the given key is of type
  1147      * key (only required if the given key is of type
  1148      * {@code java.security.PrivateKey}).
  1148      * {@code java.security.PrivateKey}).
  1149      *
  1149      *
  1150      * @exception KeyStoreException if the keystore has not been initialized
  1150      * @throws    KeyStoreException if the keystore has not been initialized
  1151      * (loaded), the given key cannot be protected, or this operation fails
  1151      * (loaded), the given key cannot be protected, or this operation fails
  1152      * for some other reason
  1152      * for some other reason
  1153      */
  1153      */
  1154     public final void setKeyEntry(String alias, Key key, char[] password,
  1154     public final void setKeyEntry(String alias, Key key, char[] password,
  1155                                   Certificate[] chain)
  1155                                   Certificate[] chain)
  1186      * @param key the key (in protected format) to be associated with the alias
  1186      * @param key the key (in protected format) to be associated with the alias
  1187      * @param chain the certificate chain for the corresponding public
  1187      * @param chain the certificate chain for the corresponding public
  1188      *          key (only useful if the protected key is of type
  1188      *          key (only useful if the protected key is of type
  1189      *          {@code java.security.PrivateKey}).
  1189      *          {@code java.security.PrivateKey}).
  1190      *
  1190      *
  1191      * @exception KeyStoreException if the keystore has not been initialized
  1191      * @throws    KeyStoreException if the keystore has not been initialized
  1192      * (loaded), or if this operation fails for some other reason.
  1192      * (loaded), or if this operation fails for some other reason.
  1193      */
  1193      */
  1194     public final void setKeyEntry(String alias, byte[] key,
  1194     public final void setKeyEntry(String alias, byte[] key,
  1195                                   Certificate[] chain)
  1195                                   Certificate[] chain)
  1196         throws KeyStoreException
  1196         throws KeyStoreException
  1212      * is overridden by the given certificate.
  1212      * is overridden by the given certificate.
  1213      *
  1213      *
  1214      * @param alias the alias name
  1214      * @param alias the alias name
  1215      * @param cert the certificate
  1215      * @param cert the certificate
  1216      *
  1216      *
  1217      * @exception KeyStoreException if the keystore has not been initialized,
  1217      * @throws    KeyStoreException if the keystore has not been initialized,
  1218      * or the given alias already exists and does not identify an
  1218      * or the given alias already exists and does not identify an
  1219      * entry containing a trusted certificate,
  1219      * entry containing a trusted certificate,
  1220      * or this operation fails for some other reason.
  1220      * or this operation fails for some other reason.
  1221      */
  1221      */
  1222     public final void setCertificateEntry(String alias, Certificate cert)
  1222     public final void setCertificateEntry(String alias, Certificate cert)
  1231     /**
  1231     /**
  1232      * Deletes the entry identified by the given alias from this keystore.
  1232      * Deletes the entry identified by the given alias from this keystore.
  1233      *
  1233      *
  1234      * @param alias the alias name
  1234      * @param alias the alias name
  1235      *
  1235      *
  1236      * @exception KeyStoreException if the keystore has not been initialized,
  1236      * @throws    KeyStoreException if the keystore has not been initialized,
  1237      * or if the entry cannot be removed.
  1237      * or if the entry cannot be removed.
  1238      */
  1238      */
  1239     public final void deleteEntry(String alias)
  1239     public final void deleteEntry(String alias)
  1240         throws KeyStoreException
  1240         throws KeyStoreException
  1241     {
  1241     {
  1248     /**
  1248     /**
  1249      * Lists all the alias names of this keystore.
  1249      * Lists all the alias names of this keystore.
  1250      *
  1250      *
  1251      * @return enumeration of the alias names
  1251      * @return enumeration of the alias names
  1252      *
  1252      *
  1253      * @exception KeyStoreException if the keystore has not been initialized
  1253      * @throws    KeyStoreException if the keystore has not been initialized
  1254      * (loaded).
  1254      * (loaded).
  1255      */
  1255      */
  1256     public final Enumeration<String> aliases()
  1256     public final Enumeration<String> aliases()
  1257         throws KeyStoreException
  1257         throws KeyStoreException
  1258     {
  1258     {
  1267      *
  1267      *
  1268      * @param alias the alias name
  1268      * @param alias the alias name
  1269      *
  1269      *
  1270      * @return true if the alias exists, false otherwise
  1270      * @return true if the alias exists, false otherwise
  1271      *
  1271      *
  1272      * @exception KeyStoreException if the keystore has not been initialized
  1272      * @throws    KeyStoreException if the keystore has not been initialized
  1273      * (loaded).
  1273      * (loaded).
  1274      */
  1274      */
  1275     public final boolean containsAlias(String alias)
  1275     public final boolean containsAlias(String alias)
  1276         throws KeyStoreException
  1276         throws KeyStoreException
  1277     {
  1277     {
  1284     /**
  1284     /**
  1285      * Retrieves the number of entries in this keystore.
  1285      * Retrieves the number of entries in this keystore.
  1286      *
  1286      *
  1287      * @return the number of entries in this keystore
  1287      * @return the number of entries in this keystore
  1288      *
  1288      *
  1289      * @exception KeyStoreException if the keystore has not been initialized
  1289      * @throws    KeyStoreException if the keystore has not been initialized
  1290      * (loaded).
  1290      * (loaded).
  1291      */
  1291      */
  1292     public final int size()
  1292     public final int size()
  1293         throws KeyStoreException
  1293         throws KeyStoreException
  1294     {
  1294     {
  1307      * @param alias the alias for the keystore entry to be checked
  1307      * @param alias the alias for the keystore entry to be checked
  1308      *
  1308      *
  1309      * @return true if the entry identified by the given alias is a
  1309      * @return true if the entry identified by the given alias is a
  1310      * key-related entry, false otherwise.
  1310      * key-related entry, false otherwise.
  1311      *
  1311      *
  1312      * @exception KeyStoreException if the keystore has not been initialized
  1312      * @throws    KeyStoreException if the keystore has not been initialized
  1313      * (loaded).
  1313      * (loaded).
  1314      */
  1314      */
  1315     public final boolean isKeyEntry(String alias)
  1315     public final boolean isKeyEntry(String alias)
  1316         throws KeyStoreException
  1316         throws KeyStoreException
  1317     {
  1317     {
  1330      * @param alias the alias for the keystore entry to be checked
  1330      * @param alias the alias for the keystore entry to be checked
  1331      *
  1331      *
  1332      * @return true if the entry identified by the given alias contains a
  1332      * @return true if the entry identified by the given alias contains a
  1333      * trusted certificate, false otherwise.
  1333      * trusted certificate, false otherwise.
  1334      *
  1334      *
  1335      * @exception KeyStoreException if the keystore has not been initialized
  1335      * @throws    KeyStoreException if the keystore has not been initialized
  1336      * (loaded).
  1336      * (loaded).
  1337      */
  1337      */
  1338     public final boolean isCertificateEntry(String alias)
  1338     public final boolean isCertificateEntry(String alias)
  1339         throws KeyStoreException
  1339         throws KeyStoreException
  1340     {
  1340     {
  1365      * @param cert the certificate to match with.
  1365      * @param cert the certificate to match with.
  1366      *
  1366      *
  1367      * @return the alias name of the first entry with a matching certificate,
  1367      * @return the alias name of the first entry with a matching certificate,
  1368      * or null if no such entry exists in this keystore.
  1368      * or null if no such entry exists in this keystore.
  1369      *
  1369      *
  1370      * @exception KeyStoreException if the keystore has not been initialized
  1370      * @throws    KeyStoreException if the keystore has not been initialized
  1371      * (loaded).
  1371      * (loaded).
  1372      */
  1372      */
  1373     public final String getCertificateAlias(Certificate cert)
  1373     public final String getCertificateAlias(Certificate cert)
  1374         throws KeyStoreException
  1374         throws KeyStoreException
  1375     {
  1375     {
  1384      * integrity with the given password.
  1384      * integrity with the given password.
  1385      *
  1385      *
  1386      * @param stream the output stream to which this keystore is written.
  1386      * @param stream the output stream to which this keystore is written.
  1387      * @param password the password to generate the keystore integrity check
  1387      * @param password the password to generate the keystore integrity check
  1388      *
  1388      *
  1389      * @exception KeyStoreException if the keystore has not been initialized
  1389      * @throws    KeyStoreException if the keystore has not been initialized
  1390      * (loaded).
  1390      * (loaded).
  1391      * @exception IOException if there was an I/O problem with data
  1391      * @throws    IOException if there was an I/O problem with data
  1392      * @exception NoSuchAlgorithmException if the appropriate data integrity
  1392      * @throws    NoSuchAlgorithmException if the appropriate data integrity
  1393      * algorithm could not be found
  1393      * algorithm could not be found
  1394      * @exception CertificateException if any of the certificates included in
  1394      * @throws    CertificateException if any of the certificates included in
  1395      * the keystore data could not be stored
  1395      * the keystore data could not be stored
  1396      */
  1396      */
  1397     public final void store(OutputStream stream, char[] password)
  1397     public final void store(OutputStream stream, char[] password)
  1398         throws KeyStoreException, IOException, NoSuchAlgorithmException,
  1398         throws KeyStoreException, IOException, NoSuchAlgorithmException,
  1399             CertificateException
  1399             CertificateException
  1409      *
  1409      *
  1410      * @param param the {@code LoadStoreParameter}
  1410      * @param param the {@code LoadStoreParameter}
  1411      *          that specifies how to store the keystore,
  1411      *          that specifies how to store the keystore,
  1412      *          which may be {@code null}
  1412      *          which may be {@code null}
  1413      *
  1413      *
  1414      * @exception IllegalArgumentException if the given
  1414      * @throws    IllegalArgumentException if the given
  1415      *          {@code LoadStoreParameter}
  1415      *          {@code LoadStoreParameter}
  1416      *          input is not recognized
  1416      *          input is not recognized
  1417      * @exception KeyStoreException if the keystore has not been initialized
  1417      * @throws    KeyStoreException if the keystore has not been initialized
  1418      *          (loaded)
  1418      *          (loaded)
  1419      * @exception IOException if there was an I/O problem with data
  1419      * @throws    IOException if there was an I/O problem with data
  1420      * @exception NoSuchAlgorithmException if the appropriate data integrity
  1420      * @throws    NoSuchAlgorithmException if the appropriate data integrity
  1421      *          algorithm could not be found
  1421      *          algorithm could not be found
  1422      * @exception CertificateException if any of the certificates included in
  1422      * @throws    CertificateException if any of the certificates included in
  1423      *          the keystore data could not be stored
  1423      *          the keystore data could not be stored
  1424      *
  1424      *
  1425      * @since 1.5
  1425      * @since 1.5
  1426      */
  1426      */
  1427     public final void store(LoadStoreParameter param)
  1427     public final void store(LoadStoreParameter param)
  1453      * or {@code null}
  1453      * or {@code null}
  1454      * @param password the password used to check the integrity of
  1454      * @param password the password used to check the integrity of
  1455      * the keystore, the password used to unlock the keystore,
  1455      * the keystore, the password used to unlock the keystore,
  1456      * or {@code null}
  1456      * or {@code null}
  1457      *
  1457      *
  1458      * @exception IOException if there is an I/O or format problem with the
  1458      * @throws    IOException if there is an I/O or format problem with the
  1459      * keystore data, if a password is required but not given,
  1459      * keystore data, if a password is required but not given,
  1460      * or if the given password was incorrect. If the error is due to a
  1460      * or if the given password was incorrect. If the error is due to a
  1461      * wrong password, the {@link Throwable#getCause cause} of the
  1461      * wrong password, the {@link Throwable#getCause cause} of the
  1462      * {@code IOException} should be an
  1462      * {@code IOException} should be an
  1463      * {@code UnrecoverableKeyException}
  1463      * {@code UnrecoverableKeyException}
  1464      * @exception NoSuchAlgorithmException if the algorithm used to check
  1464      * @throws    NoSuchAlgorithmException if the algorithm used to check
  1465      * the integrity of the keystore cannot be found
  1465      * the integrity of the keystore cannot be found
  1466      * @exception CertificateException if any of the certificates in the
  1466      * @throws    CertificateException if any of the certificates in the
  1467      * keystore could not be loaded
  1467      * keystore could not be loaded
  1468      */
  1468      */
  1469     public final void load(InputStream stream, char[] password)
  1469     public final void load(InputStream stream, char[] password)
  1470         throws IOException, NoSuchAlgorithmException, CertificateException
  1470         throws IOException, NoSuchAlgorithmException, CertificateException
  1471     {
  1471     {
  1481      *
  1481      *
  1482      * @param param the {@code LoadStoreParameter}
  1482      * @param param the {@code LoadStoreParameter}
  1483      *          that specifies how to load the keystore,
  1483      *          that specifies how to load the keystore,
  1484      *          which may be {@code null}
  1484      *          which may be {@code null}
  1485      *
  1485      *
  1486      * @exception IllegalArgumentException if the given
  1486      * @throws    IllegalArgumentException if the given
  1487      *          {@code LoadStoreParameter}
  1487      *          {@code LoadStoreParameter}
  1488      *          input is not recognized
  1488      *          input is not recognized
  1489      * @exception IOException if there is an I/O or format problem with the
  1489      * @throws    IOException if there is an I/O or format problem with the
  1490      *          keystore data. If the error is due to an incorrect
  1490      *          keystore data. If the error is due to an incorrect
  1491      *         {@code ProtectionParameter} (e.g. wrong password)
  1491      *         {@code ProtectionParameter} (e.g. wrong password)
  1492      *         the {@link Throwable#getCause cause} of the
  1492      *         the {@link Throwable#getCause cause} of the
  1493      *         {@code IOException} should be an
  1493      *         {@code IOException} should be an
  1494      *         {@code UnrecoverableKeyException}
  1494      *         {@code UnrecoverableKeyException}
  1495      * @exception NoSuchAlgorithmException if the algorithm used to check
  1495      * @throws    NoSuchAlgorithmException if the algorithm used to check
  1496      *          the integrity of the keystore cannot be found
  1496      *          the integrity of the keystore cannot be found
  1497      * @exception CertificateException if any of the certificates in the
  1497      * @throws    CertificateException if any of the certificates in the
  1498      *          keystore could not be loaded
  1498      *          keystore could not be loaded
  1499      *
  1499      *
  1500      * @since 1.5
  1500      * @since 1.5
  1501      */
  1501      */
  1502     public final void load(LoadStoreParameter param)
  1502     public final void load(LoadStoreParameter param)
  1517      *          which may be {@code null}
  1517      *          which may be {@code null}
  1518      *
  1518      *
  1519      * @return the keystore {@code Entry} for the specified alias,
  1519      * @return the keystore {@code Entry} for the specified alias,
  1520      *          or {@code null} if there is no such entry
  1520      *          or {@code null} if there is no such entry
  1521      *
  1521      *
  1522      * @exception NullPointerException if
  1522      * @throws    NullPointerException if
  1523      *          {@code alias} is {@code null}
  1523      *          {@code alias} is {@code null}
  1524      * @exception NoSuchAlgorithmException if the algorithm for recovering the
  1524      * @throws    NoSuchAlgorithmException if the algorithm for recovering the
  1525      *          entry cannot be found
  1525      *          entry cannot be found
  1526      * @exception UnrecoverableEntryException if the specified
  1526      * @throws    UnrecoverableEntryException if the specified
  1527      *          {@code protParam} were insufficient or invalid
  1527      *          {@code protParam} were insufficient or invalid
  1528      * @exception UnrecoverableKeyException if the entry is a
  1528      * @throws    UnrecoverableKeyException if the entry is a
  1529      *          {@code PrivateKeyEntry} or {@code SecretKeyEntry}
  1529      *          {@code PrivateKeyEntry} or {@code SecretKeyEntry}
  1530      *          and the specified {@code protParam} does not contain
  1530      *          and the specified {@code protParam} does not contain
  1531      *          the information needed to recover the key (e.g. wrong password)
  1531      *          the information needed to recover the key (e.g. wrong password)
  1532      * @exception KeyStoreException if the keystore has not been initialized
  1532      * @throws    KeyStoreException if the keystore has not been initialized
  1533      *          (loaded).
  1533      *          (loaded).
  1534      * @see #setEntry(String, KeyStore.Entry, KeyStore.ProtectionParameter)
  1534      * @see #setEntry(String, KeyStore.Entry, KeyStore.ProtectionParameter)
  1535      *
  1535      *
  1536      * @since 1.5
  1536      * @since 1.5
  1537      */
  1537      */
  1560      * @param entry the {@code Entry} to save
  1560      * @param entry the {@code Entry} to save
  1561      * @param protParam the {@code ProtectionParameter}
  1561      * @param protParam the {@code ProtectionParameter}
  1562      *          used to protect the {@code Entry},
  1562      *          used to protect the {@code Entry},
  1563      *          which may be {@code null}
  1563      *          which may be {@code null}
  1564      *
  1564      *
  1565      * @exception NullPointerException if
  1565      * @throws    NullPointerException if
  1566      *          {@code alias} or {@code entry}
  1566      *          {@code alias} or {@code entry}
  1567      *          is {@code null}
  1567      *          is {@code null}
  1568      * @exception KeyStoreException if the keystore has not been initialized
  1568      * @throws    KeyStoreException if the keystore has not been initialized
  1569      *          (loaded), or if this operation fails for some other reason
  1569      *          (loaded), or if this operation fails for some other reason
  1570      *
  1570      *
  1571      * @see #getEntry(String, KeyStore.ProtectionParameter)
  1571      * @see #getEntry(String, KeyStore.ProtectionParameter)
  1572      *
  1572      *
  1573      * @since 1.5
  1573      * @since 1.5
  1594      *
  1594      *
  1595      * @return true if the keystore {@code Entry} for the specified
  1595      * @return true if the keystore {@code Entry} for the specified
  1596      *          {@code alias} is an instance or subclass of the
  1596      *          {@code alias} is an instance or subclass of the
  1597      *          specified {@code entryClass}, false otherwise
  1597      *          specified {@code entryClass}, false otherwise
  1598      *
  1598      *
  1599      * @exception NullPointerException if
  1599      * @throws    NullPointerException if
  1600      *          {@code alias} or {@code entryClass}
  1600      *          {@code alias} or {@code entryClass}
  1601      *          is {@code null}
  1601      *          is {@code null}
  1602      * @exception KeyStoreException if the keystore has not been
  1602      * @throws    KeyStoreException if the keystore has not been
  1603      *          initialized (loaded)
  1603      *          initialized (loaded)
  1604      *
  1604      *
  1605      * @since 1.5
  1605      * @since 1.5
  1606      */
  1606      */
  1607     public final boolean
  1607     public final boolean
  1839 
  1839 
  1840         /**
  1840         /**
  1841          * Returns the KeyStore described by this object.
  1841          * Returns the KeyStore described by this object.
  1842          *
  1842          *
  1843          * @return the {@code KeyStore} described by this object
  1843          * @return the {@code KeyStore} described by this object
  1844          * @exception KeyStoreException if an error occurred during the
  1844          * @throws    KeyStoreException if an error occurred during the
  1845          *   operation, for example if the KeyStore could not be
  1845          *   operation, for example if the KeyStore could not be
  1846          *   instantiated or loaded
  1846          *   instantiated or loaded
  1847          */
  1847          */
  1848         public abstract KeyStore getKeyStore() throws KeyStoreException;
  1848         public abstract KeyStore getKeyStore() throws KeyStoreException;
  1849 
  1849