package com.mbridge.msdk.thrid.okhttp; import com.ironsource.nb; import com.mbridge.msdk.thrid.okhttp.internal.Util; import java.nio.charset.Charset; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; /* loaded from: classes4.dex */ public final class Challenge { private final Map authParams; private final String scheme; public Map authParams() { return this.authParams; } public String scheme() { return this.scheme; } public Challenge(String str, Map map) { if (str == null) { throw new NullPointerException("scheme == null"); } if (map == null) { throw new NullPointerException("authParams == null"); } this.scheme = str; LinkedHashMap linkedHashMap = new LinkedHashMap(); for (Map.Entry entry : map.entrySet()) { linkedHashMap.put(entry.getKey() == null ? null : entry.getKey().toLowerCase(Locale.US), entry.getValue()); } this.authParams = Collections.unmodifiableMap(linkedHashMap); } public Challenge(String str, String str2) { if (str == null) { throw new NullPointerException("scheme == null"); } if (str2 == null) { throw new NullPointerException("realm == null"); } this.scheme = str; this.authParams = Collections.singletonMap("realm", str2); } public Challenge withCharset(Charset charset) { if (charset == null) { throw new NullPointerException("charset == null"); } LinkedHashMap linkedHashMap = new LinkedHashMap(this.authParams); linkedHashMap.put(nb.M, charset.name()); return new Challenge(this.scheme, linkedHashMap); } public String realm() { return this.authParams.get("realm"); } public Charset charset() { String str = this.authParams.get(nb.M); if (str != null) { try { return Charset.forName(str); } catch (Exception unused) { } } return Util.ISO_8859_1; } public boolean equals(Object obj) { if (obj instanceof Challenge) { Challenge challenge = (Challenge) obj; if (challenge.scheme.equals(this.scheme) && challenge.authParams.equals(this.authParams)) { return true; } } return false; } public int hashCode() { return ((899 + this.scheme.hashCode()) * 31) + this.authParams.hashCode(); } public String toString() { return this.scheme + " authParams=" + this.authParams; } }