1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.geronimo.util.asn1.x509;
20
21 import org.apache.geronimo.util.asn1.ASN1EncodableVector;
22 import org.apache.geronimo.util.asn1.ASN1Sequence;
23 import org.apache.geronimo.util.asn1.ASN1Encodable;
24 import org.apache.geronimo.util.asn1.DERObject;
25 import org.apache.geronimo.util.asn1.DERObjectIdentifier;
26 import org.apache.geronimo.util.asn1.DERSequence;
27
28 public class PolicyInformation
29 extends ASN1Encodable
30 {
31 private DERObjectIdentifier policyIdentifier;
32 private ASN1Sequence policyQualifiers;
33
34 public PolicyInformation(
35 ASN1Sequence seq)
36 {
37 policyIdentifier = (DERObjectIdentifier)seq.getObjectAt(0);
38
39 if (seq.size() > 1)
40 {
41 policyQualifiers = (ASN1Sequence)seq.getObjectAt(1);
42 }
43 }
44
45 public PolicyInformation(
46 DERObjectIdentifier policyIdentifier)
47 {
48 this.policyIdentifier = policyIdentifier;
49 }
50
51 public PolicyInformation(
52 DERObjectIdentifier policyIdentifier,
53 ASN1Sequence policyQualifiers)
54 {
55 this.policyIdentifier = policyIdentifier;
56 this.policyQualifiers = policyQualifiers;
57 }
58
59 public static PolicyInformation getInstance(
60 Object obj)
61 {
62 if (obj == null || obj instanceof PolicyInformation)
63 {
64 return (PolicyInformation)obj;
65 }
66
67 return new PolicyInformation(ASN1Sequence.getInstance(obj));
68 }
69
70 public DERObjectIdentifier getPolicyIdentifier()
71 {
72 return policyIdentifier;
73 }
74
75 public ASN1Sequence getPolicyQualifiers()
76 {
77 return policyQualifiers;
78 }
79
80
81
82
83
84
85
86 public DERObject toASN1Object()
87 {
88 ASN1EncodableVector v = new ASN1EncodableVector();
89
90 v.add(policyIdentifier);
91
92 if (policyQualifiers != null)
93 {
94 v.add(policyQualifiers);
95 }
96
97 return new DERSequence(v);
98 }
99 }