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

101 lines
3.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.cmp;
import java.util.Enumeration;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERTaggedObject;
/* loaded from: classes6.dex */
public class KeyRecRepContent extends ASN1Object {
private ASN1Sequence caCerts;
private ASN1Sequence keyPairHist;
private CMPCertificate newSigCert;
private PKIStatusInfo status;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
aSN1EncodableVector.add(this.status);
addOptional(aSN1EncodableVector, 0, this.newSigCert);
addOptional(aSN1EncodableVector, 1, this.caCerts);
addOptional(aSN1EncodableVector, 2, this.keyPairHist);
return new DERSequence(aSN1EncodableVector);
}
public PKIStatusInfo getStatus() {
return this.status;
}
public CMPCertificate getNewSigCert() {
return this.newSigCert;
}
public CertifiedKeyPair[] getKeyPairHist() {
ASN1Sequence aSN1Sequence = this.keyPairHist;
if (aSN1Sequence == null) {
return null;
}
int size = aSN1Sequence.size();
CertifiedKeyPair[] certifiedKeyPairArr = new CertifiedKeyPair[size];
for (int i = 0; i != size; i++) {
certifiedKeyPairArr[i] = CertifiedKeyPair.getInstance(this.keyPairHist.getObjectAt(i));
}
return certifiedKeyPairArr;
}
public CMPCertificate[] getCaCerts() {
ASN1Sequence aSN1Sequence = this.caCerts;
if (aSN1Sequence == null) {
return null;
}
int size = aSN1Sequence.size();
CMPCertificate[] cMPCertificateArr = new CMPCertificate[size];
for (int i = 0; i != size; i++) {
cMPCertificateArr[i] = CMPCertificate.getInstance(this.caCerts.getObjectAt(i));
}
return cMPCertificateArr;
}
public static KeyRecRepContent getInstance(Object obj) {
if (obj instanceof KeyRecRepContent) {
return (KeyRecRepContent) obj;
}
if (obj != null) {
return new KeyRecRepContent(ASN1Sequence.getInstance(obj));
}
return null;
}
private void addOptional(ASN1EncodableVector aSN1EncodableVector, int i, ASN1Encodable aSN1Encodable) {
if (aSN1Encodable != null) {
aSN1EncodableVector.add(new DERTaggedObject(true, i, aSN1Encodable));
}
}
private KeyRecRepContent(ASN1Sequence aSN1Sequence) {
Enumeration objects = aSN1Sequence.getObjects();
this.status = PKIStatusInfo.getInstance(objects.nextElement());
while (objects.hasMoreElements()) {
ASN1TaggedObject aSN1TaggedObject = ASN1TaggedObject.getInstance(objects.nextElement());
int tagNo = aSN1TaggedObject.getTagNo();
if (tagNo == 0) {
this.newSigCert = CMPCertificate.getInstance(aSN1TaggedObject.getObject());
} else if (tagNo == 1) {
this.caCerts = ASN1Sequence.getInstance(aSN1TaggedObject.getObject());
} else {
if (tagNo != 2) {
StringBuilder sb = new StringBuilder("unknown tag number: ");
sb.append(aSN1TaggedObject.getTagNo());
throw new IllegalArgumentException(sb.toString());
}
this.keyPairHist = ASN1Sequence.getInstance(aSN1TaggedObject.getObject());
}
}
}
}