01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.crypto.asn1.x509;
17:
18: import org.apache.geronimo.crypto.asn1.ASN1Choice;
19: import org.apache.geronimo.crypto.asn1.ASN1Encodable;
20: import org.apache.geronimo.crypto.asn1.ASN1Sequence;
21: import org.apache.geronimo.crypto.asn1.ASN1TaggedObject;
22: import org.apache.geronimo.crypto.asn1.DERObject;
23: import org.apache.geronimo.crypto.asn1.DERTaggedObject;
24:
25: public class AttCertIssuer extends ASN1Encodable implements ASN1Choice {
26: ASN1Encodable obj;
27: DERObject choiceObj;
28:
29: public static AttCertIssuer getInstance(Object obj) {
30: if (obj instanceof AttCertIssuer) {
31: return (AttCertIssuer) obj;
32: } else if (obj instanceof V2Form) {
33: return new AttCertIssuer(V2Form.getInstance(obj));
34: } else if (obj instanceof GeneralNames) {
35: return new AttCertIssuer((GeneralNames) obj);
36: } else if (obj instanceof ASN1TaggedObject) {
37: return new AttCertIssuer(V2Form.getInstance(
38: (ASN1TaggedObject) obj, false));
39: } else if (obj instanceof ASN1Sequence) {
40: return new AttCertIssuer(GeneralNames.getInstance(obj));
41: }
42:
43: throw new IllegalArgumentException(
44: "unknown object in factory: " + obj.getClass());
45: }
46:
47: public static AttCertIssuer getInstance(ASN1TaggedObject obj,
48: boolean explicit) {
49: return getInstance(obj.getObject()); // must be explictly tagged
50: }
51:
52: /**
53: * Don't use this one if you are trying to be RFC compliant.
54: *
55: * @param names our GeneralNames structure
56: */
57: public AttCertIssuer(GeneralNames names) {
58: obj = names;
59: choiceObj = obj.getDERObject();
60: }
61:
62: public AttCertIssuer(V2Form v2Form) {
63: obj = v2Form;
64: choiceObj = new DERTaggedObject(false, 0, obj);
65: }
66:
67: public ASN1Encodable getIssuer() {
68: return obj;
69: }
70:
71: /**
72: * Produce an object suitable for an ASN1OutputStream.
73: * <pre>
74: * AttCertIssuer ::= CHOICE {
75: * v1Form GeneralNames, -- MUST NOT be used in this
76: * -- profile
77: * v2Form [0] V2Form -- v2 only
78: * }
79: * </pre>
80: */
81: public DERObject toASN1Object() {
82: return choiceObj;
83: }
84: }
|