what-the-bank/sources/org/bouncycastle/crypto/tls/CertificateStatus.java

60 lines
1.9 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.tls;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1Encoding;
import org.bouncycastle.asn1.ocsp.OCSPResponse;
/* loaded from: classes6.dex */
public class CertificateStatus {
protected Object response;
protected short statusType;
public short getStatusType() {
return this.statusType;
}
public Object getResponse() {
return this.response;
}
public OCSPResponse getOCSPResponse() {
if (isCorrectType((short) 1, this.response)) {
return (OCSPResponse) this.response;
}
throw new IllegalStateException("'response' is not an OCSPResponse");
}
public void encode(OutputStream outputStream) throws IOException {
TlsUtils.writeUint8(this.statusType, outputStream);
if (this.statusType != 1) {
throw new TlsFatalAlert((short) 80);
}
TlsUtils.writeOpaque24(((OCSPResponse) this.response).getEncoded(ASN1Encoding.DER), outputStream);
}
public static CertificateStatus parse(InputStream inputStream) throws IOException {
short readUint8 = TlsUtils.readUint8(inputStream);
if (readUint8 == 1) {
return new CertificateStatus(readUint8, OCSPResponse.getInstance(TlsUtils.readDERObject(TlsUtils.readOpaque24(inputStream))));
}
throw new TlsFatalAlert((short) 50);
}
protected static boolean isCorrectType(short s, Object obj) {
if (s == 1) {
return obj instanceof OCSPResponse;
}
throw new IllegalArgumentException("'statusType' is an unsupported value");
}
public CertificateStatus(short s, Object obj) {
if (!isCorrectType(s, obj)) {
throw new IllegalArgumentException("'response' is not an instance of the correct type");
}
this.statusType = s;
this.response = obj;
}
}