📄 pkixcertpath.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: PKIXCertPath.java
package org.bouncycastle.jce.provider;
import java.io.*;
import java.security.NoSuchProviderException;
import java.security.cert.*;
import java.util.*;
import org.bouncycastle.asn1.*;
public class PKIXCertPath extends CertPath
{
static final List certPathEncodings;
private List certificates;
PKIXCertPath(List certificates)
{
super("X.509");
this.certificates = new ArrayList(certificates);
}
PKIXCertPath(InputStream inStream, String encoding)
throws CertificateException
{
super("X.509");
try
{
if (encoding.equals("PkiPath"))
{
DERInputStream derInStream = new DERInputStream(inStream);
DERObject derObject = derInStream.readObject();
if (derObject == null || !(derObject instanceof ASN1Sequence))
throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath");
Enumeration enumx = ((ASN1Sequence)derObject).getObjects();
certificates = new ArrayList();
CertificateFactory certFactory = CertificateFactory.getInstance("X.509", "BC");
InputStream certInStream;
for (; enumx.hasMoreElements(); certificates.add(0, certFactory.generateCertificate(certInStream)))
{
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DEROutputStream derOutStream = new DEROutputStream(outStream);
derOutStream.writeObject(enumx.nextElement());
derOutStream.close();
certInStream = new ByteArrayInputStream(outStream.toByteArray());
}
} else
{
throw new CertificateException("unsupported encoding");
}
}
catch (IOException ex)
{
throw new CertificateException((new StringBuilder()).append("IOException throw while decoding CertPath:\n").append(ex.toString()).toString());
}
catch (NoSuchProviderException ex)
{
throw new CertificateException((new StringBuilder()).append("BouncyCastle provider not found while trying to get a CertificateFactory:\n").append(ex.toString()).toString());
}
}
public Iterator getEncodings()
{
return certPathEncodings.iterator();
}
public byte[] getEncoded()
throws CertificateEncodingException
{
Iterator iter = getEncodings();
if (iter.hasNext())
{
Object enc = iter.next();
if (enc instanceof String)
return getEncoded((String)enc);
}
return null;
}
public byte[] getEncoded(String encoding)
throws CertificateEncodingException
{
DERObject encoded = null;
if (encoding.equals("PkiPath"))
{
ASN1EncodableVector v = new ASN1EncodableVector();
for (ListIterator iter = certificates.listIterator(certificates.size()); iter.hasPrevious(); v.add(getEncodedX509Certificate((X509Certificate)iter.previous())));
encoded = new DERSequence(v);
} else
{
throw new CertificateEncodingException("unsupported encoding");
}
if (encoded == null)
return null;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DEROutputStream derOutStream = new DEROutputStream(outStream);
try
{
derOutStream.writeObject(encoded);
derOutStream.close();
}
catch (IOException ex)
{
throw new CertificateEncodingException((new StringBuilder()).append("IOExeption thrown: ").append(ex.toString()).toString());
}
return outStream.toByteArray();
}
public List getCertificates()
{
return new ArrayList(certificates);
}
private DERObject getEncodedX509Certificate(X509Certificate cert)
throws CertificateEncodingException
{
DERInputStream derInStream;
ByteArrayInputStream inStream = new ByteArrayInputStream(cert.getEncoded());
derInStream = new DERInputStream(inStream);
return derInStream.readObject();
IOException ex;
ex;
throw new CertificateEncodingException((new StringBuilder()).append("IOException caught while encoding certificate\n").append(ex.toString()).toString());
}
static
{
List encodings = new ArrayList();
encodings.add("PkiPath");
certPathEncodings = Collections.unmodifiableList(encodings);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -