FileDocCategorySizeDatePackage
PrincipalUtil.javaAPI DocAzureus 3.0.3.42364Tue Jun 08 05:13:00 BST 2004org.bouncycastle.jce

PrincipalUtil

public class PrincipalUtil extends Object
a utility class that will extract X509Principal objects from X.509 certificates.

Fields Summary
Constructors Summary
Methods Summary
public static X509PrincipalgetIssuerX509Principal(java.security.cert.X509Certificate cert)
return the issuer of the given cert as an X509PrincipalObject.

        try
        {
            ByteArrayInputStream    bIn = new ByteArrayInputStream(
                cert.getTBSCertificate());
            ASN1InputStream         aIn = new ASN1InputStream(bIn);
            TBSCertificateStructure tbsCert = new TBSCertificateStructure(
                                            (ASN1Sequence)aIn.readObject());

            return new X509Principal(tbsCert.getIssuer());
        }
        catch (IOException e)
        {
            throw new CertificateEncodingException(e.toString());
        }
    
public static X509PrincipalgetIssuerX509Principal(java.security.cert.X509CRL crl)
return the issuer of the given CRL as an X509PrincipalObject.

		try
		{
			ByteArrayInputStream    bIn = new ByteArrayInputStream(
				crl.getTBSCertList());
			ASN1InputStream         aIn = new ASN1InputStream(bIn);
			TBSCertList tbsCertList = new TBSCertList(
											(ASN1Sequence)aIn.readObject());

			return new X509Principal(tbsCertList.getIssuer());
		}
		catch (IOException e)
		{
			throw new CRLException(e.toString());
		}
	
public static X509PrincipalgetSubjectX509Principal(java.security.cert.X509Certificate cert)
return the subject of the given cert as an X509PrincipalObject.

        try
        {
            ByteArrayInputStream    bIn = new ByteArrayInputStream(
                cert.getTBSCertificate());
            ASN1InputStream         aIn = new ASN1InputStream(bIn);
            TBSCertificateStructure tbsCert = new TBSCertificateStructure(
                                            (ASN1Sequence)aIn.readObject());

            return new X509Principal(tbsCert.getSubject());
        }
        catch (IOException e)
        {
            throw new CertificateEncodingException(e.toString());
        }