Rewrite issuer/subject getters
package org.bouncycastle.jcajce.provider.asymmetric.x509;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.net.InetAddress;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
-import org.bouncycastle.asn1.ASN1OutputStream;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1String;
@@ -114,26 +112,16 @@ public BigInteger getSerialNumber()
public Principal getIssuerDN()
{
- try
- {
- return new X509Principal(X500Name.getInstance(c.getIssuer().getEncoded()));
- }
- catch (IOException e)
- {
- return null;
- }
+ return new X509Principal(c.getIssuer());
}
public X500Principal getIssuerX500Principal()
{
try
{
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- ASN1OutputStream aOut = new ASN1OutputStream(bOut);
+ byte[] encoding = c.getIssuer().getEncoded(ASN1Encoding.DER);
- aOut.writeObject(c.getIssuer());
-
- return new X500Principal(bOut.toByteArray());
+ return new X500Principal(encoding);
}
catch (IOException e)
{
@@ -143,19 +131,16 @@ public X500Principal getIssuerX500Principal()
public Principal getSubjectDN()
{
- return new X509Principal(X500Name.getInstance(c.getSubject().toASN1Primitive()));
+ return new X509Principal(c.getSubject());
}
public X500Principal getSubjectX500Principal()
{
try
{
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- ASN1OutputStream aOut = new ASN1OutputStream(bOut);
-
- aOut.writeObject(c.getSubject());
+ byte[] encoding = c.getSubject().getEncoded(ASN1Encoding.DER);
- return new X500Principal(bOut.toByteArray());
+ return new X500Principal(encoding);
}
catch (IOException e)
{
