001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.geronimo.util.asn1.pkcs; 019 020 import org.apache.geronimo.util.asn1.ASN1Encodable; 021 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 022 import org.apache.geronimo.util.asn1.ASN1Sequence; 023 import org.apache.geronimo.util.asn1.DERBitString; 024 import org.apache.geronimo.util.asn1.DERObject; 025 import org.apache.geronimo.util.asn1.DERSequence; 026 import org.apache.geronimo.util.asn1.x509.AlgorithmIdentifier; 027 028 /** 029 * PKCS10 Certification request object. 030 * <pre> 031 * CertificationRequest ::= SEQUENCE { 032 * certificationRequestInfo CertificationRequestInfo, 033 * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }}, 034 * signature BIT STRING 035 * } 036 * </pre> 037 */ 038 public class CertificationRequest 039 extends ASN1Encodable 040 { 041 protected CertificationRequestInfo reqInfo = null; 042 protected AlgorithmIdentifier sigAlgId = null; 043 protected DERBitString sigBits = null; 044 045 protected CertificationRequest() 046 { 047 } 048 049 public CertificationRequest( 050 CertificationRequestInfo requestInfo, 051 AlgorithmIdentifier algorithm, 052 DERBitString signature) 053 { 054 this.reqInfo = requestInfo; 055 this.sigAlgId = algorithm; 056 this.sigBits = signature; 057 } 058 059 public CertificationRequest( 060 ASN1Sequence seq) 061 { 062 reqInfo = CertificationRequestInfo.getInstance(seq.getObjectAt(0)); 063 sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); 064 sigBits = (DERBitString)seq.getObjectAt(2); 065 } 066 067 public CertificationRequestInfo getCertificationRequestInfo() 068 { 069 return reqInfo; 070 } 071 072 public AlgorithmIdentifier getSignatureAlgorithm() 073 { 074 return sigAlgId; 075 } 076 077 public DERBitString getSignature() 078 { 079 return sigBits; 080 } 081 082 public DERObject toASN1Object() 083 { 084 // Construct the CertificateRequest 085 ASN1EncodableVector v = new ASN1EncodableVector(); 086 087 v.add(reqInfo); 088 v.add(sigAlgId); 089 v.add(sigBits); 090 091 return new DERSequence(v); 092 } 093 }