KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > x509 > AttCertIssuer


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.util.asn1.x509;
19
20 import org.apache.geronimo.util.asn1.ASN1Choice;
21 import org.apache.geronimo.util.asn1.ASN1Encodable;
22 import org.apache.geronimo.util.asn1.ASN1Sequence;
23 import org.apache.geronimo.util.asn1.ASN1TaggedObject;
24 import org.apache.geronimo.util.asn1.DERObject;
25 import org.apache.geronimo.util.asn1.DERTaggedObject;
26
27 public class AttCertIssuer
28     extends ASN1Encodable
29     implements ASN1Choice
30 {
31     ASN1Encodable obj;
32     DERObject choiceObj;
33
34     public static AttCertIssuer getInstance(
35         Object JavaDoc obj)
36     {
37         if (obj instanceof AttCertIssuer)
38         {
39             return (AttCertIssuer)obj;
40         }
41         else if (obj instanceof V2Form)
42         {
43             return new AttCertIssuer(V2Form.getInstance(obj));
44         }
45         else if (obj instanceof GeneralNames)
46         {
47             return new AttCertIssuer((GeneralNames)obj);
48         }
49         else if (obj instanceof ASN1TaggedObject)
50         {
51             return new AttCertIssuer(V2Form.getInstance((ASN1TaggedObject)obj, false));
52         }
53         else if (obj instanceof ASN1Sequence)
54         {
55             return new AttCertIssuer(GeneralNames.getInstance(obj));
56         }
57
58         throw new IllegalArgumentException JavaDoc("unknown object in factory: " + obj.getClass());
59     }
60
61     public static AttCertIssuer getInstance(
62         ASN1TaggedObject obj,
63         boolean explicit)
64     {
65         return getInstance(obj.getObject()); // must be explictly tagged
66
}
67
68     /**
69      * Don't use this one if you are trying to be RFC compliant.
70      *
71      * @param names our GeneralNames structure
72      */

73     public AttCertIssuer(
74         GeneralNames names)
75     {
76         obj = names;
77         choiceObj = obj.getDERObject();
78     }
79
80     public AttCertIssuer(
81         V2Form v2Form)
82     {
83         obj = v2Form;
84         choiceObj = new DERTaggedObject(false, 0, obj);
85     }
86
87     public ASN1Encodable getIssuer()
88     {
89         return obj;
90     }
91
92     /**
93      * Produce an object suitable for an ASN1OutputStream.
94      * <pre>
95      * AttCertIssuer ::= CHOICE {
96      * v1Form GeneralNames, -- MUST NOT be used in this
97      * -- profile
98      * v2Form [0] V2Form -- v2 only
99      * }
100      * </pre>
101      */

102     public DERObject toASN1Object()
103     {
104         return choiceObj;
105     }
106 }
107
Popular Tags