what-the-bank/sources/org/bouncycastle/asn1/cmp/CMPCertificate.java

83 lines
2.8 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.cmp;
import java.io.IOException;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.x509.AttributeCertificate;
import org.bouncycastle.asn1.x509.Certificate;
/* loaded from: classes6.dex */
public class CMPCertificate extends ASN1Object implements ASN1Choice {
private ASN1Object otherCert;
private int otherTagValue;
private Certificate x509v3PKCert;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
return this.otherCert != null ? new DERTaggedObject(true, this.otherTagValue, this.otherCert) : this.x509v3PKCert.toASN1Primitive();
}
public boolean isX509v3PKCert() {
return this.x509v3PKCert != null;
}
public Certificate getX509v3PKCert() {
return this.x509v3PKCert;
}
public AttributeCertificate getX509v2AttrCert() {
return AttributeCertificate.getInstance(this.otherCert);
}
public int getOtherCertTag() {
return this.otherTagValue;
}
public ASN1Object getOtherCert() {
return this.otherCert;
}
public static CMPCertificate getInstance(Object obj) {
if (obj == null || (obj instanceof CMPCertificate)) {
return (CMPCertificate) obj;
}
if (obj instanceof byte[]) {
try {
obj = ASN1Primitive.fromByteArray((byte[]) obj);
} catch (IOException unused) {
throw new IllegalArgumentException("Invalid encoding in CMPCertificate");
}
}
if (obj instanceof ASN1Sequence) {
return new CMPCertificate(Certificate.getInstance(obj));
}
if (obj instanceof ASN1TaggedObject) {
ASN1TaggedObject aSN1TaggedObject = (ASN1TaggedObject) obj;
return new CMPCertificate(aSN1TaggedObject.getTagNo(), aSN1TaggedObject.getObject());
}
StringBuilder sb = new StringBuilder("Invalid object: ");
sb.append(obj.getClass().getName());
throw new IllegalArgumentException(sb.toString());
}
public CMPCertificate(Certificate certificate) {
if (certificate.getVersionNumber() != 3) {
throw new IllegalArgumentException("only version 3 certificates allowed");
}
this.x509v3PKCert = certificate;
}
public CMPCertificate(AttributeCertificate attributeCertificate) {
this(1, attributeCertificate);
}
public CMPCertificate(int i, ASN1Object aSN1Object) {
this.otherTagValue = i;
this.otherCert = aSN1Object;
}
}