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