package H3;

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

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

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

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

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

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

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

    public final synchronized void c(d dVar) {
        try {
            O3.f fVar = dVar.f3073a;
            Class cls = (Class) fVar.f5148b;
            if (!((Map) fVar.f5149c).keySet().contains(cls) && !Void.class.equals(cls)) {
                throw new IllegalArgumentException("Given internalKeyMananger " + fVar.toString() + " does not support primitive class " + cls.getName());
            }
            String strC = fVar.c();
            d dVar2 = (d) this.f3075a.get(strC);
            if (dVar2 != null && !dVar2.f3073a.getClass().equals(dVar.f3073a.getClass())) {
                f3074b.warning("Attempted overwrite of a registered key manager for key type ".concat(strC));
                throw new GeneralSecurityException("typeUrl (" + strC + ") is already registered with " + dVar2.f3073a.getClass().getName() + ", cannot be re-registered with " + dVar.f3073a.getClass().getName());
            }
            this.f3075a.putIfAbsent(strC, dVar);
        } catch (Throwable th) {
            throw th;
        }
    }

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