package p138.p329.p374;

import com.hierynomus.protocol.commons.buffer.Buffer;
import com.hierynomus.spnego.SpnegoException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import p138.p139.p143.p144.C2803;
import p138.p329.p330.C6077;
import p138.p329.p330.C6079;
import p138.p329.p330.p331.p333.C6083;
import p138.p329.p330.p331.p333.C6084;
import p138.p329.p330.p334.AbstractC6087;
import p138.p329.p330.p334.AbstractC6088;
import p138.p329.p330.p334.p335.C6109;
import p138.p329.p330.p334.p336.C6117;
import p138.p329.p330.p334.p336.C6128;
import p138.p329.p330.p334.p337.C6137;
import p138.p329.p351.p352.p353.AbstractC6294;
import p138.p329.p351.p352.p353.C6293;

/* JADX INFO: renamed from: ދ.ށ.ފ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6420 extends AbstractC6422 {

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public BigInteger f17920;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public C6128 f17921;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public byte[] f17922;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public byte[] f17923;

    public C6420() {
        super(1, "NegTokenTarg");
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ void m9645(Throwable th, AutoCloseable autoCloseable) throws Exception {
        if (th == null) {
            autoCloseable.close();
            return;
        }
        try {
            autoCloseable.close();
        } catch (Throwable th2) {
            th.addSuppressed(th2);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public C6420 m9646(byte[] bArr) throws Exception {
        try {
            C6077 c6077 = new C6077(new C6083(), new C6293(new Buffer.C0346(bArr, AbstractC6294.f17633)));
            try {
                m9648(c6077.m9449());
                m9645((Throwable) null, c6077);
                return this;
            } finally {
            }
        } catch (IOException e) {
            throw new SpnegoException("Could not read NegTokenTarg from buffer", e);
        }
    }

    @Override // p138.p329.p374.AbstractC6422
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo9647(Buffer<?> buffer, AbstractC6087 abstractC6087) throws Exception {
        C6109 c6109 = new C6109(AbstractC6088.m9459(1).m9463(), abstractC6087, true);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        C6079 c6079 = new C6079(new C6084(), byteArrayOutputStream);
        try {
            c6079.m9450(c6109);
            m9645((Throwable) null, c6079);
            buffer.m1463(byteArrayOutputStream.toByteArray());
        } finally {
        }
    }

    @Override // p138.p329.p374.AbstractC6422
    /* JADX INFO: renamed from: ֏ */
    public void mo9642(C6109 c6109) throws SpnegoException {
        int i = c6109.f17009.f17021;
        if (i == 0) {
            AbstractC6087 abstractC6087M9466 = c6109.m9466();
            if (abstractC6087M9466 instanceof C6117) {
                this.f17920 = ((C6117) abstractC6087M9466).f17040;
                return;
            } else {
                StringBuilder sbM4889 = C2803.m4889("Expected the negResult (ENUMERATED) contents, not: ");
                sbM4889.append(this.f17921);
                throw new SpnegoException(sbM4889.toString());
            }
        }
        if (i == 1) {
            AbstractC6087 abstractC6087M94662 = c6109.m9466();
            if (abstractC6087M94662 instanceof C6128) {
                this.f17921 = (C6128) abstractC6087M94662;
                return;
            }
            throw new SpnegoException("Expected the supportedMech (OBJECT IDENTIFIER) contents, not: " + abstractC6087M94662);
        }
        if (i == 2) {
            AbstractC6087 abstractC6087M94663 = c6109.m9466();
            if (abstractC6087M94663 instanceof C6137) {
                this.f17922 = ((C6137) abstractC6087M94663).mo9457();
                return;
            }
            throw new SpnegoException("Expected the responseToken (OCTET_STRING) contents, not: " + abstractC6087M94663);
        }
        if (i != 3) {
            throw new SpnegoException(C2803.m4882(C2803.m4889("Unknown Object Tag "), c6109.f17009.f17021, " encountered."));
        }
        AbstractC6087 abstractC6087M94664 = c6109.m9466();
        if (abstractC6087M94664 instanceof C6137) {
            this.f17923 = ((C6137) abstractC6087M94664).mo9457();
            return;
        }
        throw new SpnegoException("Expected the responseToken (OCTET_STRING) contents, not: " + abstractC6087M94664);
    }
}
