package com.google.android.gms.fido.fido2.api.common;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.ResultReceiver;
import android.util.Log;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import androidx.media3.extractor.text.ttml.TtmlNode;
import com.google.android.gms.common.internal.Objects;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.internal.safeparcel.SafeParcelWriter;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelableSerializer;
import com.google.android.gms.common.util.Base64Utils;
import com.google.android.gms.fido.fido2.api.common.AttestationConveyancePreference;
import com.google.android.gms.fido.u2f.api.common.ClientData;
import com.google.android.gms.internal.fido.zzbl;
import com.google.android.gms.internal.fido.zzia;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import defpackage.fi7;
import defpackage.n41;
import defpackage.rq6;
import defpackage.vo6;
import defpackage.vw2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
@SafeParcelable.Class(creator = "PublicKeyCredentialCreationOptionsCreator")
@SafeParcelable.Reserved({1})
public class PublicKeyCredentialCreationOptions extends RequestOptions {

    @vo6
    public static final Parcelable.Creator<PublicKeyCredentialCreationOptions> CREATOR = new zzan();

    @vo6
    @SafeParcelable.Field(getter = "getRp", id = 2)
    private final PublicKeyCredentialRpEntity zza;

    @vo6
    @SafeParcelable.Field(getter = "getUser", id = 3)
    private final PublicKeyCredentialUserEntity zzb;

    @vo6
    @SafeParcelable.Field(getter = "getChallenge", id = 4)
    private final byte[] zzc;

    @vo6
    @SafeParcelable.Field(getter = "getParameters", id = 5)
    private final List zzd;

    @rq6
    @SafeParcelable.Field(getter = "getTimeoutSeconds", id = 6)
    private final Double zze;

    @rq6
    @SafeParcelable.Field(getter = "getExcludeList", id = 7)
    private final List zzf;

    @rq6
    @SafeParcelable.Field(getter = "getAuthenticatorSelection", id = 8)
    private final AuthenticatorSelectionCriteria zzg;

    @rq6
    @SafeParcelable.Field(getter = "getRequestId", id = 9)
    private final Integer zzh;

    @rq6
    @SafeParcelable.Field(getter = "getTokenBinding", id = 10)
    private final TokenBinding zzi;

    @rq6
    @SafeParcelable.Field(getter = "getAttestationConveyancePreferenceAsString", id = 11, type = "java.lang.String")
    private final AttestationConveyancePreference zzj;

    @rq6
    @SafeParcelable.Field(getter = "getAuthenticationExtensions", id = 12)
    private final AuthenticationExtensions zzk;

    @rq6
    @SafeParcelable.Field(getter = "getJsonString", id = 13)
    private final String zzl;

    @rq6
    @SafeParcelable.Field(getter = "getResultReceiver", id = 14)
    private ResultReceiver zzm;

    public static final class Builder {
        private PublicKeyCredentialRpEntity zza;
        private PublicKeyCredentialUserEntity zzb;
        private byte[] zzc;
        private List zzd;
        private Double zze;
        private List zzf;
        private AuthenticatorSelectionCriteria zzg;
        private Integer zzh;
        private TokenBinding zzi;
        private AttestationConveyancePreference zzj;
        private AuthenticationExtensions zzk;

        @vo6
        public PublicKeyCredentialCreationOptions build() {
            PublicKeyCredentialRpEntity publicKeyCredentialRpEntity = this.zza;
            PublicKeyCredentialUserEntity publicKeyCredentialUserEntity = this.zzb;
            byte[] bArr = this.zzc;
            List list = this.zzd;
            Double d = this.zze;
            List list2 = this.zzf;
            AuthenticatorSelectionCriteria authenticatorSelectionCriteria = this.zzg;
            Integer num = this.zzh;
            TokenBinding tokenBinding = this.zzi;
            AttestationConveyancePreference attestationConveyancePreference = this.zzj;
            return new PublicKeyCredentialCreationOptions(publicKeyCredentialRpEntity, publicKeyCredentialUserEntity, bArr, list, d, list2, authenticatorSelectionCriteria, num, tokenBinding, attestationConveyancePreference == null ? null : attestationConveyancePreference.toString(), this.zzk, null, null);
        }

        @vo6
        public Builder setAttestationConveyancePreference(@rq6 AttestationConveyancePreference attestationConveyancePreference) {
            this.zzj = attestationConveyancePreference;
            return this;
        }

        @vo6
        public Builder setAuthenticationExtensions(@rq6 AuthenticationExtensions authenticationExtensions) {
            this.zzk = authenticationExtensions;
            return this;
        }

        @vo6
        public Builder setAuthenticatorSelection(@rq6 AuthenticatorSelectionCriteria authenticatorSelectionCriteria) {
            this.zzg = authenticatorSelectionCriteria;
            return this;
        }

        @vo6
        public Builder setChallenge(@vo6 byte[] bArr) {
            this.zzc = (byte[]) Preconditions.checkNotNull(bArr);
            return this;
        }

        @vo6
        public Builder setExcludeList(@rq6 List<PublicKeyCredentialDescriptor> list) {
            this.zzf = list;
            return this;
        }

        @vo6
        public Builder setParameters(@vo6 List<PublicKeyCredentialParameters> list) {
            this.zzd = (List) Preconditions.checkNotNull(list);
            return this;
        }

        @vo6
        public Builder setRequestId(@rq6 Integer num) {
            this.zzh = num;
            return this;
        }

        @vo6
        public Builder setRp(@vo6 PublicKeyCredentialRpEntity publicKeyCredentialRpEntity) {
            this.zza = (PublicKeyCredentialRpEntity) Preconditions.checkNotNull(publicKeyCredentialRpEntity);
            return this;
        }

        @vo6
        public Builder setTimeoutSeconds(@rq6 Double d) {
            this.zze = d;
            return this;
        }

        @vo6
        public Builder setTokenBinding(@rq6 TokenBinding tokenBinding) {
            this.zzi = tokenBinding;
            return this;
        }

        @vo6
        public Builder setUser(@vo6 PublicKeyCredentialUserEntity publicKeyCredentialUserEntity) {
            this.zzb = (PublicKeyCredentialUserEntity) Preconditions.checkNotNull(publicKeyCredentialUserEntity);
            return this;
        }
    }

    @SafeParcelable.Constructor
    public PublicKeyCredentialCreationOptions(@vo6 @SafeParcelable.Param(id = 2) PublicKeyCredentialRpEntity publicKeyCredentialRpEntity, @vo6 @SafeParcelable.Param(id = 3) PublicKeyCredentialUserEntity publicKeyCredentialUserEntity, @vo6 @SafeParcelable.Param(id = 4) byte[] bArr, @vo6 @SafeParcelable.Param(id = 5) List list, @rq6 @SafeParcelable.Param(id = 6) Double d, @rq6 @SafeParcelable.Param(id = 7) List list2, @rq6 @SafeParcelable.Param(id = 8) AuthenticatorSelectionCriteria authenticatorSelectionCriteria, @rq6 @SafeParcelable.Param(id = 9) Integer num, @rq6 @SafeParcelable.Param(id = 10) TokenBinding tokenBinding, @rq6 @SafeParcelable.Param(id = 11) String str, @rq6 @SafeParcelable.Param(id = 12) AuthenticationExtensions authenticationExtensions, @rq6 @SafeParcelable.Param(id = 13) String str2, @rq6 @SafeParcelable.Param(id = 14) ResultReceiver resultReceiver) {
        this.zzm = resultReceiver;
        if (str2 != null) {
            try {
                PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptionsZza = zza(new JSONObject(str2));
                this.zza = publicKeyCredentialCreationOptionsZza.zza;
                this.zzb = publicKeyCredentialCreationOptionsZza.zzb;
                this.zzc = publicKeyCredentialCreationOptionsZza.zzc;
                this.zzd = publicKeyCredentialCreationOptionsZza.zzd;
                this.zze = publicKeyCredentialCreationOptionsZza.zze;
                this.zzf = publicKeyCredentialCreationOptionsZza.zzf;
                this.zzg = publicKeyCredentialCreationOptionsZza.zzg;
                this.zzh = publicKeyCredentialCreationOptionsZza.zzh;
                this.zzi = publicKeyCredentialCreationOptionsZza.zzi;
                this.zzj = publicKeyCredentialCreationOptionsZza.zzj;
                this.zzk = publicKeyCredentialCreationOptionsZza.zzk;
                this.zzl = str2;
                return;
            } catch (JSONException e) {
                throw new IllegalArgumentException(e);
            }
        }
        this.zza = (PublicKeyCredentialRpEntity) Preconditions.checkNotNull(publicKeyCredentialRpEntity);
        this.zzb = (PublicKeyCredentialUserEntity) Preconditions.checkNotNull(publicKeyCredentialUserEntity);
        this.zzc = (byte[]) Preconditions.checkNotNull(bArr);
        this.zzd = (List) Preconditions.checkNotNull(list);
        this.zze = d;
        this.zzf = list2;
        this.zzg = authenticatorSelectionCriteria;
        this.zzh = num;
        this.zzi = tokenBinding;
        if (str != null) {
            try {
                this.zzj = AttestationConveyancePreference.fromString(str);
            } catch (AttestationConveyancePreference.UnsupportedAttestationConveyancePreferenceException e2) {
                throw new IllegalArgumentException(e2);
            }
        } else {
            this.zzj = null;
        }
        this.zzk = authenticationExtensions;
        this.zzl = null;
    }

    @vo6
    public static PublicKeyCredentialCreationOptions deserializeFromBytes(@vo6 byte[] bArr) {
        return (PublicKeyCredentialCreationOptions) SafeParcelableSerializer.deserializeFromBytes(bArr, CREATOR);
    }

    @vo6
    public static PublicKeyCredentialCreationOptions zza(@vo6 JSONObject jSONObject) throws JSONException {
        zzbl zzblVarZzc;
        Builder builder = new Builder();
        JSONObject jSONObject2 = jSONObject.getJSONObject("rp");
        Parcelable.Creator<PublicKeyCredentialRpEntity> creator = PublicKeyCredentialRpEntity.CREATOR;
        builder.setRp(new PublicKeyCredentialRpEntity(jSONObject2.getString(TtmlNode.ATTR_ID), jSONObject2.getString(AppMeasurementSdk.ConditionalUserProperty.NAME), jSONObject2.has("icon") ? jSONObject2.optString("icon") : null));
        JSONObject jSONObject3 = jSONObject.getJSONObject("user");
        Parcelable.Creator<PublicKeyCredentialUserEntity> creator2 = PublicKeyCredentialUserEntity.CREATOR;
        builder.setUser(new PublicKeyCredentialUserEntity(Base64Utils.decodeUrlSafeNoPadding(jSONObject3.getString(TtmlNode.ATTR_ID)), jSONObject3.getString(AppMeasurementSdk.ConditionalUserProperty.NAME), jSONObject3.has("icon") ? jSONObject3.optString("icon") : null, jSONObject3.optString("displayName")));
        builder.setChallenge(Base64Utils.decodeUrlSafeNoPadding(jSONObject.getString(ClientData.KEY_CHALLENGE)));
        JSONArray jSONArray = jSONObject.getJSONArray("pubKeyCredParams");
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < jSONArray.length(); i++) {
            JSONObject jSONObject4 = jSONArray.getJSONObject(i);
            try {
                zzblVarZzc = zzbl.zzd(new PublicKeyCredentialParameters(jSONObject4.getString(SessionDescription.ATTR_TYPE), jSONObject4.getInt("alg")));
            } catch (IllegalArgumentException unused) {
                zzblVarZzc = zzbl.zzc();
            }
            if (zzblVarZzc.zzb()) {
                arrayList.add(zzblVarZzc.zza());
            }
        }
        builder.setParameters(arrayList);
        if (jSONObject.has("timeout")) {
            builder.setTimeoutSeconds(Double.valueOf(jSONObject.getDouble("timeout") / 1000.0d));
        }
        if (jSONObject.has("excludeCredentials")) {
            JSONArray jSONArray2 = jSONObject.getJSONArray("excludeCredentials");
            ArrayList arrayList2 = new ArrayList();
            for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
                arrayList2.add(PublicKeyCredentialDescriptor.zza(jSONArray2.getJSONObject(i2)));
            }
            builder.setExcludeList(arrayList2);
        }
        if (jSONObject.has("authenticatorSelection")) {
            JSONObject jSONObject5 = jSONObject.getJSONObject("authenticatorSelection");
            Parcelable.Creator<AuthenticatorSelectionCriteria> creator3 = AuthenticatorSelectionCriteria.CREATOR;
            builder.setAuthenticatorSelection(new AuthenticatorSelectionCriteria(jSONObject5.has("authenticatorAttachment") ? jSONObject5.optString("authenticatorAttachment") : null, jSONObject5.has("requireResidentKey") ? Boolean.valueOf(jSONObject5.optBoolean("requireResidentKey")) : null, jSONObject5.has("userVerification") ? jSONObject5.optString("userVerification") : null, jSONObject5.has("residentKey") ? jSONObject5.optString("residentKey") : null));
        }
        if (jSONObject.has("extensions")) {
            builder.setAuthenticationExtensions(AuthenticationExtensions.zza(jSONObject.getJSONObject("extensions")));
        }
        if (jSONObject.has("attestation")) {
            try {
                builder.setAttestationConveyancePreference(AttestationConveyancePreference.fromString(jSONObject.getString("attestation")));
            } catch (AttestationConveyancePreference.UnsupportedAttestationConveyancePreferenceException e) {
                Log.w("PKCCreationOptions", "Invalid AttestationConveyancePreference", e);
                builder.setAttestationConveyancePreference(AttestationConveyancePreference.NONE);
            }
        }
        return builder.build();
    }

    public boolean equals(@vo6 Object obj) {
        List list;
        List list2;
        if (!(obj instanceof PublicKeyCredentialCreationOptions)) {
            return false;
        }
        PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptions = (PublicKeyCredentialCreationOptions) obj;
        return Objects.equal(this.zza, publicKeyCredentialCreationOptions.zza) && Objects.equal(this.zzb, publicKeyCredentialCreationOptions.zzb) && Arrays.equals(this.zzc, publicKeyCredentialCreationOptions.zzc) && Objects.equal(this.zze, publicKeyCredentialCreationOptions.zze) && this.zzd.containsAll(publicKeyCredentialCreationOptions.zzd) && publicKeyCredentialCreationOptions.zzd.containsAll(this.zzd) && (((list = this.zzf) == null && publicKeyCredentialCreationOptions.zzf == null) || (list != null && (list2 = publicKeyCredentialCreationOptions.zzf) != null && list.containsAll(list2) && publicKeyCredentialCreationOptions.zzf.containsAll(this.zzf))) && Objects.equal(this.zzg, publicKeyCredentialCreationOptions.zzg) && Objects.equal(this.zzh, publicKeyCredentialCreationOptions.zzh) && Objects.equal(this.zzi, publicKeyCredentialCreationOptions.zzi) && Objects.equal(this.zzj, publicKeyCredentialCreationOptions.zzj) && Objects.equal(this.zzk, publicKeyCredentialCreationOptions.zzk) && Objects.equal(this.zzl, publicKeyCredentialCreationOptions.zzl);
    }

    @rq6
    public AttestationConveyancePreference getAttestationConveyancePreference() {
        return this.zzj;
    }

    @rq6
    public String getAttestationConveyancePreferenceAsString() {
        AttestationConveyancePreference attestationConveyancePreference = this.zzj;
        if (attestationConveyancePreference == null) {
            return null;
        }
        return attestationConveyancePreference.toString();
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public AuthenticationExtensions getAuthenticationExtensions() {
        return this.zzk;
    }

    @rq6
    public AuthenticatorSelectionCriteria getAuthenticatorSelection() {
        return this.zzg;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @vo6
    public byte[] getChallenge() {
        return this.zzc;
    }

    @rq6
    public List<PublicKeyCredentialDescriptor> getExcludeList() {
        return this.zzf;
    }

    @rq6
    public String getJsonString() {
        return this.zzl;
    }

    @vo6
    public List<PublicKeyCredentialParameters> getParameters() {
        return this.zzd;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public Integer getRequestId() {
        return this.zzh;
    }

    @vo6
    public PublicKeyCredentialRpEntity getRp() {
        return this.zza;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public Double getTimeoutSeconds() {
        return this.zze;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public TokenBinding getTokenBinding() {
        return this.zzi;
    }

    @vo6
    public PublicKeyCredentialUserEntity getUser() {
        return this.zzb;
    }

    public int hashCode() {
        return Objects.hashCode(this.zza, this.zzb, Integer.valueOf(Arrays.hashCode(this.zzc)), this.zzd, this.zze, this.zzf, this.zzg, this.zzh, this.zzi, this.zzj, this.zzk, this.zzl);
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @vo6
    public byte[] serializeToBytes() {
        if (!zzia.zzd()) {
            return SafeParcelableSerializer.serializeToBytes(this);
        }
        Builder builder = new Builder();
        builder.setRp(this.zza);
        builder.setUser(this.zzb);
        builder.setChallenge(this.zzc);
        builder.setParameters(this.zzd);
        builder.setTimeoutSeconds(this.zze);
        builder.setExcludeList(this.zzf);
        builder.setAuthenticatorSelection(this.zzg);
        builder.setRequestId(this.zzh);
        builder.setTokenBinding(this.zzi);
        builder.setAttestationConveyancePreference(this.zzj);
        builder.setAuthenticationExtensions(this.zzk);
        return SafeParcelableSerializer.serializeToBytes(builder.build());
    }

    @vo6
    public final String toString() {
        AuthenticationExtensions authenticationExtensions = this.zzk;
        AttestationConveyancePreference attestationConveyancePreference = this.zzj;
        TokenBinding tokenBinding = this.zzi;
        AuthenticatorSelectionCriteria authenticatorSelectionCriteria = this.zzg;
        List list = this.zzf;
        List list2 = this.zzd;
        byte[] bArr = this.zzc;
        PublicKeyCredentialUserEntity publicKeyCredentialUserEntity = this.zzb;
        String strValueOf = String.valueOf(this.zza);
        String strValueOf2 = String.valueOf(publicKeyCredentialUserEntity);
        String strEncodeUrlSafeNoPadding = Base64Utils.encodeUrlSafeNoPadding(bArr);
        String strValueOf3 = String.valueOf(list2);
        String strValueOf4 = String.valueOf(list);
        String strValueOf5 = String.valueOf(authenticatorSelectionCriteria);
        String strValueOf6 = String.valueOf(tokenBinding);
        String strValueOf7 = String.valueOf(attestationConveyancePreference);
        String strValueOf8 = String.valueOf(authenticationExtensions);
        StringBuilder sbM = fi7.m("PublicKeyCredentialCreationOptions{\n rp=", strValueOf, ", \n user=", strValueOf2, ", \n challenge=");
        vw2.aa(sbM, strEncodeUrlSafeNoPadding, ", \n parameters=", strValueOf3, ", \n timeoutSeconds=");
        sbM.append(this.zze);
        sbM.append(", \n excludeList=");
        sbM.append(strValueOf4);
        sbM.append(", \n authenticatorSelection=");
        sbM.append(strValueOf5);
        sbM.append(", \n requestId=");
        sbM.append(this.zzh);
        sbM.append(", \n tokenBinding=");
        sbM.append(strValueOf6);
        sbM.append(", \n attestationConveyancePreference=");
        return n41.u(sbM, strValueOf7, ", \n authenticationExtensions=", strValueOf8, "}");
    }

    @Override // android.os.Parcelable
    public void writeToParcel(@vo6 Parcel parcel, int i) {
        int iBeginObjectHeader = SafeParcelWriter.beginObjectHeader(parcel);
        SafeParcelWriter.writeParcelable(parcel, 2, getRp(), i, false);
        SafeParcelWriter.writeParcelable(parcel, 3, getUser(), i, false);
        SafeParcelWriter.writeByteArray(parcel, 4, getChallenge(), false);
        SafeParcelWriter.writeTypedList(parcel, 5, getParameters(), false);
        SafeParcelWriter.writeDoubleObject(parcel, 6, getTimeoutSeconds(), false);
        SafeParcelWriter.writeTypedList(parcel, 7, getExcludeList(), false);
        SafeParcelWriter.writeParcelable(parcel, 8, getAuthenticatorSelection(), i, false);
        SafeParcelWriter.writeIntegerObject(parcel, 9, getRequestId(), false);
        SafeParcelWriter.writeParcelable(parcel, 10, getTokenBinding(), i, false);
        SafeParcelWriter.writeString(parcel, 11, getAttestationConveyancePreferenceAsString(), false);
        SafeParcelWriter.writeParcelable(parcel, 12, getAuthenticationExtensions(), i, false);
        SafeParcelWriter.writeString(parcel, 13, getJsonString(), false);
        SafeParcelWriter.writeParcelable(parcel, 14, this.zzm, i, false);
        SafeParcelWriter.finishObjectHeader(parcel, iBeginObjectHeader);
    }

    public PublicKeyCredentialCreationOptions(@vo6 String str) {
        try {
            PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptionsZza = zza(new JSONObject(str));
            this.zza = publicKeyCredentialCreationOptionsZza.zza;
            this.zzb = publicKeyCredentialCreationOptionsZza.zzb;
            this.zzc = publicKeyCredentialCreationOptionsZza.zzc;
            this.zzd = publicKeyCredentialCreationOptionsZza.zzd;
            this.zze = publicKeyCredentialCreationOptionsZza.zze;
            this.zzf = publicKeyCredentialCreationOptionsZza.zzf;
            this.zzg = publicKeyCredentialCreationOptionsZza.zzg;
            this.zzh = publicKeyCredentialCreationOptionsZza.zzh;
            this.zzi = publicKeyCredentialCreationOptionsZza.zzi;
            this.zzj = publicKeyCredentialCreationOptionsZza.zzj;
            this.zzk = publicKeyCredentialCreationOptionsZza.zzk;
            this.zzl = str;
        } catch (JSONException e) {
            throw new IllegalArgumentException(e);
        }
    }
}
