what-the-bank/sources/org/bouncycastle/asn1/tsp/Accuracy.java

107 lines
4.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.tsp;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
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 Accuracy extends ASN1Object {
protected static final int MAX_MICROS = 999;
protected static final int MAX_MILLIS = 999;
protected static final int MIN_MICROS = 1;
protected static final int MIN_MILLIS = 1;
ASN1Integer micros;
ASN1Integer millis;
ASN1Integer seconds;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
ASN1Integer aSN1Integer = this.seconds;
if (aSN1Integer != null) {
aSN1EncodableVector.add(aSN1Integer);
}
if (this.millis != null) {
aSN1EncodableVector.add(new DERTaggedObject(false, 0, this.millis));
}
if (this.micros != null) {
aSN1EncodableVector.add(new DERTaggedObject(false, 1, this.micros));
}
return new DERSequence(aSN1EncodableVector);
}
public ASN1Integer getSeconds() {
return this.seconds;
}
public ASN1Integer getMillis() {
return this.millis;
}
public ASN1Integer getMicros() {
return this.micros;
}
public static Accuracy getInstance(Object obj) {
if (obj instanceof Accuracy) {
return (Accuracy) obj;
}
if (obj != null) {
return new Accuracy(ASN1Sequence.getInstance(obj));
}
return null;
}
private Accuracy(ASN1Sequence aSN1Sequence) {
this.seconds = null;
this.millis = null;
this.micros = null;
for (int i = 0; i < aSN1Sequence.size(); i++) {
if (aSN1Sequence.getObjectAt(i) instanceof ASN1Integer) {
this.seconds = (ASN1Integer) aSN1Sequence.getObjectAt(i);
} else if (aSN1Sequence.getObjectAt(i) instanceof ASN1TaggedObject) {
ASN1TaggedObject aSN1TaggedObject = (ASN1TaggedObject) aSN1Sequence.getObjectAt(i);
int tagNo = aSN1TaggedObject.getTagNo();
if (tagNo == 0) {
ASN1Integer aSN1Integer = ASN1Integer.getInstance(aSN1TaggedObject, false);
this.millis = aSN1Integer;
if (aSN1Integer.getValue().intValue() <= 0 || this.millis.getValue().intValue() > 999) {
throw new IllegalArgumentException("Invalid millis field : not in (1..999).");
}
} else {
if (tagNo != 1) {
throw new IllegalArgumentException("Invalig tag number");
}
ASN1Integer aSN1Integer2 = ASN1Integer.getInstance(aSN1TaggedObject, false);
this.micros = aSN1Integer2;
if (aSN1Integer2.getValue().intValue() <= 0 || this.micros.getValue().intValue() > 999) {
throw new IllegalArgumentException("Invalid micros field : not in (1..999).");
}
}
} else {
continue;
}
}
}
public Accuracy(ASN1Integer aSN1Integer, ASN1Integer aSN1Integer2, ASN1Integer aSN1Integer3) {
this.seconds = aSN1Integer;
if (aSN1Integer2 != null && (aSN1Integer2.getValue().intValue() <= 0 || aSN1Integer2.getValue().intValue() > 999)) {
throw new IllegalArgumentException("Invalid millis field : not in (1..999)");
}
this.millis = aSN1Integer2;
if (aSN1Integer3 != null && (aSN1Integer3.getValue().intValue() <= 0 || aSN1Integer3.getValue().intValue() > 999)) {
throw new IllegalArgumentException("Invalid micros field : not in (1..999)");
}
this.micros = aSN1Integer3;
}
protected Accuracy() {
}
}