1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.geronimo.util.asn1.x509;
20
21 import org.apache.geronimo.util.asn1.ASN1Choice;
22 import org.apache.geronimo.util.asn1.ASN1Encodable;
23 import org.apache.geronimo.util.asn1.ASN1Sequence;
24 import org.apache.geronimo.util.asn1.ASN1TaggedObject;
25 import org.apache.geronimo.util.asn1.DERObject;
26 import org.apache.geronimo.util.asn1.DERTaggedObject;
27
28 public class AttCertIssuer
29 extends ASN1Encodable
30 implements ASN1Choice
31 {
32 ASN1Encodable obj;
33 DERObject choiceObj;
34
35 public static AttCertIssuer getInstance(
36 Object obj)
37 {
38 if (obj instanceof AttCertIssuer)
39 {
40 return (AttCertIssuer)obj;
41 }
42 else if (obj instanceof V2Form)
43 {
44 return new AttCertIssuer(V2Form.getInstance(obj));
45 }
46 else if (obj instanceof GeneralNames)
47 {
48 return new AttCertIssuer((GeneralNames)obj);
49 }
50 else if (obj instanceof ASN1TaggedObject)
51 {
52 return new AttCertIssuer(V2Form.getInstance((ASN1TaggedObject)obj, false));
53 }
54 else if (obj instanceof ASN1Sequence)
55 {
56 return new AttCertIssuer(GeneralNames.getInstance(obj));
57 }
58
59 throw new IllegalArgumentException("unknown object in factory: " + obj.getClass());
60 }
61
62 public static AttCertIssuer getInstance(
63 ASN1TaggedObject obj,
64 boolean explicit)
65 {
66 return getInstance(obj.getObject());
67 }
68
69 /**
70 * Don't use this one if you are trying to be RFC compliant.
71 *
72 * @param names our GeneralNames structure
73 */
74 public AttCertIssuer(
75 GeneralNames names)
76 {
77 obj = names;
78 choiceObj = obj.getDERObject();
79 }
80
81 public AttCertIssuer(
82 V2Form v2Form)
83 {
84 obj = v2Form;
85 choiceObj = new DERTaggedObject(false, 0, obj);
86 }
87
88 public ASN1Encodable getIssuer()
89 {
90 return obj;
91 }
92
93 /**
94 * Produce an object suitable for an ASN1OutputStream.
95 * <pre>
96 * AttCertIssuer ::= CHOICE {
97 * v1Form GeneralNames, -- MUST NOT be used in this
98 * -- profile
99 * v2Form [0] V2Form -- v2 only
100 * }
101 * </pre>
102 */
103 public DERObject toASN1Object()
104 {
105 return choiceObj;
106 }
107 }