KickJava   Java API By Example, From Geeks To Geeks.

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


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.ASN1Encodable;
21 import org.apache.geronimo.util.asn1.ASN1Sequence;
22 import org.apache.geronimo.util.asn1.ASN1TaggedObject;
23 import org.apache.geronimo.util.asn1.DERObject;
24 import org.apache.geronimo.util.asn1.DERSequence;
25
26 public class GeneralNames
27     extends ASN1Encodable
28 {
29     ASN1Sequence seq;
30
31     public static GeneralNames getInstance(
32         Object JavaDoc obj)
33     {
34         if (obj == null || obj instanceof GeneralNames)
35         {
36             return (GeneralNames)obj;
37         }
38
39         if (obj instanceof ASN1Sequence)
40         {
41             return new GeneralNames((ASN1Sequence)obj);
42         }
43
44         throw new IllegalArgumentException JavaDoc("illegal object in getInstance: " + obj.getClass().getName());
45     }
46
47     public static GeneralNames getInstance(
48         ASN1TaggedObject obj,
49         boolean explicit)
50     {
51         return getInstance(ASN1Sequence.getInstance(obj, explicit));
52     }
53
54     /**
55      * Construct a GeneralNames object containing one GeneralName.
56      *
57      * @param name the name to be contained.
58      */

59     public GeneralNames(
60         GeneralName name)
61     {
62         this.seq = new DERSequence(name);
63     }
64
65     public GeneralNames(
66         ASN1Sequence seq)
67     {
68         this.seq = seq;
69     }
70
71     public GeneralName[] getNames()
72     {
73         GeneralName[] names = new GeneralName[seq.size()];
74
75         for (int i = 0; i != seq.size(); i++)
76         {
77             names[i] = GeneralName.getInstance(seq.getObjectAt(i));
78         }
79
80         return names;
81     }
82
83     /**
84      * Produce an object suitable for an ASN1OutputStream.
85      * <pre>
86      * GeneralNames ::= SEQUENCE SIZE {1..MAX} OF GeneralName
87      * </pre>
88      */

89     public DERObject toASN1Object()
90     {
91         return seq;
92     }
93 }
94
Popular Tags