package e1;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import l1.C0622e;
import okhttp3.HttpUrl;

/* JADX INFO: renamed from: e1.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0453a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static Properties f3806a = new Properties();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static C0622e f3807b = C0622e.a();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static String f3808c;

    static {
        f3808c = "Cp850";
        try {
            String property = System.getProperty("jcifs.properties");
            FileInputStream fileInputStream = (property == null || property.length() <= 1) ? null : new FileInputStream(property);
            i(fileInputStream);
            if (fileInputStream != null) {
                fileInputStream.close();
            }
        } catch (IOException e2) {
            if (C0622e.f5384g > 0) {
                e2.printStackTrace(f3807b);
            }
        }
        int iD = d("jcifs.util.loglevel", -1);
        if (iD != -1) {
            C0622e.d(iD);
        }
        try {
            HttpUrl.FRAGMENT_ENCODE_SET.getBytes(f3808c);
        } catch (UnsupportedEncodingException unused) {
            if (C0622e.f5384g >= 2) {
                f3807b.println("WARNING: The default OEM encoding " + f3808c + " does not appear to be supported by this JRE. The default encoding will be US-ASCII.");
            }
            f3808c = "US-ASCII";
        }
        if (C0622e.f5384g >= 4) {
            try {
                f3806a.store(f3807b, "JCIFS PROPERTIES");
            } catch (IOException unused2) {
            }
        }
    }

    public static boolean a(String str, boolean z2) {
        String strG = g(str);
        return strG != null ? strG.toLowerCase().equals("true") : z2;
    }

    public static InetAddress b(String str, InetAddress inetAddress) {
        String property = f3806a.getProperty(str);
        if (property == null) {
            return inetAddress;
        }
        try {
            return InetAddress.getByName(property);
        } catch (UnknownHostException e2) {
            if (C0622e.f5384g <= 0) {
                return inetAddress;
            }
            f3807b.println(property);
            e2.printStackTrace(f3807b);
            return inetAddress;
        }
    }

    public static InetAddress[] c(String str, String str2, InetAddress[] inetAddressArr) {
        String strG = g(str);
        if (strG == null) {
            return inetAddressArr;
        }
        StringTokenizer stringTokenizer = new StringTokenizer(strG, str2);
        int iCountTokens = stringTokenizer.countTokens();
        InetAddress[] inetAddressArr2 = new InetAddress[iCountTokens];
        for (int i2 = 0; i2 < iCountTokens; i2++) {
            String strNextToken = stringTokenizer.nextToken();
            try {
                inetAddressArr2[i2] = InetAddress.getByName(strNextToken);
            } catch (UnknownHostException e2) {
                if (C0622e.f5384g > 0) {
                    f3807b.println(strNextToken);
                    e2.printStackTrace(f3807b);
                }
                return inetAddressArr;
            }
        }
        return inetAddressArr2;
    }

    public static int d(String str, int i2) {
        String property = f3806a.getProperty(str);
        if (property == null) {
            return i2;
        }
        try {
            return Integer.parseInt(property);
        } catch (NumberFormatException e2) {
            if (C0622e.f5384g <= 0) {
                return i2;
            }
            e2.printStackTrace(f3807b);
            return i2;
        }
    }

    public static InetAddress e() {
        String property = f3806a.getProperty("jcifs.smb.client.laddr");
        if (property == null) {
            return null;
        }
        try {
            return InetAddress.getByName(property);
        } catch (UnknownHostException e2) {
            if (C0622e.f5384g <= 0) {
                return null;
            }
            f3807b.println("Ignoring jcifs.smb.client.laddr address: " + property);
            e2.printStackTrace(f3807b);
            return null;
        }
    }

    public static long f(String str, long j2) {
        String property = f3806a.getProperty(str);
        if (property == null) {
            return j2;
        }
        try {
            return Long.parseLong(property);
        } catch (NumberFormatException e2) {
            if (C0622e.f5384g <= 0) {
                return j2;
            }
            e2.printStackTrace(f3807b);
            return j2;
        }
    }

    public static String g(String str) {
        return f3806a.getProperty(str);
    }

    public static String h(String str, String str2) {
        return f3806a.getProperty(str, str2);
    }

    public static void i(InputStream inputStream) throws IOException {
        if (inputStream != null) {
            f3806a.load(inputStream);
        }
        try {
            f3806a.putAll((Map) System.getProperties().clone());
        } catch (SecurityException unused) {
            if (C0622e.f5384g > 1) {
                f3807b.println("SecurityException: jcifs will ignore System properties");
            }
        }
    }

    public static void j() {
        String property = System.getProperty("java.version");
        if (property.startsWith("1.1.") || property.startsWith("1.2.")) {
            throw new RuntimeException("jcifs-0.7.0b4+ requires Java 1.3 or above. You are running " + property);
        }
        String property2 = System.getProperty("java.protocol.handler.pkgs");
        if (property2 == null) {
            System.setProperty("java.protocol.handler.pkgs", "jcifs");
        } else if (property2.indexOf("jcifs") == -1) {
            System.setProperty("java.protocol.handler.pkgs", property2 + "|jcifs");
        }
    }

    public static Object k(String str, String str2) {
        return f3806a.setProperty(str, str2);
    }
}
