All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.x509.V1TBSCertificateGenerator Maven / Gradle / Ivy

Go to download

The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.

There is a newer version: 2.0.0
Show newest version
/***************************************************************/
/******    DO NOT EDIT THIS CLASS bc-java SOURCE FILE     ******/
/***************************************************************/
package org.bouncycastle.asn1.x509;

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1UTCTime;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x500.X500Name;

/**
 * Generator for Version 1 TBSCertificateStructures.
 * 
 * TBSCertificate ::= SEQUENCE {
 *      version          [ 0 ]  Version DEFAULT v1(0),
 *      serialNumber            CertificateSerialNumber,
 *      signature               AlgorithmIdentifier,
 *      issuer                  Name,
 *      validity                Validity,
 *      subject                 Name,
 *      subjectPublicKeyInfo    SubjectPublicKeyInfo,
 *      }
 * 
* */ public class V1TBSCertificateGenerator { ASN1Integer serialNumber; AlgorithmIdentifier signature; X500Name issuer; Time startDate, endDate; X500Name subject; SubjectPublicKeyInfo subjectPublicKeyInfo; public V1TBSCertificateGenerator() { } public void setSerialNumber( ASN1Integer serialNumber) { this.serialNumber = serialNumber; } public void setSignature( AlgorithmIdentifier signature) { this.signature = signature; } public void setIssuer( X500Name issuer) { this.issuer = issuer; } public void setStartDate( Time startDate) { this.startDate = startDate; } public void setStartDate( ASN1UTCTime startDate) { this.startDate = new Time(startDate); } public void setEndDate( Time endDate) { this.endDate = endDate; } public void setEndDate( ASN1UTCTime endDate) { this.endDate = new Time(endDate); } public void setSubject( X500Name subject) { this.subject = subject; } public void setSubjectPublicKeyInfo( SubjectPublicKeyInfo pubKeyInfo) { this.subjectPublicKeyInfo = pubKeyInfo; } public TBSCertificate generateTBSCertificate() { if ((serialNumber == null) || (signature == null) || (issuer == null) || (startDate == null) || (endDate == null) || (subject == null) || (subjectPublicKeyInfo == null)) { throw new IllegalStateException("not all mandatory fields set in V1 TBScertificate generator"); } ASN1EncodableVector seq = new ASN1EncodableVector(); // seq.add(version); - not required as default value. seq.add(serialNumber); seq.add(signature); seq.add(issuer); // // before and after dates // ASN1EncodableVector validity = new ASN1EncodableVector(); validity.add(startDate); validity.add(endDate); seq.add(new DERSequence(validity)); seq.add(subject); seq.add(subjectPublicKeyInfo); return TBSCertificate.getInstance(new DERSequence(seq)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy