📄 keystore.html
字号:
"../../../guide/security/CryptoSpec.html#AppA"> Java Cryptography Architecture API Specification & Reference </a> for information about standard keystore types.<DT><B>Returns:</B><DD>a keystore object of the specified type.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the requested keystore type is not available in the default provider package or any of the other provider packages that were searched.</DL></DD></DL><HR><A NAME="getInstance(java.lang.String, java.lang.String)"><!-- --></A><H3>getInstance</H3><PRE>public static <A HREF="../../java/security/KeyStore.html">KeyStore</A> <B>getInstance</B>(<A HREF="../../java/lang/String.html">String</A> type, <A HREF="../../java/lang/String.html">String</A> provider) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A>, <A HREF="../../java/security/NoSuchProviderException.html">NoSuchProviderException</A></PRE><DL><DD>Generates a keystore object for the specified keystore type from the specified provider.<DD><DL><DT><B>Parameters:</B><DD><CODE>type</CODE> - the type of keystore. See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java Cryptography Architecture API Specification & Reference </a> for information about standard keystore types.<DD><CODE>provider</CODE> - the name of the provider.<DT><B>Returns:</B><DD>a keystore object of the specified type, as supplied by the specified provider.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the requested keystore type is not available from the provider.<DD><CODE><A HREF="../../java/security/NoSuchProviderException.html">NoSuchProviderException</A></CODE> - if the provider has not been configured.<DT><B>See Also: </B><DD><A HREF="../../java/security/Provider.html"><CODE>Provider</CODE></A></DL></DD></DL><HR><A NAME="getProvider()"><!-- --></A><H3>getProvider</H3><PRE>public final <A HREF="../../java/security/Provider.html">Provider</A> <B>getProvider</B>()</PRE><DL><DD>Returns the provider of this keystore.<DD><DL><DT><B>Returns:</B><DD>the provider of this keystore.</DL></DD></DL><HR><A NAME="getType()"><!-- --></A><H3>getType</H3><PRE>public final <A HREF="../../java/lang/String.html">String</A> <B>getType</B>()</PRE><DL><DD>Returns the type of this keystore.<DD><DL><DT><B>Returns:</B><DD>the type of this keystore.</DL></DD></DL><HR><A NAME="getKey(java.lang.String, char[])"><!-- --></A><H3>getKey</H3><PRE>public final <A HREF="../../java/security/Key.html">Key</A> <B>getKey</B>(<A HREF="../../java/lang/String.html">String</A> alias, char[] password) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A>, <A HREF="../../java/security/NoSuchAlgorithmException.html">NoSuchAlgorithmException</A>, <A HREF="../../java/security/UnrecoverableKeyException.html">UnrecoverableKeyException</A></PRE><DL><DD>Returns the key associated with the given alias, using the given password to recover it.<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DD><CODE>password</CODE> - the password for recovering the key<DT><B>Returns:</B><DD>the requested key, or null if the given alias does not exist or does not identify a <i>key entry</i>.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized (loaded).<DD><CODE><A HREF="../../java/security/NoSuchAlgorithmException.html">NoSuchAlgorithmException</A></CODE> - if the algorithm for recovering the key cannot be found<DD><CODE><A HREF="../../java/security/UnrecoverableKeyException.html">UnrecoverableKeyException</A></CODE> - if the key cannot be recovered (e.g., the given password is wrong).</DL></DD></DL><HR><A NAME="getCertificateChain(java.lang.String)"><!-- --></A><H3>getCertificateChain</H3><PRE>public final <A HREF="../../java/security/cert/Certificate.html">Certificate</A>[] <B>getCertificateChain</B>(<A HREF="../../java/lang/String.html">String</A> alias) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></PRE><DL><DD>Returns the certificate chain associated with the given alias.<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DT><B>Returns:</B><DD>the certificate chain (ordered with the user's certificate first and the root certificate authority last), or null if the given alias does not exist or does not contain a certificate chain (i.e., the given alias identifies either a <i>trusted certificate entry</i> or a <i>key entry</i> without a certificate chain).<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized (loaded).</DL></DD></DL><HR><A NAME="getCertificate(java.lang.String)"><!-- --></A><H3>getCertificate</H3><PRE>public final <A HREF="../../java/security/cert/Certificate.html">Certificate</A> <B>getCertificate</B>(<A HREF="../../java/lang/String.html">String</A> alias) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></PRE><DL><DD>Returns the certificate associated with the given alias. <p>If the given alias name identifies a <i>trusted certificate entry</i>, the certificate associated with that entry is returned. If the given alias name identifies a <i>key entry</i>, the first element of the certificate chain of that entry is returned, or null if that entry does not have a certificate chain.<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DT><B>Returns:</B><DD>the certificate, or null if the given alias does not exist or does not contain a certificate.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized (loaded).</DL></DD></DL><HR><A NAME="getCreationDate(java.lang.String)"><!-- --></A><H3>getCreationDate</H3><PRE>public final <A HREF="../../java/util/Date.html">Date</A> <B>getCreationDate</B>(<A HREF="../../java/lang/String.html">String</A> alias) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></PRE><DL><DD>Returns the creation date of the entry identified by the given alias.<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DT><B>Returns:</B><DD>the creation date of this entry, or null if the given alias does not exist<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized (loaded).</DL></DD></DL><HR><A NAME="setKeyEntry(java.lang.String, java.security.Key, char[], java.security.cert.Certificate[])"><!-- --></A><H3>setKeyEntry</H3><PRE>public final void <B>setKeyEntry</B>(<A HREF="../../java/lang/String.html">String</A> alias, <A HREF="../../java/security/Key.html">Key</A> key, char[] password, <A HREF="../../java/security/cert/Certificate.html">Certificate</A>[] chain) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></PRE><DL><DD>Assigns the given key to the given alias, protecting it with the given password. <p>If the given key is of type <code>java.security.PrivateKey</code>, it must be accompanied by a certificate chain certifying the corresponding public key. <p>If the given alias already exists, the keystore information associated with it is overridden by the given key (and possibly certificate chain).<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DD><CODE>key</CODE> - the key to be associated with the alias<DD><CODE>password</CODE> - the password to protect the key<DD><CODE>chain</CODE> - the certificate chain for the corresponding public key (only required if the given key is of type <code>java.security.PrivateKey</code>).<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized (loaded), the given key cannot be protected, or this operation fails for some other reason</DL></DD></DL><HR><A NAME="setKeyEntry(java.lang.String, byte[], java.security.cert.Certificate[])"><!-- --></A><H3>setKeyEntry</H3><PRE>public final void <B>setKeyEntry</B>(<A HREF="../../java/lang/String.html">String</A> alias, byte[] key, <A HREF="../../java/security/cert/Certificate.html">Certificate</A>[] chain) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></PRE><DL><DD>Assigns the given key (that has already been protected) to the given alias. <p>If the protected key is of type <code>java.security.PrivateKey</code>, it must be accompanied by a certificate chain certifying the corresponding public key. If the underlying keystore implementation is of type <code>jks</code>, <code>key</code> must be encoded as an <code>EncryptedPrivateKeyInfo</code> as defined in the PKCS #8 standard. <p>If the given alias already exists, the keystore information associated with it is overridden by the given key (and possibly certificate chain).<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DD><CODE>key</CODE> - the key (in protected format) to be associated with the alias<DD><CODE>chain</CODE> - the certificate chain for the corresponding public key (only useful if the protected key is of type <code>java.security.PrivateKey</code>).<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized (loaded), or if this operation fails for some other reason.</DL></DD></DL><HR><A NAME="setCertificateEntry(java.lang.String, java.security.cert.Certificate)"><!-- --></A><H3>setCertificateEntry</H3><PRE>public final void <B>setCertificateEntry</B>(<A HREF="../../java/lang/String.html">String</A> alias, <A HREF="../../java/security/cert/Certificate.html">Certificate</A> cert) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></PRE><DL><DD>Assigns the given certificate to the given alias. <p>If the given alias already exists in this keystore and identifies a <i>trusted certificate entry</i>, the certificate associated with it is overridden by the given certificate.<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DD><CODE>cert</CODE> - the certificate<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized, or the given alias already exists and does not identify a <i>trusted certificate entry</i>, or this operation fails for some other reason.</DL></DD></DL><HR><A NAME="deleteEntry(java.lang.String)"><!-- --></A><H3>deleteEntry</H3><PRE>public final void <B>deleteEntry</B>(<A HREF="../../java/lang/String.html">String</A> alias) throws <A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></PRE><DL><DD>Deletes the entry identified by the given alias from this keystore.<DD><DL><DT><B>Parameters:</B><DD><CODE>alias</CODE> - the alias name<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/KeyStoreException.html">KeyStoreException</A></CODE> - if the keystore has not been initialized, or if the entry cannot be removed.</DL></DD></DL><HR><A NAME="aliases()"><!-- --></A><H3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -