76 lines
2.8 KiB
Java
76 lines
2.8 KiB
Java
|
package org.bouncycastle.asn1.x509;
|
||
|
|
||
|
import java.util.Enumeration;
|
||
|
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 CertificatePair extends ASN1Object {
|
||
|
private Certificate forward;
|
||
|
private Certificate reverse;
|
||
|
|
||
|
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
|
||
|
public ASN1Primitive toASN1Primitive() {
|
||
|
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
|
||
|
if (this.forward != null) {
|
||
|
aSN1EncodableVector.add(new DERTaggedObject(0, this.forward));
|
||
|
}
|
||
|
if (this.reverse != null) {
|
||
|
aSN1EncodableVector.add(new DERTaggedObject(1, this.reverse));
|
||
|
}
|
||
|
return new DERSequence(aSN1EncodableVector);
|
||
|
}
|
||
|
|
||
|
public Certificate getReverse() {
|
||
|
return this.reverse;
|
||
|
}
|
||
|
|
||
|
public Certificate getForward() {
|
||
|
return this.forward;
|
||
|
}
|
||
|
|
||
|
public static CertificatePair getInstance(Object obj) {
|
||
|
if (obj == null || (obj instanceof CertificatePair)) {
|
||
|
return (CertificatePair) obj;
|
||
|
}
|
||
|
if (obj instanceof ASN1Sequence) {
|
||
|
return new CertificatePair((ASN1Sequence) obj);
|
||
|
}
|
||
|
StringBuilder sb = new StringBuilder("illegal object in getInstance: ");
|
||
|
sb.append(obj.getClass().getName());
|
||
|
throw new IllegalArgumentException(sb.toString());
|
||
|
}
|
||
|
|
||
|
public CertificatePair(Certificate certificate, Certificate certificate2) {
|
||
|
this.forward = certificate;
|
||
|
this.reverse = certificate2;
|
||
|
}
|
||
|
|
||
|
private CertificatePair(ASN1Sequence aSN1Sequence) {
|
||
|
if (aSN1Sequence.size() != 1 && aSN1Sequence.size() != 2) {
|
||
|
StringBuilder sb = new StringBuilder("Bad sequence size: ");
|
||
|
sb.append(aSN1Sequence.size());
|
||
|
throw new IllegalArgumentException(sb.toString());
|
||
|
}
|
||
|
Enumeration objects = aSN1Sequence.getObjects();
|
||
|
while (objects.hasMoreElements()) {
|
||
|
ASN1TaggedObject aSN1TaggedObject = ASN1TaggedObject.getInstance(objects.nextElement());
|
||
|
if (aSN1TaggedObject.getTagNo() == 0) {
|
||
|
this.forward = Certificate.getInstance(aSN1TaggedObject, true);
|
||
|
} else {
|
||
|
if (aSN1TaggedObject.getTagNo() != 1) {
|
||
|
StringBuilder sb2 = new StringBuilder("Bad tag number: ");
|
||
|
sb2.append(aSN1TaggedObject.getTagNo());
|
||
|
throw new IllegalArgumentException(sb2.toString());
|
||
|
}
|
||
|
this.reverse = Certificate.getInstance(aSN1TaggedObject, true);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|