< prev index next >

src/java.base/share/classes/java/security/KeyStore.java

Print this page




1601     {
1602 
1603         if (alias == null || entryClass == null) {
1604             throw new NullPointerException("invalid null input");
1605         }
1606         if (!initialized) {
1607             throw new KeyStoreException("Uninitialized keystore");
1608         }
1609         return keyStoreSpi.engineEntryInstanceOf(alias, entryClass);
1610     }
1611 
1612     /**
1613      * Returns a loaded keystore object of the appropriate keystore type.
1614      * First the keystore type is determined by probing the specified file.
1615      * Then a keystore object is instantiated and loaded using the data from
1616      * that file.
1617      * A password may be supplied to unlock the keystore data or perform an
1618      * integrity check.
1619      *
1620      * <p>
1621      * This method traverses the list of registered security {@link Providers},
1622      * starting with the most preferred Provider.
1623      * For each {@link KeyStoreSpi} implementation supported by a Provider,
1624      * it invokes the {@link engineProbe} method to determine if it supports
1625      * the specified keystore.


1626      * A new KeyStore object is returned that encapsulates the KeyStoreSpi
1627      * implementation from the first Provider that supports the specified file.
1628      *
1629      * <p> Note that the list of registered providers may be retrieved via
1630      * the {@link Security#getProviders() Security.getProviders()} method.
1631      *
1632      * @param  file the keystore file
1633      * @param  password the keystore password, which may be {@code null}
1634      *
1635      * @return a keystore object loaded with keystore data
1636      *
1637      * @throws KeyStoreException if no Provider supports a KeyStoreSpi
1638      *             implementation for the specified keystore file.
1639      * @throws IOException if there is an I/O or format problem with the
1640      *             keystore data, if a password is required but not given,
1641      *             or if the given password was incorrect. If the error is
1642      *             due to a wrong password, the {@link Throwable#getCause cause}
1643      *             of the {@code IOException} should be an
1644      *             {@code UnrecoverableKeyException}.
1645      * @throws NoSuchAlgorithmException if the algorithm used to check the


1655      *
1656      * @see Provider
1657      *
1658      * @since 1.9
1659      */
1660     public static final KeyStore getInstance(File file, char[] password)
1661         throws KeyStoreException, IOException, NoSuchAlgorithmException,
1662             CertificateException {
1663         return getInstance(file, password, null, true);
1664     }
1665 
1666     /**
1667      * Returns a loaded keystore object of the appropriate keystore type.
1668      * First the keystore type is determined by probing the specified file.
1669      * Then a keystore object is instantiated and loaded using the data from
1670      * that file.
1671      * A {@code LoadStoreParameter} may be supplied which specifies how to
1672      * unlock the keystore data or perform an integrity check.
1673      *
1674      * <p>
1675      * This method traverses the list of registered security {@link Providers},
1676      * starting with the most preferred Provider.
1677      * For each {@link KeyStoreSpi} implementation supported by a Provider,
1678      * it invokes the {@link engineProbe} method to determine if it supports
1679      * the specified keystore.

1680      * A new KeyStore object is returned that encapsulates the KeyStoreSpi
1681      * implementation from the first Provider that supports the specified file.
1682      *
1683      * <p> Note that the list of registered providers may be retrieved via
1684      * the {@link Security#getProviders() Security.getProviders()} method.
1685      *
1686      * @param  file the keystore file
1687      * @param  param the {@code LoadStoreParameter} that specifies how to load
1688      *             the keystore, which may be {@code null}
1689      *
1690      * @return a keystore object loaded with keystore data
1691      *
1692      * @throws KeyStoreException if no Provider supports a KeyStoreSpi
1693      *             implementation for the specified keystore file.
1694      * @throws IOException if there is an I/O or format problem with the
1695      *             keystore data. If the error is due to an incorrect
1696      *             {@code ProtectionParameter} (e.g. wrong password)
1697      *             the {@link Throwable#getCause cause} of the
1698      *             {@code IOException} should be an
1699      *             {@code UnrecoverableKeyException}.




1601     {
1602 
1603         if (alias == null || entryClass == null) {
1604             throw new NullPointerException("invalid null input");
1605         }
1606         if (!initialized) {
1607             throw new KeyStoreException("Uninitialized keystore");
1608         }
1609         return keyStoreSpi.engineEntryInstanceOf(alias, entryClass);
1610     }
1611 
1612     /**
1613      * Returns a loaded keystore object of the appropriate keystore type.
1614      * First the keystore type is determined by probing the specified file.
1615      * Then a keystore object is instantiated and loaded using the data from
1616      * that file.
1617      * A password may be supplied to unlock the keystore data or perform an
1618      * integrity check.
1619      *
1620      * <p>
1621      * This method traverses the list of registered security
1622      * {@linkplain Provider providers}, starting with the most
1623      * preferred Provider.
1624      * For each {@link KeyStoreSpi} implementation supported by a
1625      * Provider, it invokes the {@link
1626      * KeyStoreSpi#engineProbe(InputStream) engineProbe} method to
1627      * determine if it supports the specified keystore.
1628      * A new KeyStore object is returned that encapsulates the KeyStoreSpi
1629      * implementation from the first Provider that supports the specified file.
1630      *
1631      * <p> Note that the list of registered providers may be retrieved via
1632      * the {@link Security#getProviders() Security.getProviders()} method.
1633      *
1634      * @param  file the keystore file
1635      * @param  password the keystore password, which may be {@code null}
1636      *
1637      * @return a keystore object loaded with keystore data
1638      *
1639      * @throws KeyStoreException if no Provider supports a KeyStoreSpi
1640      *             implementation for the specified keystore file.
1641      * @throws IOException if there is an I/O or format problem with the
1642      *             keystore data, if a password is required but not given,
1643      *             or if the given password was incorrect. If the error is
1644      *             due to a wrong password, the {@link Throwable#getCause cause}
1645      *             of the {@code IOException} should be an
1646      *             {@code UnrecoverableKeyException}.
1647      * @throws NoSuchAlgorithmException if the algorithm used to check the


1657      *
1658      * @see Provider
1659      *
1660      * @since 1.9
1661      */
1662     public static final KeyStore getInstance(File file, char[] password)
1663         throws KeyStoreException, IOException, NoSuchAlgorithmException,
1664             CertificateException {
1665         return getInstance(file, password, null, true);
1666     }
1667 
1668     /**
1669      * Returns a loaded keystore object of the appropriate keystore type.
1670      * First the keystore type is determined by probing the specified file.
1671      * Then a keystore object is instantiated and loaded using the data from
1672      * that file.
1673      * A {@code LoadStoreParameter} may be supplied which specifies how to
1674      * unlock the keystore data or perform an integrity check.
1675      *
1676      * <p>
1677      * This method traverses the list of registered security {@link
1678      * Provider providers}, starting with the most preferred Provider.
1679      * For each {@link KeyStoreSpi} implementation supported by a
1680      * Provider, it invokes the {@link
1681      * KeyStoreSpi#engineProbe(InputStream) engineProbe} method to
1682      * determine if it supports the specified keystore.
1683      * A new KeyStore object is returned that encapsulates the KeyStoreSpi
1684      * implementation from the first Provider that supports the specified file.
1685      *
1686      * <p> Note that the list of registered providers may be retrieved via
1687      * the {@link Security#getProviders() Security.getProviders()} method.
1688      *
1689      * @param  file the keystore file
1690      * @param  param the {@code LoadStoreParameter} that specifies how to load
1691      *             the keystore, which may be {@code null}
1692      *
1693      * @return a keystore object loaded with keystore data
1694      *
1695      * @throws KeyStoreException if no Provider supports a KeyStoreSpi
1696      *             implementation for the specified keystore file.
1697      * @throws IOException if there is an I/O or format problem with the
1698      *             keystore data. If the error is due to an incorrect
1699      *             {@code ProtectionParameter} (e.g. wrong password)
1700      *             the {@link Throwable#getCause cause} of the
1701      *             {@code IOException} should be an
1702      *             {@code UnrecoverableKeyException}.


< prev index next >