what-the-bank/sources/org/bouncycastle/asn1/isismtt/ocsp/RequestedCertificate.java

90 lines
3.5 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.isismtt.ocsp;
import java.io.IOException;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.x509.Certificate;
/* loaded from: classes6.dex */
public class RequestedCertificate extends ASN1Object implements ASN1Choice {
public static final int attributeCertificate = 1;
public static final int certificate = -1;
public static final int publicKeyCertificate = 0;
private byte[] attributeCert;
private Certificate cert;
private byte[] publicKeyCert;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
return this.publicKeyCert != null ? new DERTaggedObject(0, new DEROctetString(this.publicKeyCert)) : this.attributeCert != null ? new DERTaggedObject(1, new DEROctetString(this.attributeCert)) : this.cert.toASN1Primitive();
}
public int getType() {
if (this.cert != null) {
return -1;
}
return this.publicKeyCert != null ? 0 : 1;
}
public byte[] getCertificateBytes() {
Certificate certificate2 = this.cert;
if (certificate2 == null) {
byte[] bArr = this.publicKeyCert;
return bArr != null ? bArr : this.attributeCert;
}
try {
return certificate2.getEncoded();
} catch (IOException e) {
throw new IllegalStateException("can't decode certificate: ".concat(String.valueOf(e)));
}
}
public static RequestedCertificate getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) {
if (z) {
return getInstance(aSN1TaggedObject.getObject());
}
throw new IllegalArgumentException("choice item must be explicitly tagged");
}
public static RequestedCertificate getInstance(Object obj) {
if (obj == null || (obj instanceof RequestedCertificate)) {
return (RequestedCertificate) obj;
}
if (obj instanceof ASN1Sequence) {
return new RequestedCertificate(Certificate.getInstance(obj));
}
if (obj instanceof ASN1TaggedObject) {
return new RequestedCertificate((ASN1TaggedObject) obj);
}
StringBuilder sb = new StringBuilder("illegal object in getInstance: ");
sb.append(obj.getClass().getName());
throw new IllegalArgumentException(sb.toString());
}
public RequestedCertificate(Certificate certificate2) {
this.cert = certificate2;
}
private RequestedCertificate(ASN1TaggedObject aSN1TaggedObject) {
if (aSN1TaggedObject.getTagNo() == 0) {
this.publicKeyCert = ASN1OctetString.getInstance(aSN1TaggedObject, true).getOctets();
} else if (aSN1TaggedObject.getTagNo() == 1) {
this.attributeCert = ASN1OctetString.getInstance(aSN1TaggedObject, true).getOctets();
} else {
StringBuilder sb = new StringBuilder("unknown tag number: ");
sb.append(aSN1TaggedObject.getTagNo());
throw new IllegalArgumentException(sb.toString());
}
}
public RequestedCertificate(int i, byte[] bArr) {
this(new DERTaggedObject(i, new DEROctetString(bArr)));
}
}