import java.util.LinkedList;
import java.util.List;
-public class X509CertificateFactory extends CertificateFactorySpi
+public class X509CertificateFactory
+ extends CertificateFactorySpi
{
-
- // Constants.
- // ------------------------------------------------------------------------
-
public static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----";
+
public static final String END_CERTIFICATE = "-----END CERTIFICATE-----";
+
public static final String BEGIN_X509_CRL = "-----BEGIN X509 CRL-----";
- public static final String END_X509_CRL = "-----END X509 CRL-----";
- // Constructors.
- // ------------------------------------------------------------------------
+ public static final String END_X509_CRL = "-----END X509 CRL-----";
public X509CertificateFactory()
{
super();
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public Certificate engineGenerateCertificate(InputStream inStream)
- throws CertificateException
+ throws CertificateException
{
try
{
catch (IOException ioe)
{
CertificateException ce = new CertificateException(ioe.getMessage());
- ce.initCause (ioe);
+ ce.initCause(ioe);
throw ce;
}
}
public Collection engineGenerateCertificates(InputStream inStream)
- throws CertificateException
+ throws CertificateException
{
LinkedList certs = new LinkedList();
while (true)
catch (IOException ioe)
{
CertificateException ce = new CertificateException(ioe.getMessage());
- ce.initCause (ioe);
+ ce.initCause(ioe);
throw ce;
}
}
catch (IOException ioe)
{
CRLException crle = new CRLException(ioe.getMessage());
- crle.initCause (ioe);
+ crle.initCause(ioe);
throw crle;
}
}
public Collection engineGenerateCRLs(InputStream inStream)
- throws CRLException
+ throws CRLException
{
LinkedList crls = new LinkedList();
while (true)
catch (IOException ioe)
{
CRLException crle = new CRLException(ioe.getMessage());
- crle.initCause (ioe);
+ crle.initCause(ioe);
throw crle;
}
}
}
public CertPath engineGenerateCertPath(InputStream in)
- throws CertificateEncodingException
+ throws CertificateEncodingException
{
return new X509CertPath(in);
}
public CertPath engineGenerateCertPath(InputStream in, String encoding)
- throws CertificateEncodingException
+ throws CertificateEncodingException
{
return new X509CertPath(in, encoding);
}
return X509CertPath.ENCODINGS.iterator();
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private X509Certificate generateCert(InputStream inStream)
- throws IOException, CertificateException
+ throws IOException, CertificateException
{
if (inStream == null)
throw new CertificateException("missing input stream");
- if (!inStream.markSupported())
+ if (! inStream.markSupported())
inStream = new BufferedInputStream(inStream, 8192);
inStream.mark(20);
int i = inStream.read();
if (i == -1)
throw new EOFException();
-
// If the input is in binary DER format, the first byte MUST be
// 0x30, which stands for the ASN.1 [UNIVERSAL 16], which is the
// UNIVERSAL SEQUENCE, with the CONSTRUCTED bit (0x20) set.
}
while (i != '\n' && i != '\r');
}
- while (!line.toString().equals(BEGIN_CERTIFICATE));
+ while (! line.toString().equals(BEGIN_CERTIFICATE));
X509Certificate ret = new X509Certificate(
- new BufferedInputStream(new Base64InputStream(inStream), 8192));
+ new BufferedInputStream(new Base64InputStream(inStream), 8192));
line.setLength(0);
line.append('-'); // Base64InputStream will eat this.
do
}
while (i != '\n' && i != '\r');
// XXX ???
- if (!line.toString().equals(END_CERTIFICATE))
+ if (! line.toString().equals(END_CERTIFICATE))
throw new CertificateException("no end-of-certificate marker");
return ret;
}
}
}
- private X509CRL generateCRL(InputStream inStream)
- throws IOException, CRLException
+ private X509CRL generateCRL(InputStream inStream) throws IOException,
+ CRLException
{
if (inStream == null)
throw new CRLException("missing input stream");
- if (!inStream.markSupported())
+ if (! inStream.markSupported())
inStream = new BufferedInputStream(inStream, 8192);
inStream.mark(20);
int i = inStream.read();
if (i == -1)
throw new EOFException();
-
// If the input is in binary DER format, the first byte MUST be
// 0x30, which stands for the ASN.1 [UNIVERSAL 16], which is the
// UNIVERSAL SEQUENCE, with the CONSTRUCTED bit (0x20) set.
}
while (i != '\n' && i != '\r');
}
- while (!line.toString().startsWith(BEGIN_X509_CRL));
+ while (! line.toString().startsWith(BEGIN_X509_CRL));
X509CRL ret = new X509CRL(
- new BufferedInputStream(new Base64InputStream(inStream), 8192));
+ new BufferedInputStream(new Base64InputStream(inStream), 8192));
line.setLength(0);
line.append('-'); // Base64InputStream will eat this.
do
}
while (i != '\n' && i != '\r');
// XXX ???
- if (!line.toString().startsWith(END_X509_CRL))
+ if (! line.toString().startsWith(END_X509_CRL))
throw new CRLException("no end-of-CRL marker");
return ret;
}