KickJava   Java API By Example, From Geeks To Geeks.

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


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.ASN1Set;
23 import org.apache.geronimo.util.asn1.ASN1TaggedObject;
24 import org.apache.geronimo.util.asn1.DEREncodable;
25 import org.apache.geronimo.util.asn1.DERObject;
26 import org.apache.geronimo.util.asn1.DERTaggedObject;
27
28 /**
29  * The DistributionPointName object.
30  * <pre>
31  * DistributionPointName ::= CHOICE {
32  * fullName [0] GeneralNames,
33  * nameRelativeToCRLIssuer [1] RelativeDistinguishedName
34  * }
35  * </pre>
36  */

37 public class DistributionPointName
38     extends ASN1Encodable
39     implements ASN1Choice
40 {
41     DEREncodable name;
42     int type;
43
44     public static final int FULL_NAME = 0;
45     public static final int NAME_RELATIVE_TO_CRL_ISSUER = 1;
46
47     public static DistributionPointName getInstance(
48         ASN1TaggedObject obj,
49         boolean explicit)
50     {
51         return getInstance(ASN1TaggedObject.getInstance(obj, true));
52     }
53
54     public static DistributionPointName getInstance(
55         Object JavaDoc obj)
56     {
57         if (obj == null || obj instanceof DistributionPointName)
58         {
59             return (DistributionPointName)obj;
60         }
61         else if (obj instanceof ASN1TaggedObject)
62         {
63             return new DistributionPointName((ASN1TaggedObject)obj);
64         }
65
66         throw new IllegalArgumentException JavaDoc("unknown object in factory");
67     }
68
69     /*
70      * @deprecated use ASN1Encodable
71      */

72     public DistributionPointName(
73         int type,
74         DEREncodable name)
75     {
76         this.type = type;
77         this.name = name;
78     }
79
80     public DistributionPointName(
81         int type,
82         ASN1Encodable name)
83     {
84         this.type = type;
85         this.name = name;
86     }
87
88     /**
89      * Return the tag number applying to the underlying choice.
90      *
91      * @return the tag number for this point name.
92      */

93     public int getType()
94     {
95         return this.type;
96     }
97
98     /**
99      * Return the tagged object inside the distribution point name.
100      *
101      * @return the underlying choice item.
102      */

103     public ASN1Encodable getName()
104     {
105         return (ASN1Encodable)name;
106     }
107
108     public DistributionPointName(
109         ASN1TaggedObject obj)
110     {
111         this.type = obj.getTagNo();
112
113         if (type == 0)
114         {
115             this.name = GeneralNames.getInstance(obj, false);
116         }
117         else
118         {
119             this.name = ASN1Set.getInstance(obj, false);
120         }
121     }
122
123     public DERObject toASN1Object()
124     {
125         return new DERTaggedObject(false, type, name);
126     }
127 }
128
Popular Tags