Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1.x509;
  
  import java.util.Vector;
  

Deprecated:
use Extensions
 
 public class X509Extensions
     extends ASN1Object
 {
    
Subject Directory Attributes

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier SubjectDirectoryAttributes = new ASN1ObjectIdentifier("2.5.29.9");
    
    
Subject Key Identifier

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier SubjectKeyIdentifier = new ASN1ObjectIdentifier("2.5.29.14");

    
Key Usage

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier KeyUsage = new ASN1ObjectIdentifier("2.5.29.15");

    
Private Key Usage Period

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier PrivateKeyUsagePeriod = new ASN1ObjectIdentifier("2.5.29.16");

    
Subject Alternative Name

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier SubjectAlternativeName = new ASN1ObjectIdentifier("2.5.29.17");

    
Issuer Alternative Name

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier IssuerAlternativeName = new ASN1ObjectIdentifier("2.5.29.18");

    
Basic Constraints

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier BasicConstraints = new ASN1ObjectIdentifier("2.5.29.19");

    
CRL Number

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier CRLNumber = new ASN1ObjectIdentifier("2.5.29.20");

    
Reason code

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier ReasonCode = new ASN1ObjectIdentifier("2.5.29.21");

    
Hold Instruction Code

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier InstructionCode = new ASN1ObjectIdentifier("2.5.29.23");

    
Invalidity Date

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier InvalidityDate = new ASN1ObjectIdentifier("2.5.29.24");

    
Delta CRL indicator

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier DeltaCRLIndicator = new ASN1ObjectIdentifier("2.5.29.27");

    
Issuing Distribution Point

Deprecated:
use X509Extension value.
 
     public static final ASN1ObjectIdentifier IssuingDistributionPoint = new ASN1ObjectIdentifier("2.5.29.28");

    
Certificate Issuer

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier CertificateIssuer = new ASN1ObjectIdentifier("2.5.29.29");

    
Name Constraints

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier NameConstraints = new ASN1ObjectIdentifier("2.5.29.30");

    
CRL Distribution Points

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier CRLDistributionPoints = new ASN1ObjectIdentifier("2.5.29.31");

    
Certificate Policies

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier CertificatePolicies = new ASN1ObjectIdentifier("2.5.29.32");

    
Policy Mappings

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier PolicyMappings = new ASN1ObjectIdentifier("2.5.29.33");

    
Authority Key Identifier

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier AuthorityKeyIdentifier = new ASN1ObjectIdentifier("2.5.29.35");

    
Policy Constraints

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier PolicyConstraints = new ASN1ObjectIdentifier("2.5.29.36");

    
Extended Key Usage

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier ExtendedKeyUsage = new ASN1ObjectIdentifier("2.5.29.37");

    
Freshest CRL

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier FreshestCRL = new ASN1ObjectIdentifier("2.5.29.46");
     
    
Inhibit Any Policy

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier InhibitAnyPolicy = new ASN1ObjectIdentifier("2.5.29.54");

    
Authority Info Access

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier AuthorityInfoAccess = new ASN1ObjectIdentifier("1.3.6.1.5.5.7.1.1");

    
Subject Info Access

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier SubjectInfoAccess = new ASN1ObjectIdentifier("1.3.6.1.5.5.7.1.11");
    
    
Logo Type

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier LogoType = new ASN1ObjectIdentifier("1.3.6.1.5.5.7.1.12");

    
BiometricInfo

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier BiometricInfo = new ASN1ObjectIdentifier("1.3.6.1.5.5.7.1.2");
    
    
QCStatements

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier QCStatements = new ASN1ObjectIdentifier("1.3.6.1.5.5.7.1.3");

    
Audit identity extension in attribute certificates.

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier AuditIdentity = new ASN1ObjectIdentifier("1.3.6.1.5.5.7.1.4");
    
    
NoRevAvail extension in attribute certificates.

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier NoRevAvail = new ASN1ObjectIdentifier("2.5.29.56");

    
TargetInformation extension in attribute certificates.

Deprecated:
use X509Extension value.
    public static final ASN1ObjectIdentifier TargetInformation = new ASN1ObjectIdentifier("2.5.29.55");
    
    private Hashtable               extensions = new Hashtable();
    private Vector                  ordering = new Vector();
    public static X509Extensions getInstance(
        ASN1TaggedObject obj,
        boolean          explicit)
    {
        return getInstance(ASN1Sequence.getInstance(objexplicit));
    }
    public static X509Extensions getInstance(
        Object  obj)
    {
        if (obj == null || obj instanceof X509Extensions)
        {
            return (X509Extensions)obj;
        }
        if (obj instanceof ASN1Sequence)
        {
            return new X509Extensions((ASN1Sequence)obj);
        }
        if (obj instanceof Extensions)
        {
            return new X509Extensions((ASN1Sequence)((Extensions)obj).toASN1Primitive());
        }
        if (obj instanceof ASN1TaggedObject)
        {
            return getInstance(((ASN1TaggedObject)obj).getObject());
        }
        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
    }

    
Constructor from ASN1Sequence. the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID, Boolean, OctetString)
    public X509Extensions(
        ASN1Sequence  seq)
    {
        Enumeration e = seq.getObjects();
        while (e.hasMoreElements())
        {
            ASN1Sequence            s = ASN1Sequence.getInstance(e.nextElement());
            if (s.size() == 3)
            {
                .put(s.getObjectAt(0), new X509Extension(ASN1Boolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2))));
            }
            else if (s.size() == 2)
            {
                .put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))));
            }
            else
            {
                throw new IllegalArgumentException("Bad sequence size: " + s.size());
            }
            .addElement(s.getObjectAt(0));
        }
    }

    
constructor from a table of extensions.

it's is assumed the table contains OID/String pairs.

    public X509Extensions(
        Hashtable  extensions)
    {
        this(nullextensions);
    }

    
Constructor from a table of extensions with ordering.

It's is assumed the table contains OID/String pairs.

Deprecated:
use Extensions
    public X509Extensions(
        Vector      ordering,
        Hashtable   extensions)
    {
        Enumeration e;
        if (ordering == null)
        {
            e = extensions.keys();
        }
        else
        {
            e = ordering.elements();
        }
        while (e.hasMoreElements())
        {
            this..addElement(ASN1ObjectIdentifier.getInstance(e.nextElement()));
        }
        e = this..elements();
        while (e.hasMoreElements())
        {
            ASN1ObjectIdentifier     oid = ASN1ObjectIdentifier.getInstance(e.nextElement());
            X509Extension           ext = (X509Extension)extensions.get(oid);
            this..put(oidext);
        }
    }

    
Constructor from two vectors

Deprecated:
use Extensions
Parameters:
objectIDs a vector of the object identifiers.
values a vector of the extension values.
    public X509Extensions(
        Vector      objectIDs,
        Vector      values)
    {
        Enumeration e = objectIDs.elements();
        while (e.hasMoreElements())
        {
            this..addElement(e.nextElement()); 
        }
        int count = 0;
        
        e = this..elements();
        while (e.hasMoreElements())
        {
            ASN1ObjectIdentifier     oid = (ASN1ObjectIdentifier)e.nextElement();
            X509Extension           ext = (X509Extension)values.elementAt(count);
            this..put(oidext);
            count++;
        }
    }
    
    
return an Enumeration of the extension field's object ids.
    public Enumeration oids()
    {
        return .elements();
    }

    
return the extension represented by the object identifier passed in.

Returns:
the extension if it's present, null otherwise.
    public X509Extension getExtension(
        ASN1ObjectIdentifier oid)
    {
        return (X509Extension).get(oid);
    }

    
     Extensions        ::=   SEQUENCE SIZE (1..MAX) OF Extension

     Extension         ::=   SEQUENCE {
        extnId            EXTENSION.&id ({ExtensionSet}),
        critical          BOOLEAN DEFAULT FALSE,
        extnValue         OCTET STRING }
 
    {
        ASN1EncodableVector     vec = new ASN1EncodableVector();
        Enumeration             e = .elements();
        while (e.hasMoreElements())
        {
            ASN1ObjectIdentifier    oid = (ASN1ObjectIdentifier)e.nextElement();
            X509Extension           ext = (X509Extension).get(oid);
            ASN1EncodableVector     v = new ASN1EncodableVector();
            v.add(oid);
            if (ext.isCritical())
            {
                v.add(.);
            }
            v.add(ext.getValue());
            vec.add(new DERSequence(v));
        }
        return new DERSequence(vec);
    }
    public boolean equivalent(
        X509Extensions other)
    {
        if (.size() != other.extensions.size())
        {
            return false;
        }
        Enumeration     e1 = .keys();
        while (e1.hasMoreElements())
        {
            Object  key = e1.nextElement();
            if (!.get(key).equals(other.extensions.get(key)))
            {
                return false;
            }
        }
        return true;
    }
    {
        return toOidArray();
    }
    
    {
        return getExtensionOIDs(false);
    }
    {
        return getExtensionOIDs(true);
    }
    private ASN1ObjectIdentifier[] getExtensionOIDs(boolean isCritical)
    {
        Vector oidVec = new Vector();
        for (int i = 0; i != .size(); i++)
        {
            Object oid = .elementAt(i);
            if (((X509Extension).get(oid)).isCritical() == isCritical)
            {
                oidVec.addElement(oid);
            }
        }
        return toOidArray(oidVec);
    }
    private ASN1ObjectIdentifier[] toOidArray(Vector oidVec)
    {
        ASN1ObjectIdentifier[] oids = new ASN1ObjectIdentifier[oidVec.size()];
        for (int i = 0; i != oids.lengthi++)
        {
            oids[i] = (ASN1ObjectIdentifier)oidVec.elementAt(i);
        }
        return oids;
    }
New to GrepCode? Check out our FAQ X