001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.geronimo.util.asn1.x509;
019
020 import org.apache.geronimo.util.asn1.ASN1Choice;
021 import org.apache.geronimo.util.asn1.ASN1Encodable;
022 import org.apache.geronimo.util.asn1.ASN1Sequence;
023 import org.apache.geronimo.util.asn1.ASN1TaggedObject;
024 import org.apache.geronimo.util.asn1.DERObject;
025 import org.apache.geronimo.util.asn1.DERTaggedObject;
026
027 public class AttCertIssuer
028 extends ASN1Encodable
029 implements ASN1Choice
030 {
031 ASN1Encodable obj;
032 DERObject choiceObj;
033
034 public static AttCertIssuer getInstance(
035 Object obj)
036 {
037 if (obj instanceof AttCertIssuer)
038 {
039 return (AttCertIssuer)obj;
040 }
041 else if (obj instanceof V2Form)
042 {
043 return new AttCertIssuer(V2Form.getInstance(obj));
044 }
045 else if (obj instanceof GeneralNames)
046 {
047 return new AttCertIssuer((GeneralNames)obj);
048 }
049 else if (obj instanceof ASN1TaggedObject)
050 {
051 return new AttCertIssuer(V2Form.getInstance((ASN1TaggedObject)obj, false));
052 }
053 else if (obj instanceof ASN1Sequence)
054 {
055 return new AttCertIssuer(GeneralNames.getInstance(obj));
056 }
057
058 throw new IllegalArgumentException("unknown object in factory: " + obj.getClass());
059 }
060
061 public static AttCertIssuer getInstance(
062 ASN1TaggedObject obj,
063 boolean explicit)
064 {
065 return getInstance(obj.getObject()); // must be explictly tagged
066 }
067
068 /**
069 * Don't use this one if you are trying to be RFC compliant.
070 *
071 * @param names our GeneralNames structure
072 */
073 public AttCertIssuer(
074 GeneralNames names)
075 {
076 obj = names;
077 choiceObj = obj.getDERObject();
078 }
079
080 public AttCertIssuer(
081 V2Form v2Form)
082 {
083 obj = v2Form;
084 choiceObj = new DERTaggedObject(false, 0, obj);
085 }
086
087 public ASN1Encodable getIssuer()
088 {
089 return obj;
090 }
091
092 /**
093 * Produce an object suitable for an ASN1OutputStream.
094 * <pre>
095 * AttCertIssuer ::= CHOICE {
096 * v1Form GeneralNames, -- MUST NOT be used in this
097 * -- profile
098 * v2Form [0] V2Form -- v2 only
099 * }
100 * </pre>
101 */
102 public DERObject toASN1Object()
103 {
104 return choiceObj;
105 }
106 }