KickJava   Java API By Example, From Geeks To Geeks.

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


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.ASN1EncodableVector;
21 import org.apache.geronimo.util.asn1.ASN1Sequence;
22 import org.apache.geronimo.util.asn1.ASN1Encodable;
23 import org.apache.geronimo.util.asn1.DERObject;
24 import org.apache.geronimo.util.asn1.DERObjectIdentifier;
25 import org.apache.geronimo.util.asn1.DERSequence;
26
27 public class PolicyInformation
28     extends ASN1Encodable
29 {
30     private DERObjectIdentifier policyIdentifier;
31     private ASN1Sequence policyQualifiers;
32
33     public PolicyInformation(
34         ASN1Sequence seq)
35     {
36         policyIdentifier = (DERObjectIdentifier)seq.getObjectAt(0);
37
38         if (seq.size() > 1)
39         {
40             policyQualifiers = (ASN1Sequence)seq.getObjectAt(1);
41         }
42     }
43
44     public PolicyInformation(
45         DERObjectIdentifier policyIdentifier)
46     {
47         this.policyIdentifier = policyIdentifier;
48     }
49
50     public PolicyInformation(
51         DERObjectIdentifier policyIdentifier,
52         ASN1Sequence policyQualifiers)
53     {
54         this.policyIdentifier = policyIdentifier;
55         this.policyQualifiers = policyQualifiers;
56     }
57
58     public static PolicyInformation getInstance(
59         Object JavaDoc obj)
60     {
61         if (obj == null || obj instanceof PolicyInformation)
62         {
63             return (PolicyInformation)obj;
64         }
65
66         return new PolicyInformation(ASN1Sequence.getInstance(obj));
67     }
68
69     public DERObjectIdentifier getPolicyIdentifier()
70     {
71         return policyIdentifier;
72     }
73
74     public ASN1Sequence getPolicyQualifiers()
75     {
76         return policyQualifiers;
77     }
78
79     /*
80      * PolicyInformation ::= SEQUENCE {
81      * policyIdentifier CertPolicyId,
82      * policyQualifiers SEQUENCE SIZE (1..MAX) OF
83      * PolicyQualifierInfo OPTIONAL }
84      */

85     public DERObject toASN1Object()
86     {
87         ASN1EncodableVector v = new ASN1EncodableVector();
88
89         v.add(policyIdentifier);
90
91         if (policyQualifiers != null)
92         {
93             v.add(policyQualifiers);
94         }
95
96         return new DERSequence(v);
97     }
98 }
99
Popular Tags