KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > pkcs > CertificationRequest


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.pkcs;
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.DERBitString;
24 import org.apache.geronimo.util.asn1.DERObject;
25 import org.apache.geronimo.util.asn1.DERSequence;
26 import org.apache.geronimo.util.asn1.x509.AlgorithmIdentifier;
27
28 /**
29  * PKCS10 Certification request object.
30  * <pre>
31  * CertificationRequest ::= SEQUENCE {
32  * certificationRequestInfo CertificationRequestInfo,
33  * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }},
34  * signature BIT STRING
35  * }
36  * </pre>
37  */

38 public class CertificationRequest
39     extends ASN1Encodable
40 {
41     protected CertificationRequestInfo reqInfo = null;
42     protected AlgorithmIdentifier sigAlgId = null;
43     protected DERBitString sigBits = null;
44
45     protected CertificationRequest()
46     {
47     }
48
49     public CertificationRequest(
50         CertificationRequestInfo requestInfo,
51         AlgorithmIdentifier algorithm,
52         DERBitString signature)
53     {
54         this.reqInfo = requestInfo;
55         this.sigAlgId = algorithm;
56         this.sigBits = signature;
57     }
58
59     public CertificationRequest(
60         ASN1Sequence seq)
61     {
62         reqInfo = CertificationRequestInfo.getInstance(seq.getObjectAt(0));
63         sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
64         sigBits = (DERBitString)seq.getObjectAt(2);
65     }
66
67     public CertificationRequestInfo getCertificationRequestInfo()
68     {
69         return reqInfo;
70     }
71
72     public AlgorithmIdentifier getSignatureAlgorithm()
73     {
74         return sigAlgId;
75     }
76
77     public DERBitString getSignature()
78     {
79         return sigBits;
80     }
81
82     public DERObject toASN1Object()
83     {
84         // Construct the CertificateRequest
85
ASN1EncodableVector v = new ASN1EncodableVector();
86
87         v.add(reqInfo);
88         v.add(sigAlgId);
89         v.add(sigBits);
90
91         return new DERSequence(v);
92     }
93 }
94
Popular Tags