KickJava   Java API By Example, From Geeks To Geeks.

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


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.ASN1EncodableVector;
22 import org.apache.geronimo.util.asn1.ASN1Sequence;
23 import org.apache.geronimo.util.asn1.DEREncodable;
24 import org.apache.geronimo.util.asn1.DERObject;
25 import org.apache.geronimo.util.asn1.DERIA5String;
26 import org.apache.geronimo.util.asn1.DERObjectIdentifier;
27 import org.apache.geronimo.util.asn1.DERSequence;
28
29 /**
30  * Policy qualifiers, used in the X509V3 CertificatePolicies
31  * extension.
32  *
33  * <pre>
34  * PolicyQualifierInfo ::= SEQUENCE {
35  * policyQualifierId PolicyQualifierId,
36  * qualifier ANY DEFINED BY policyQualifierId }
37  * </pre>
38  */

39 public class PolicyQualifierInfo
40     extends ASN1Encodable
41 {
42    DERObjectIdentifier policyQualifierId;
43    DEREncodable qualifier;
44
45    /**
46     * Creates a new <code>PolicyQualifierInfo</code> instance.
47     *
48     * @param policyQualifierId a <code>PolicyQualifierId</code> value
49     * @param qualifier the qualifier, defined by the above field.
50     */

51    public PolicyQualifierInfo (DERObjectIdentifier policyQualifierId,
52                                DEREncodable qualifier)
53    {
54       this.policyQualifierId = policyQualifierId;
55       this.qualifier = qualifier;
56    }
57
58    /**
59     * Creates a new <code>PolicyQualifierInfo</code> containing a
60     * cPSuri qualifier.
61     *
62     * @param cps the CPS (certification practice statement) uri as a
63     * <code>String</code>.
64     */

65    public PolicyQualifierInfo (String JavaDoc cps)
66    {
67       policyQualifierId = PolicyQualifierId.id_qt_cps;
68       qualifier = new DERIA5String (cps);
69    }
70
71    /**
72     * Creates a new <code>PolicyQualifierInfo</code> instance.
73     *
74     * @param as <code>PolicyQualifierInfo</code> X509 structure
75     * encoded as an ASN1Sequence.
76     */

77    public PolicyQualifierInfo (ASN1Sequence as)
78    {
79         policyQualifierId = (DERObjectIdentifier) as.getObjectAt(0);
80         qualifier = as.getObjectAt(1);
81     }
82
83    public static PolicyQualifierInfo getInstance (Object JavaDoc as)
84    {
85         if (as instanceof PolicyQualifierInfo)
86         {
87             return (PolicyQualifierInfo)as;
88         }
89         else if (as instanceof ASN1Sequence)
90         {
91             return new PolicyQualifierInfo((ASN1Sequence)as);
92         }
93
94         throw new IllegalArgumentException JavaDoc("unknown object in getInstance.");
95    }
96
97    /**
98     * Returns a DER-encodable representation of this instance.
99     *
100     * @return a <code>DERObject</code> value
101     */

102    public DERObject toASN1Object()
103    {
104       ASN1EncodableVector dev = new ASN1EncodableVector();
105       dev.add(policyQualifierId);
106       dev.add(qualifier);
107
108       return new DERSequence(dev);
109    }
110 }
111
Popular Tags