64 lines
2.2 KiB
Java
64 lines
2.2 KiB
Java
package org.bouncycastle.asn1.cmp;
|
|
|
|
import org.bouncycastle.asn1.ASN1Choice;
|
|
import org.bouncycastle.asn1.ASN1Object;
|
|
import org.bouncycastle.asn1.ASN1Primitive;
|
|
import org.bouncycastle.asn1.ASN1TaggedObject;
|
|
import org.bouncycastle.asn1.DERTaggedObject;
|
|
import org.bouncycastle.asn1.crmf.EncryptedValue;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class CertOrEncCert extends ASN1Object implements ASN1Choice {
|
|
private CMPCertificate certificate;
|
|
private EncryptedValue encryptedCert;
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
|
|
public ASN1Primitive toASN1Primitive() {
|
|
return this.certificate != null ? new DERTaggedObject(true, 0, this.certificate) : new DERTaggedObject(true, 1, this.encryptedCert);
|
|
}
|
|
|
|
public EncryptedValue getEncryptedCert() {
|
|
return this.encryptedCert;
|
|
}
|
|
|
|
public CMPCertificate getCertificate() {
|
|
return this.certificate;
|
|
}
|
|
|
|
public static CertOrEncCert getInstance(Object obj) {
|
|
if (obj instanceof CertOrEncCert) {
|
|
return (CertOrEncCert) obj;
|
|
}
|
|
if (obj instanceof ASN1TaggedObject) {
|
|
return new CertOrEncCert((ASN1TaggedObject) obj);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public CertOrEncCert(EncryptedValue encryptedValue) {
|
|
if (encryptedValue == null) {
|
|
throw new IllegalArgumentException("'encryptedCert' cannot be null");
|
|
}
|
|
this.encryptedCert = encryptedValue;
|
|
}
|
|
|
|
public CertOrEncCert(CMPCertificate cMPCertificate) {
|
|
if (cMPCertificate == null) {
|
|
throw new IllegalArgumentException("'certificate' cannot be null");
|
|
}
|
|
this.certificate = cMPCertificate;
|
|
}
|
|
|
|
private CertOrEncCert(ASN1TaggedObject aSN1TaggedObject) {
|
|
if (aSN1TaggedObject.getTagNo() == 0) {
|
|
this.certificate = CMPCertificate.getInstance(aSN1TaggedObject.getObject());
|
|
} else if (aSN1TaggedObject.getTagNo() == 1) {
|
|
this.encryptedCert = EncryptedValue.getInstance(aSN1TaggedObject.getObject());
|
|
} else {
|
|
StringBuilder sb = new StringBuilder("unknown tag: ");
|
|
sb.append(aSN1TaggedObject.getTagNo());
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
}
|
|
}
|