package L3;

import java.security.GeneralSecurityException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;

/* JADX INFO: loaded from: classes3.dex */
public final class e {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Logger f4167b = Logger.getLogger(e.class.getName());

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ConcurrentHashMap f4168a;

    public e(e eVar) {
        this.f4168a = new ConcurrentHashMap(eVar.f4168a);
    }

    public final synchronized d a(String str) {
        if (!this.f4168a.containsKey(str)) {
            throw new GeneralSecurityException("No key manager found for key type " + str);
        }
        return (d) this.f4168a.get(str);
    }

    public final synchronized void b(S3.d dVar) {
        int iA = dVar.a();
        if (!(iA != 1 ? A0.a.b(iA) : A0.a.a(iA))) {
            throw new GeneralSecurityException("failed to register key manager " + dVar.getClass() + " as it is not FIPS compatible.");
        }
        c(new d(dVar));
    }

    public final synchronized void c(d dVar) {
        try {
            S3.d dVar2 = dVar.f4166a;
            Class cls = dVar2.f6225c;
            if (!dVar2.f6224b.keySet().contains(cls) && !Void.class.equals(cls)) {
                throw new IllegalArgumentException("Given internalKeyMananger " + dVar2.toString() + " does not support primitive class " + cls.getName());
            }
            String strB = dVar2.b();
            d dVar3 = (d) this.f4168a.get(strB);
            if (dVar3 != null && !dVar3.f4166a.getClass().equals(dVar.f4166a.getClass())) {
                f4167b.warning("Attempted overwrite of a registered key manager for key type ".concat(strB));
                throw new GeneralSecurityException("typeUrl (" + strB + ") is already registered with " + dVar3.f4166a.getClass().getName() + ", cannot be re-registered with " + dVar.f4166a.getClass().getName());
            }
            this.f4168a.putIfAbsent(strB, dVar);
        } catch (Throwable th) {
            throw th;
        }
    }

    public e() {
        this.f4168a = new ConcurrentHashMap();
    }
}
