package t2;

import java.security.GeneralSecurityException;
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 f9978b = Logger.getLogger(e.class.getName());

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

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

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

    public final synchronized void b(A2.f fVar) {
        int iA = fVar.a();
        if (!(iA != 1 ? s0.c.b(iA) : s0.c.a(iA))) {
            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 {
            A2.f fVar = dVar.f9977a;
            Class cls = fVar.f32c;
            if (!fVar.f31b.keySet().contains(cls) && !Void.class.equals(cls)) {
                throw new IllegalArgumentException("Given internalKeyMananger " + fVar.toString() + " does not support primitive class " + cls.getName());
            }
            String strB = fVar.b();
            d dVar2 = (d) this.f9979a.get(strB);
            if (dVar2 != null && !dVar2.f9977a.getClass().equals(dVar.f9977a.getClass())) {
                f9978b.warning("Attempted overwrite of a registered key manager for key type ".concat(strB));
                throw new GeneralSecurityException("typeUrl (" + strB + ") is already registered with " + dVar2.f9977a.getClass().getName() + ", cannot be re-registered with " + dVar.f9977a.getClass().getName());
            }
            this.f9979a.putIfAbsent(strB, dVar);
        } catch (Throwable th) {
            throw th;
        }
    }

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