1b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampackage org.bouncycastle.asn1.x509;
2b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
3b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1EncodableVector;
44c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstromimport org.bouncycastle.asn1.ASN1Object;
54c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstromimport org.bouncycastle.asn1.ASN1Primitive;
6b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1Sequence;
7b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1TaggedObject;
8b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERSequence;
9b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERTaggedObject;
10b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
11b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam/**
12b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * The Holder object.
13c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * <p>
14c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * For an v2 attribute certificate this is:
15c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *
16b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * <pre>
17c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *            Holder ::= SEQUENCE {
18c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                  baseCertificateID   [0] IssuerSerial OPTIONAL,
19c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                           -- the issuer and serial number of
20c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                           -- the holder's Public Key Certificate
21c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                  entityName          [1] GeneralNames OPTIONAL,
22c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                           -- the name of the claimant or role
23c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                  objectDigestInfo    [2] ObjectDigestInfo OPTIONAL
24c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                           -- used to directly authenticate the holder,
25c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *                           -- for example, an executable
26c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *            }
27c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * </pre>
28c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *
29c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * <p>
30c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * For an v1 attribute certificate this is:
31c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *
32c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom * <pre>
33c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *         subject CHOICE {
345db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root *          baseCertificateID [0] EXPLICIT IssuerSerial,
35c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *          -- associated with a Public Key Certificate
365db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root *          subjectName [1] EXPLICIT GeneralNames },
37c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom *          -- associated with a name
38b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * </pre>
39b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */
40b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampublic class Holder
414c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom    extends ASN1Object
42b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam{
434c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom    public static final int V1_CERTIFICATE_HOLDER = 0;
444c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom    public static final int V2_CERTIFICATE_HOLDER = 1;
454c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom
46c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    IssuerSerial baseCertificateID;
47c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
48c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    GeneralNames entityName;
49c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
50c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    ObjectDigestInfo objectDigestInfo;
51b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
524c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom    private int version = V2_CERTIFICATE_HOLDER;
53c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
54c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public static Holder getInstance(Object obj)
55b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
56b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (obj instanceof Holder)
57b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
58b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return (Holder)obj;
59b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
604c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom        else if (obj instanceof ASN1TaggedObject)
61b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
624c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom            return new Holder(ASN1TaggedObject.getInstance(obj));
63b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
644c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom        else if (obj != null)
65c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
664c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom            return new Holder(ASN1Sequence.getInstance(obj));
67c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
68b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
694c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom        return null;
70b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
71b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
72c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
734c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * Constructor for a holder for an V1 attribute certificate.
74c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     *
75c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param tagObj The ASN.1 tagged holder object.
76c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
774c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom    private Holder(ASN1TaggedObject tagObj)
78c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
79c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        switch (tagObj.getTagNo())
80c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
81c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        case 0:
825db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root            baseCertificateID = IssuerSerial.getInstance(tagObj, true);
83c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            break;
84c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        case 1:
855db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root            entityName = GeneralNames.getInstance(tagObj, true);
86c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            break;
87c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        default:
88c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            throw new IllegalArgumentException("unknown tag in Holder");
89c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
90c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        version = 0;
91c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
92c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
93c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
944c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * Constructor for a holder for an V2 attribute certificate.
95c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     *
96c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param seq The ASN.1 sequence.
97c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
984c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom    private Holder(ASN1Sequence seq)
99b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
100b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (seq.size() > 3)
101b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
102b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            throw new IllegalArgumentException("Bad sequence size: "
103c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom                + seq.size());
104b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
105b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
106b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        for (int i = 0; i != seq.size(); i++)
107b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
108c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            ASN1TaggedObject tObj = ASN1TaggedObject.getInstance(seq
109c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom                .getObjectAt(i));
110c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
111b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            switch (tObj.getTagNo())
112b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            {
113b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            case 0:
114b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                baseCertificateID = IssuerSerial.getInstance(tObj, false);
115b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                break;
116b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            case 1:
117b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                entityName = GeneralNames.getInstance(tObj, false);
118b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                break;
119b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            case 2:
120b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                objectDigestInfo = ObjectDigestInfo.getInstance(tObj, false);
121b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                break;
122b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            default:
123b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                throw new IllegalArgumentException("unknown tag in Holder");
124b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            }
125b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
126c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        version = 1;
127b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
128c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
129c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public Holder(IssuerSerial baseCertificateID)
130b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
1314c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom        this(baseCertificateID, V2_CERTIFICATE_HOLDER);
132b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
133c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
134c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
1354c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * Constructs a holder from a IssuerSerial for a V1 or V2 certificate.
1364c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * .
137c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param baseCertificateID The IssuerSerial.
138c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param version The version of the attribute certificate.
139c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
140c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public Holder(IssuerSerial baseCertificateID, int version)
141c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
142c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        this.baseCertificateID = baseCertificateID;
143c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        this.version = version;
144c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
145b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
146c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
1474c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * Returns 1 for V2 attribute certificates or 0 for V1 attribute
148c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * certificates.
149c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @return The version of the attribute certificate.
150c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
151c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public int getVersion()
152c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
153c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        return version;
154c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
155c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
156c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
1574c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * Constructs a holder with an entityName for V2 attribute certificates.
158c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     *
159c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param entityName The entity or subject name.
160c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
161c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public Holder(GeneralNames entityName)
162c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
1634c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom        this(entityName, V2_CERTIFICATE_HOLDER);
164c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
165c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
166c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
1674c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * Constructs a holder with an entityName for V2 attribute certificates or
1684c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * with a subjectName for V1 attribute certificates.
169c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     *
170c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param entityName The entity or subject name.
171c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param version The version of the attribute certificate.
172c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
173c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public Holder(GeneralNames entityName, int version)
174b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
175b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        this.entityName = entityName;
176c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        this.version = version;
177b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
178b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
179c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
180c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * Constructs a holder from an object digest info.
181c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     *
182c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @param objectDigestInfo The object digest info object.
183c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
184c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public Holder(ObjectDigestInfo objectDigestInfo)
185c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
186c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        this.objectDigestInfo = objectDigestInfo;
187c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
188c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
189b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public IssuerSerial getBaseCertificateID()
190b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
191b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return baseCertificateID;
192b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
193c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
194c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    /**
1954c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * Returns the entityName for an V2 attribute certificate or the subjectName
1964c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom     * for an V1 attribute certificate.
197c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     *
198c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     * @return The entityname or subjectname.
199c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom     */
200b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public GeneralNames getEntityName()
201b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
202b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return entityName;
203b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
204c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
205b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public ObjectDigestInfo getObjectDigestInfo()
206b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
207b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return objectDigestInfo;
208b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
209c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
2104c111300c39cb2e27f07fc2ae3b00e23ed4443b2Brian Carlstrom    public ASN1Primitive toASN1Primitive()
211b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
212c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        if (version == 1)
213b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
214c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            ASN1EncodableVector v = new ASN1EncodableVector();
215b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
216c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            if (baseCertificateID != null)
217c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            {
218c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom                v.add(new DERTaggedObject(false, 0, baseCertificateID));
219c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            }
220c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
221c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            if (entityName != null)
222c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            {
223c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom                v.add(new DERTaggedObject(false, 1, entityName));
224c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            }
225c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
226c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            if (objectDigestInfo != null)
227c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            {
228c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom                v.add(new DERTaggedObject(false, 2, objectDigestInfo));
229c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            }
230b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
231c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            return new DERSequence(v);
232c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
233c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        else
234b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
235c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            if (entityName != null)
236c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            {
2375db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root                return new DERTaggedObject(true, 1, entityName);
238c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            }
239c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            else
240c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            {
2415db505e1f6a68c8d5dfdb0fed0b8607dea7bed96Kenny Root                return new DERTaggedObject(true, 0, baseCertificateID);
242c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            }
243b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
244b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
245b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam}
246