FileDocCategorySizeDatePackage
X509CRLEntryObject.javaAPI DocAndroid 1.5 API6771Wed May 06 22:41:06 BST 2009org.bouncycastle.jce.provider

X509CRLEntryObject

public class X509CRLEntryObject extends X509CRLEntry
The following extensions are listed in RFC 2459 as relevant to CRL Entries ReasonCode Hode Instruction Code Invalidity Date Certificate Issuer (critical)

Fields Summary
private TBSCertList.CRLEntry
c
private boolean
isIndirect
private X500Principal
previousCertificateIssuer
Constructors Summary
public X509CRLEntryObject(TBSCertList.CRLEntry c)


      
    
        this.c = c;
    
public X509CRLEntryObject(TBSCertList.CRLEntry c, boolean isIndirect, X500Principal previousCertificateIssuer)
Constructor for CRLEntries of indirect CRLs. If isIndirect is false {@link #getCertificateIssuer()} will always return null, previousCertificateIssuer is ignored. If this isIndirect is specified and this CRLEntry has no certificate issuer CRL entry extension previousCertificateIssuer is returned by {@link #getCertificateIssuer()}.

param
c TBSCertList.CRLEntry object.
param
isIndirect true if the corresponding CRL is a indirect CRL.
param
previousCertificateIssuer Certificate issuer of the previous CRLEntry.

        this.c = c;
        this.isIndirect = isIndirect;
        this.previousCertificateIssuer = previousCertificateIssuer;
    
Methods Summary
public javax.security.auth.x500.X500PrincipalgetCertificateIssuer()

        if (!isIndirect)
        {
            return null;
        }

        byte[] ext = getExtensionValue(X509Extensions.CertificateIssuer.getId());
        if (ext == null)
        {
            return previousCertificateIssuer;
        }

        try
        {
            GeneralName[] names = GeneralNames.getInstance(
                    X509ExtensionUtil.fromExtensionValue(ext)).getNames();
            for (int i = 0; i < names.length; i++)
            {
                if (names[i].getTagNo() == GeneralName.directoryName)
                {
                    return new X500Principal(names[i].getName().getDERObject().getDEREncoded());
                }
            }
            throw new RuntimeException(
                    "Cannot extract directory name from certificate issuer CRL entry extension");
        }
        catch (IOException e)
        {
            throw new RuntimeException(
                    "Cannot extract certificate issuer CRL entry extension "
                            + e);
        }
    
public java.util.SetgetCriticalExtensionOIDs()

        return getExtensionOIDs(true);
    
public byte[]getEncoded()

        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        DEROutputStream dOut = new DEROutputStream(bOut);

        try
        {
            dOut.writeObject(c);

            return bOut.toByteArray();
        }
        catch (IOException e)
        {
            throw new CRLException(e.toString());
        }
    
private java.util.SetgetExtensionOIDs(boolean critical)

        X509Extensions extensions = c.getExtensions();

        if (extensions != null)
        {
            Set set = new HashSet();
            Enumeration e = extensions.oids();

            while (e.hasMoreElements())
            {
                DERObjectIdentifier oid = (DERObjectIdentifier) e.nextElement();
                X509Extension ext = extensions.getExtension(oid);

                if (critical == ext.isCritical())
                {
                    set.add(oid.getId());
                }
            }

            return set;
        }

        return null;
    
public byte[]getExtensionValue(java.lang.String oid)

        X509Extensions exts = c.getExtensions();

        if (exts != null)
        {
            X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));

            if (ext != null)
            {
                try
                {
                    return ext.getValue().getEncoded();
                }
                catch (Exception e)
                {
                    throw new RuntimeException("error encoding " + e.toString());
                }
            }
        }

        return null;
    
public java.util.SetgetNonCriticalExtensionOIDs()

        return getExtensionOIDs(false);
    
public java.util.DategetRevocationDate()

        return c.getRevocationDate().getDate();
    
public java.math.BigIntegergetSerialNumber()

        return c.getUserCertificate().getValue();
    
public booleanhasExtensions()

        return c.getExtensions() != null;
    
public booleanhasUnsupportedCriticalExtension()
Will return true if any extensions are present and marked as critical as we currently dont handle any extensions!

        Set extns = getCriticalExtensionOIDs();
        if (extns != null && !extns.isEmpty())
        {
            return true;
        }

        return false;
    
public java.lang.StringtoString()

        StringBuffer buf = new StringBuffer();
        String nl = System.getProperty("line.separator");

        buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
        buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);

        X509Extensions extensions = c.getExtensions();

        if (extensions != null)
        {
            Enumeration e = extensions.oids();
            if (e.hasMoreElements())
            {
                buf.append("   crlEntryExtensions:").append(nl);

                while (e.hasMoreElements())
                {
                    DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
                    X509Extension ext = extensions.getExtension(oid);
                    buf.append(ext);
                }
            }
        }

        return buf.toString();