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

org.bouncycastle.oer.its.CertificateBase Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls. This jar contains APIs for JDK 1.5 and up.

The newest version!
package org.bouncycastle.oer.its;

import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.oer.OEROptional;

/**
 * 
 *     CertificateBase ::= SEQUENCE {
 *         version Uint8(3),
 *         type CertificateType,
 *         issuer IssuerIdentifier,
 *         toBeSigned ToBeSignedCertificate,
 *         signature Signature OPTIONAL
 *     }
 * 
*/ public class CertificateBase extends ASN1Object { private final ASN1Integer version; private final CertificateType type; private final IssuerIdentifier issuer; private final ToBeSignedCertificate toBeSignedCertificate; private final Signature signature; public CertificateBase(ASN1Integer version, CertificateType type, IssuerIdentifier issuer, ToBeSignedCertificate toBeSignedCertificate, Signature signature) { this.version = version; this.type = type; this.issuer = issuer; this.toBeSignedCertificate = toBeSignedCertificate; this.signature = signature; } public static CertificateBase getInstance(Object o) { if (o instanceof CertificateBase) { return (CertificateBase)o; } ASN1Sequence seq = ASN1Sequence.getInstance(o); ASN1Integer version = ASN1Integer.getInstance(seq.getObjectAt(0)); CertificateType type = CertificateType.getInstance(seq.getObjectAt(1)); IssuerIdentifier issuerIdentifier = IssuerIdentifier.getInstance(seq.getObjectAt(2)); ToBeSignedCertificate cert = ToBeSignedCertificate.getInstance(seq.getObjectAt(3)); Signature signature = OEROptional.getValue(Signature.class, seq.getObjectAt(4)); return new Builder() .setVersion(version) .setType(type) .setIssuer(issuerIdentifier) .setToBeSignedCertificate(cert) .setSignature(signature) .createCertificateBase(); } public static Builder builder() { return new Builder(); } public ASN1Integer getVersion() { return version; } public CertificateType getType() { return type; } public IssuerIdentifier getIssuer() { return issuer; } public ToBeSignedCertificate getToBeSignedCertificate() { return toBeSignedCertificate; } public Signature getSignature() { return signature; } public ASN1Primitive toASN1Primitive() { /* * version Uint8(3), * type CertificateType, * issuer IssuerIdentifier, * toBeSigned ToBeSignedCertificate, * signature Signature OPTIONAL */ return Utils.toSequence( version, type, issuer, toBeSignedCertificate, OEROptional.getInstance(signature)); } public static class Builder { private ASN1Integer version; private CertificateType type; private IssuerIdentifier issuer; private ToBeSignedCertificate toBeSignedCertificate; private Signature signature; public Builder setVersion(ASN1Integer version) { this.version = version; return this; } public Builder setType(CertificateType type) { this.type = type; return this; } public Builder setIssuer(IssuerIdentifier issuer) { this.issuer = issuer; return this; } public Builder setToBeSignedCertificate(ToBeSignedCertificate toBeSignedCertificate) { this.toBeSignedCertificate = toBeSignedCertificate; return this; } public Builder setSignature(Signature signature) { this.signature = signature; return this; } public CertificateBase createCertificateBase() { return new CertificateBase(version, type, issuer, toBeSignedCertificate, signature); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy