what-the-bank/sources/org/bouncycastle/asn1/crmf/OptionalValidity.java

70 lines
2.3 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.crmf;
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;
import org.bouncycastle.asn1.x509.Time;
/* loaded from: classes6.dex */
public class OptionalValidity extends ASN1Object {
private Time notAfter;
private Time notBefore;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
if (this.notBefore != null) {
aSN1EncodableVector.add(new DERTaggedObject(true, 0, this.notBefore));
}
if (this.notAfter != null) {
aSN1EncodableVector.add(new DERTaggedObject(true, 1, this.notAfter));
}
return new DERSequence(aSN1EncodableVector);
}
public Time getNotBefore() {
return this.notBefore;
}
public Time getNotAfter() {
return this.notAfter;
}
public static OptionalValidity getInstance(Object obj) {
if (obj instanceof OptionalValidity) {
return (OptionalValidity) obj;
}
if (obj != null) {
return new OptionalValidity(ASN1Sequence.getInstance(obj));
}
return null;
}
public OptionalValidity(Time time, Time time2) {
if (time == null && time2 == null) {
throw new IllegalArgumentException("at least one of notBefore/notAfter must not be null.");
}
this.notBefore = time;
this.notAfter = time2;
}
private OptionalValidity(ASN1Sequence aSN1Sequence) {
Enumeration objects = aSN1Sequence.getObjects();
while (objects.hasMoreElements()) {
ASN1TaggedObject aSN1TaggedObject = (ASN1TaggedObject) objects.nextElement();
int tagNo = aSN1TaggedObject.getTagNo();
Time time = Time.getInstance(aSN1TaggedObject, true);
if (tagNo == 0) {
this.notBefore = time;
} else {
this.notAfter = time;
}
}
}
}