📄 certificatefactory.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:36:10 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class CertificateFactory</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/CertificateFactory.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/cert/Certificate.CertificateRep.html"><B>PREV CLASS</B></A> <A HREF="../../../java/security/cert/CertificateFactorySpi.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="CertificateFactory.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.cert</FONT><BR>Class CertificateFactory</H2><PRE><A HREF="../../../java/lang/Object.html">java.lang.Object</A> | +--<B>java.security.cert.CertificateFactory</B></PRE><HR><DL><DT>public class <B>CertificateFactory</B><DT>extends <A HREF="../../../java/lang/Object.html">Object</A></DL><P>This class defines the functionality of a certificate factory, which is used to generate certificate and certificate revocation list (CRL) objects from their encodings. <p>A certificate factory for X.509 must return certificates that are an instance of <code>java.security.cert.X509Certificate</code>, and CRLs that are an instance of <code>java.security.cert.X509CRL</code>. <p>The following example reads a file with Base64 encoded certificates, which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----. We convert the <code>FileInputStream</code> (which does not support <code>mark</code> and <code>reset</code>) to a <code>ByteArrayInputStream</code> (which supports those methods), so that each call to <code>generateCertificate</code> consumes only one certificate, and the read position of the input stream is positioned to the next certificate in the file:<p> <pre> FileInputStream fis = new FileInputStream(filename); DataInputStream dis = new DataInputStream(fis); CertificateFactory cf = CertificateFactory.getInstance("X.509"); byte[] bytes = new byte[dis.available()]; dis.readFully(bytes); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); while (bais.available() > 0) { Certificate cert = cf.generateCertificate(bais); System.out.println(cert.toString()); } </pre> <p>The following example parses a PKCS#7-formatted certificate reply stored in a file and extracts all the certificates from it:<p> <pre> FileInputStream fis = new FileInputStream(filename); CertificateFactory cf = CertificateFactory.getInstance("X.509"); Collection c = cf.generateCertificates(fis); Iterator i = c.iterator(); while (i.hasNext()) { Certificate cert = (Certificate)i.next(); System.out.println(cert); } </pre><P><DL><DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../../java/security/cert/Certificate.html"><CODE>Certificate</CODE></A>, <A HREF="../../../java/security/cert/X509Certificate.html"><CODE>X509Certificate</CODE></A>, <A HREF="../../../java/security/cert/CRL.html"><CODE>CRL</CODE></A>, <A HREF="../../../java/security/cert/X509CRL.html"><CODE>X509CRL</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/cert/CertificateFactory.html#CertificateFactory(java.security.cert.CertificateFactorySpi, java.security.Provider, java.lang.String)">CertificateFactory</A></B>(<A HREF="../../../java/security/cert/CertificateFactorySpi.html">CertificateFactorySpi</A> certFacSpi, <A HREF="../../../java/security/Provider.html">Provider</A> provider, <A HREF="../../../java/lang/String.html">String</A> type)</CODE><BR> Creates a CertificateFactory 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/security/cert/Certificate.html">Certificate</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#generateCertificate(java.io.InputStream)">generateCertificate</A></B>(<A HREF="../../../java/io/InputStream.html">InputStream</A> inStream)</CODE><BR> Generates a certificate object and initializes it with the data read from the input stream <code>inStream</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/util/Collection.html">Collection</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#generateCertificates(java.io.InputStream)">generateCertificates</A></B>(<A HREF="../../../java/io/InputStream.html">InputStream</A> inStream)</CODE><BR> Returns a (possibly empty) collection view of the certificates read from the given input stream <code>inStream</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/security/cert/CRL.html">CRL</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#generateCRL(java.io.InputStream)">generateCRL</A></B>(<A HREF="../../../java/io/InputStream.html">InputStream</A> inStream)</CODE><BR> Generates a certificate revocation list (CRL) object and initializes it with the data read from the input stream <code>inStream</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/util/Collection.html">Collection</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#generateCRLs(java.io.InputStream)">generateCRLs</A></B>(<A HREF="../../../java/io/InputStream.html">InputStream</A> inStream)</CODE><BR> Returns a (possibly empty) collection view of the CRLs read from the given input stream <code>inStream</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../../java/security/cert/CertificateFactory.html">CertificateFactory</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#getInstance(java.lang.String)">getInstance</A></B>(<A HREF="../../../java/lang/String.html">String</A> type)</CODE><BR> Generates a certificate factory object that implements the specified certificate type.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../../java/security/cert/CertificateFactory.html">CertificateFactory</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#getInstance(java.lang.String, java.lang.String)">getInstance</A></B>(<A HREF="../../../java/lang/String.html">String</A> type, <A HREF="../../../java/lang/String.html">String</A> provider)</CODE><BR> Generates a certificate factory object for the specified certificate type from the specified provider.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/security/Provider.html">Provider</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#getProvider()">getProvider</A></B>()</CODE><BR> Returns the provider of this certificate factory.</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><TD><CODE><B><A HREF="../../../java/security/cert/CertificateFactory.html#getType()">getType</A></B>()</CODE><BR> Returns the name of the certificate type associated with this certificate factory.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="CertificateFactory(java.security.cert.CertificateFactorySpi, java.security.Provider, java.lang.String)"><!-- --></A><H3>CertificateFactory</H3><PRE>protected <B>CertificateFactory</B>(<A HREF="../../../java/security/cert/CertificateFactorySpi.html">CertificateFactorySpi</A> certFacSpi, <A HREF="../../../java/security/Provider.html">Provider</A> provider, <A HREF="../../../java/lang/String.html">String</A> type)</PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -