01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.crypto.asn1.x509;
17:
18: import org.apache.geronimo.crypto.asn1.ASN1EncodableVector;
19: import org.apache.geronimo.crypto.asn1.ASN1Sequence;
20: import org.apache.geronimo.crypto.asn1.ASN1Encodable;
21: import org.apache.geronimo.crypto.asn1.DERObject;
22: import org.apache.geronimo.crypto.asn1.DERObjectIdentifier;
23: import org.apache.geronimo.crypto.asn1.DERSequence;
24:
25: public class PolicyInformation extends ASN1Encodable {
26: private DERObjectIdentifier policyIdentifier;
27: private ASN1Sequence policyQualifiers;
28:
29: public PolicyInformation(ASN1Sequence seq) {
30: policyIdentifier = (DERObjectIdentifier) seq.getObjectAt(0);
31:
32: if (seq.size() > 1) {
33: policyQualifiers = (ASN1Sequence) seq.getObjectAt(1);
34: }
35: }
36:
37: public PolicyInformation(DERObjectIdentifier policyIdentifier) {
38: this .policyIdentifier = policyIdentifier;
39: }
40:
41: public PolicyInformation(DERObjectIdentifier policyIdentifier,
42: ASN1Sequence policyQualifiers) {
43: this .policyIdentifier = policyIdentifier;
44: this .policyQualifiers = policyQualifiers;
45: }
46:
47: public static PolicyInformation getInstance(Object obj) {
48: if (obj == null || obj instanceof PolicyInformation) {
49: return (PolicyInformation) obj;
50: }
51:
52: return new PolicyInformation(ASN1Sequence.getInstance(obj));
53: }
54:
55: public DERObjectIdentifier getPolicyIdentifier() {
56: return policyIdentifier;
57: }
58:
59: public ASN1Sequence getPolicyQualifiers() {
60: return policyQualifiers;
61: }
62:
63: /*
64: * PolicyInformation ::= SEQUENCE {
65: * policyIdentifier CertPolicyId,
66: * policyQualifiers SEQUENCE SIZE (1..MAX) OF
67: * PolicyQualifierInfo OPTIONAL }
68: */
69: public DERObject toASN1Object() {
70: ASN1EncodableVector v = new ASN1EncodableVector();
71:
72: v.add(policyIdentifier);
73:
74: if (policyQualifiers != null) {
75: v.add(policyQualifiers);
76: }
77:
78: return new DERSequence(v);
79: }
80: }
|