📄 keystore.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:35:59 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class KeyStore</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/KeyStore.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/security/KeyPairGeneratorSpi.html"><B>PREV CLASS</B></A> <A HREF="../../java/security/KeyStoreSpi.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="KeyStore.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.security</FONT><BR>Class KeyStore</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<B>java.security.KeyStore</B></PRE><HR><DL><DT>public class <B>KeyStore</B><DT>extends <A HREF="../../java/lang/Object.html">Object</A></DL><P>This class represents an in-memory collection of keys and certificates. It manages two types of entries: <ul> <li><b>Key Entry</b> <p>This type of keystore entry holds very sensitive cryptographic key information, which is stored in a protected format to prevent unauthorized access. <p>Typically, a key stored in this type of entry is a secret key, or a private key accompanied by the certificate chain for the corresponding public key. <p>Private keys and certificate chains are used by a given entity for self-authentication. Applications for this authentication include software distribution organizations which sign JAR files as part of releasing and/or licensing software.<p> <li><b>Trusted Certificate Entry</b> <p>This type of entry contains a single public key certificate belonging to another party. It is called a <i>trusted certificate</i> because the keystore owner trusts that the public key in the certificate indeed belongs to the identity identified by the <i>subject</i> (owner) of the certificate. <p>This type of entry can be used to authenticate other parties. </ul> <p>Each entry in a keystore is identified by an "alias" string. In the case of private keys and their associated certificate chains, these strings distinguish among the different ways in which the entity may authenticate itself. For example, the entity may authenticate itself using different certificate authorities, or using different public key algorithms. <p>Whether keystores are persistent, and the mechanisms used by the keystore if it is persistent, are not specified here. This allows use of a variety of techniques for protecting sensitive (e.g., private or secret) keys. Smart cards or other integrated cryptographic engines (SafeKeyper) are one option, and simpler mechanisms such as files may also be used (in a variety of formats). <p>There are two ways to request a KeyStore object: by specifying either just a keystore type, or both a keystore type and a package provider. <ul> <li>If just a keystore type is specified: <pre> KeyStore ks = KeyStore.getInstance("JKS"); </pre> the system will determine if there is an implementation of the keystore type requested available in the environment, and if there is more than one, if there is a preferred one.<p> <li>If both a keystore type and a package provider are specified: <pre> KeyStore ks = KeyStore.getInstance("JKS", "SUN"); </pre> the system will determine if there is an implementation of the keystore type in the package requested, and throw an exception if there is not. </ul> <p>Before a keystore can be accessed, it must be <A HREF="../../java/security/KeyStore.html#load(java.io.InputStream, char[])"><CODE>loaded</CODE></A>. In order to create an empty keystore, you pass <code>null</code> as the <code>InputStream</code> argument to the <code>load</code> method.<P><DL><DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/security/PrivateKey.html"><CODE>PrivateKey</CODE></A>, <A HREF="../../java/security/cert/Certificate.html"><CODE>Certificate</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected </CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyStore.html#KeyStore(java.security.KeyStoreSpi, java.security.Provider, java.lang.String)">KeyStore</A></B>(<A HREF="../../java/security/KeyStoreSpi.html">KeyStoreSpi</A> keyStoreSpi, <A HREF="../../java/security/Provider.html">Provider</A> provider, <A HREF="../../java/lang/String.html">String</A> type)</CODE><BR> Creates a KeyStore object of the given type, and encapsulates the given provider implementation (SPI object) in it.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/util/Enumeration.html">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyStore.html#aliases()">aliases</A></B>()</CODE><BR> Lists all the alias names of this keystore.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyStore.html#containsAlias(java.lang.String)">containsAlias</A></B>(<A HREF="../../java/lang/String.html">String</A> alias)</CODE><BR> Checks if the given alias exists in this keystore.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyStore.html#deleteEntry(java.lang.String)">deleteEntry</A></B>(<A HREF="../../java/lang/String.html">String</A> alias)</CODE><BR> Deletes the entry identified by the given alias from this keystore.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/security/cert/Certificate.html">Certificate</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/security/KeyStore.html#getCertificate(java.lang.String)">getCertificate</A></B>(<A HREF="../../java/lang/String.html">String</A> alias)</CODE><BR> Returns the certificate associated with the given alias.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -