导航菜单

页面标题

页面副标题

Sandridge Go v2025.2.170190457 - f.java 源代码

正在查看: Sandridge Go v2025.2.170190457 应用的 f.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.microsoft.intune.mam.policy;

import android.content.Context;
import android.net.Uri;
import com.microsoft.intune.mam.client.app.AbstractC0134g;
import com.microsoft.intune.mam.client.app.AbstractC0135h;
import com.microsoft.intune.mam.policy.g;
import com.staffbase.capacitor.plugin.kvStore.StaffbaseKVStore;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.HttpUrl;
import org.json.JSONArray;
import org.json.JSONObject;

public class f implements g.c {
    private static final t5.e g = t5.f.a(f.class);
    public static final long h = TimeUnit.MINUTES.toMillis(30);
    public static final long i = TimeUnit.DAYS.toMillis(7);
    private final Context a;
    private final SSLSocketFactory b;
    private final MAMServiceAuthenticationCallbackExtended c;
    private final i d;
    private HttpURLConnection e = null;
    private String f = null;

    public f(Context context, SSLSocketFactory sSLSocketFactory, MAMServiceAuthenticationCallbackExtended mAMServiceAuthenticationCallbackExtended, i iVar) {
        this.a = context;
        this.b = sSLSocketFactory;
        this.c = mAMServiceAuthenticationCallbackExtended;
        this.d = iVar;
    }

    private void g(g.b bVar) {
        if (r(bVar)) {
            String a = AbstractC0135h.a(this.c, bVar.a);
            bVar.c = a;
            if (a == null) {
                bVar.g = MAMWEError.APP_DID_NOT_PROVIDE_TOKEN;
            }
        }
    }

    private String h() {
        return "{" + UUID.randomUUID().toString().toUpperCase(Locale.getDefault()) + "}";
    }

    private static long i(HttpURLConnection httpURLConnection) {
        String headerField = httpURLConnection.getHeaderField("MobileApplicationManagement-RetryAfterMinutes");
        long j = 43200000;
        if (headerField == null) {
            g.h(q5.c.LOOKUP_INVALID_RETRY_INTERVAL_RESPONSE, "Could not find expected header field in Location Service response: MobileApplicationManagement-RetryAfterMinutes", new Object[0]);
            return 43200000L;
        }
        try {
            j = TimeUnit.MINUTES.toMillis(Long.parseLong(headerField));
            g.m("Received {0} = {1} from Location Service.", "MobileApplicationManagement-RetryAfterMinutes", Long.valueOf(j));
        } catch (NumberFormatException e) {
            g.f(q5.c.LOOKUP_INVALID_RETRY_INTERVAL_RESPONSE, "Failed to get Location Service retry interval, could not parse header string as long.", e);
        }
        long j2 = h;
        if (j < j2) {
            g.h(q5.c.LOOKUP_INVALID_RETRY_INTERVAL_RESPONSE, "Location Service sent retry interval that is too short, received {0}, using {1}", Long.valueOf(j), Long.valueOf(j2));
            return j2;
        }
        long j3 = i;
        if (j <= j3) {
            return j;
        }
        g.h(q5.c.LOOKUP_INVALID_RETRY_INTERVAL_RESPONSE, "Location Service sent retry interval that is too long, received {0}, using {1}", Long.valueOf(j), Long.valueOf(j3));
        return j3;
    }

    private String j(String str) {
        String h2 = AbstractC0134g.h(this.a, str, "1.0");
        String a = j.a();
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("AppId", str);
        jSONObject.put("AppVersion", h2);
        jSONObject.put("SdkVersion", a);
        jSONObject.put("Os", "android");
        return jSONObject.toString();
    }

    private HttpURLConnection k(String str, String str2, String str3, String str4) {
        HttpURLConnection q = q(new m().g(new URL(Uri.withAppendedPath(Uri.parse(str), "ApplicationInstances(guid'00000000-0000-0000-0000-000000000000')/IsTargeted").toString())).d().b(this.d).a());
        q.setRequestMethod("POST");
        q.setRequestProperty("Content-Type", "application/json");
        q.setRequestProperty("Authorization", str2);
        q.setRequestProperty("Prefer", "return-content");
        q.setRequestProperty("Content-Length", HttpUrl.FRAGMENT_ENCODE_SET + Integer.toString(str3.getBytes().length));
        q.setRequestProperty("client-request-id", str4);
        q.setUseCaches(false);
        q.setDoInput(true);
        q.setDoOutput(true);
        q.setConnectTimeout(30000);
        q.setReadTimeout(60000);
        return q;
    }

    private String l(String str, String str2) {
        try {
            String g2 = new g5.e(this.a, str).g();
            if (g2 != null) {
                g.m("overriding default FWLink with manifest value: " + g2, new Object[0]);
                return g2;
            }
        } catch (AssertionError e) {
            g.o(Level.WARNING, "error looking for FWLink override", e);
        }
        String f = com.microsoft.intune.mam.http.d.b(str2).f();
        g.m("using FWLink value: " + f, new Object[0]);
        return f;
    }

    private void m(String str, g.b bVar) {
        int i2;
        HttpURLConnection httpURLConnection;
        HttpURLConnection httpURLConnection2;
        for (0; i2 < 3; i2 + 1) {
            this.e = null;
            this.f = null;
            if (i2 > 0) {
                try {
                    try {
                        try {
                            g.m("Retrying retrieve lookup service URL operation...", new Object[0]);
                            Thread.sleep(50L);
                        } catch (IOException e) {
                            g.o(Level.WARNING, "Failed to get lookup service url from FWLink", e);
                            bVar.g = MAMWEError.NETWORK_ERROR;
                            httpURLConnection2 = this.e;
                            if (httpURLConnection2 == null) {
                            }
                        }
                    } catch (InterruptedException e2) {
                        g.o(Level.WARNING, "Failed to sleep between fwlink request retries", e2);
                        httpURLConnection2 = this.e;
                        if (httpURLConnection2 == null) {
                        }
                    } catch (MalformedURLException e3) {
                        g.o(Level.WARNING, String.format("Could not create URL from lookup fwlink %s.", str), e3);
                        httpURLConnection = this.e;
                        if (httpURLConnection == null) {
                            return;
                        }
                    }
                } catch (Throwable th) {
                    HttpURLConnection httpURLConnection3 = this.e;
                    if (httpURLConnection3 != null) {
                        httpURLConnection3.disconnect();
                    }
                    throw th;
                }
            }
            bVar.g = MAMWEError.NONE_KNOWN;
            HttpURLConnection httpURLConnection4 = (HttpURLConnection) new URL(str).openConnection();
            this.e = httpURLConnection4;
            httpURLConnection4.setInstanceFollowRedirects(false);
            this.e.setConnectTimeout(30000);
            this.e.setReadTimeout(60000);
            int responseCode = this.e.getResponseCode();
            if (responseCode != 302 && responseCode != 301) {
                g.x("Failed to get lookup service url from FWLink; status = " + String.valueOf(responseCode) + " " + this.e.getResponseMessage(), new Object[0]);
                httpURLConnection2 = this.e;
                i2 = httpURLConnection2 == null ? i2 + 1 : 0;
                httpURLConnection2.disconnect();
            }
            String headerField = this.e.getHeaderField("Location");
            g.m("Retrieved lookup service URL: {0} ", headerField);
            bVar.d = headerField;
            httpURLConnection = this.e;
            if (httpURLConnection == null) {
                return;
            }
            httpURLConnection.disconnect();
            return;
        }
    }

    private static String n(HttpURLConnection httpURLConnection) {
        InputStream inputStream = httpURLConnection.getInputStream();
        if (inputStream == null) {
            return null;
        }
        char[] cArr = new char[1024];
        StringBuilder sb = new StringBuilder();
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
        while (true) {
            int read = inputStreamReader.read(cArr, 0, 1024);
            if (read < 0) {
                return sb.toString();
            }
            sb.append(cArr, 0, read);
        }
    }

    private static Map o(String str) {
        JSONArray jSONArray = new JSONObject(str).getJSONArray("Services");
        HashMap hashMap = new HashMap();
        for (int i2 = 0; i2 < jSONArray.length(); i2++) {
            JSONObject jSONObject = jSONArray.getJSONObject(i2);
            String string = jSONObject.getString("ServiceName");
            String string2 = jSONObject.getString("Url");
            g.m("found service {0} with URL {1}", string, string2);
            hashMap.put(string.toLowerCase(Locale.US), string2);
        }
        return hashMap;
    }

    private boolean p() {
        return new g5.e(this.a).i();
    }

    private HttpURLConnection q(URL url) {
        HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
        SSLSocketFactory sSLSocketFactory = this.b;
        if (sSLSocketFactory != null) {
            if (httpURLConnection instanceof HttpsURLConnection) {
                ((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(sSLSocketFactory);
            } else if (!p()) {
                throw new MalformedURLException("https scheme is required for MAMService URLs.  Invalid URL: " + url.toString());
            }
        }
        return httpURLConnection;
    }

    private boolean r(g.b bVar) {
        if (bVar == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_AUTH_CALLBACK, "null supportData passed to acquireTokenFromCallback() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.a.canonicalUPN() == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_AUTH_CALLBACK, "required UPN not provided for acquireTokenFromCallback() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.a.aadId() != null) {
            return true;
        }
        g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_AUTH_CALLBACK, "required AAD ID not provided for acquireTokenFromCallback() -- programmer error.", new Object[0]);
        return false;
    }

    private boolean s(g.b bVar) {
        if (bVar == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_IS_TARGETED, "null supportData passed to getIsTargeted() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.c == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_IS_TARGETED, "required MAMService token not provided for getIsTargeted() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.a() == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_IS_TARGETED, "required MAMService URL not provided for getIsTargeted() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.b != null) {
            return true;
        }
        g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_IS_TARGETED, "required package name not provided for getIsTargeted() -- programmer error.", new Object[0]);
        return false;
    }

    private boolean t(g.b bVar) {
        if (bVar == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_FETCH, "null supportData passed to getLookupServiceUrl() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.b != null) {
            return true;
        }
        g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_FETCH, "required package name not provided for getLookupServiceUrl() -- programmer error.", new Object[0]);
        return false;
    }

    private boolean u(g.b bVar) {
        if (bVar == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_QUERY, "null supportData passed to queryLookupService() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.c == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_QUERY, "required MAMService token not provided for queryLookupService() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.d == null) {
            g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_QUERY, "required lookup service URL not provided for queryLookupService() -- programmer error.", new Object[0]);
            return false;
        }
        if (bVar.b != null) {
            return true;
        }
        g.h(q5.c.LOOKUP_INVALID_PARAMS_FOR_QUERY, "required package name not provided for queryLookupService() -- programmer error.", new Object[0]);
        return false;
    }

    @Override
    public void a(g.b bVar) {
        if (t(bVar)) {
            m(l(bVar.b, bVar.a.authority()), bVar);
        }
    }

    @Override
    public void b(g.b bVar) {
        if (this.c != null) {
            g(bVar);
        } else {
            g.x("Neither a token nor a callback was provided to MAMServiceLookupOperations.", new Object[0]);
        }
    }

    @Override
    public HttpURLConnection c() {
        return this.e;
    }

    @Override
    public void d(g.b bVar) {
        HttpURLConnection httpURLConnection;
        if (u(bVar)) {
            this.e = null;
            this.f = h();
            String a = c.a(bVar.c);
            try {
                try {
                    HttpURLConnection q = q(new m().g(new URL(bVar.d)).c().b(this.d).a());
                    this.e = q;
                    q.setRequestProperty("Accept", "application/json");
                    this.e.setRequestProperty("Authorization", a);
                    this.e.setRequestProperty("AppId", bVar.b);
                    this.e.setRequestProperty("client-request-id", this.f);
                    this.e.setConnectTimeout(30000);
                    this.e.setReadTimeout(60000);
                    t5.e eVar = g;
                    eVar.m("Querying lookup service with URL: " + bVar.d + " activity id: " + this.f, new Object[0]);
                    int responseCode = this.e.getResponseCode();
                    if (responseCode == 200) {
                        String n = n(this.e);
                        if (n != null && !n.isEmpty()) {
                            eVar.m("Lookup Service returned response: {0}", n);
                            bVar.e = o(n);
                        }
                        eVar.x("Failed to get MAM service url from lookup service; response body was empty; activity id: {0}", this.f);
                        HttpURLConnection httpURLConnection2 = this.e;
                        if (httpURLConnection2 != null) {
                            httpURLConnection2.disconnect();
                            return;
                        }
                        return;
                    }
                    if (responseCode == 404) {
                        bVar.h = i(this.e);
                    }
                    eVar.x("Failed to get MAM service url from lookup service; activity id: {0}; status = " + String.valueOf(responseCode) + " " + this.e.getResponseMessage(), this.f);
                    HttpURLConnection httpURLConnection3 = this.e;
                    if (httpURLConnection3 != null) {
                        httpURLConnection3.disconnect();
                    }
                } catch (IOException e) {
                    g.p(Level.WARNING, "Failed to get MAM service url from lookup service due to network error; activity id: {0}", e, this.f);
                    bVar.g = MAMWEError.NETWORK_ERROR;
                    httpURLConnection = this.e;
                    if (httpURLConnection == null) {
                        return;
                    }
                    httpURLConnection.disconnect();
                } catch (Exception e2) {
                    g.p(Level.WARNING, "Failed to get MAM service url from lookup service; activity id: {0}", e2, this.f);
                    httpURLConnection = this.e;
                    if (httpURLConnection == null) {
                        return;
                    }
                    httpURLConnection.disconnect();
                }
            } catch (Throwable th) {
                HttpURLConnection httpURLConnection4 = this.e;
                if (httpURLConnection4 != null) {
                    httpURLConnection4.disconnect();
                }
                throw th;
            }
        }
    }

    @Override
    public String e() {
        return this.f;
    }

    @Override
    public void f(g.b bVar) {
        HttpURLConnection httpURLConnection;
        if (s(bVar)) {
            String a = c.a(bVar.c);
            this.e = null;
            this.f = h();
            try {
                try {
                    String j = j(bVar.b);
                    t5.e eVar = g;
                    eVar.m("Checking if user is targeted for policy.  POSTing " + j + " with activity id: " + this.f, new Object[0]);
                    this.e = k(bVar.a(), a, j, this.f);
                    DataOutputStream dataOutputStream = new DataOutputStream(this.e.getOutputStream());
                    dataOutputStream.writeBytes(j);
                    dataOutputStream.flush();
                    dataOutputStream.close();
                    int responseCode = this.e.getResponseCode();
                    if (responseCode == 200) {
                        String n = n(this.e);
                        if (n != null && !n.isEmpty()) {
                            eVar.m("IsTargeted response: {0} ", n);
                            bVar.f = Boolean.valueOf(new JSONObject(n).getBoolean(StaffbaseKVStore.KEY_VALUE));
                        }
                        eVar.x("Failed to get JSON response from MAM Service; response body was empty.", new Object[0]);
                        HttpURLConnection httpURLConnection2 = this.e;
                        if (httpURLConnection2 != null) {
                            httpURLConnection2.disconnect();
                            return;
                        }
                        return;
                    }
                    eVar.x("Failed to get JSON response from MAM Service; activity id: {0}; status = " + String.valueOf(responseCode) + " " + this.e.getResponseMessage(), this.f);
                    HttpURLConnection httpURLConnection3 = this.e;
                    if (httpURLConnection3 != null) {
                        httpURLConnection3.disconnect();
                    }
                } catch (IOException e) {
                    g.p(Level.WARNING, "Failed to query the MAMService for policy targeting due to network error, activity id: {0}", e, this.f);
                    bVar.g = MAMWEError.NETWORK_ERROR;
                    httpURLConnection = this.e;
                    if (httpURLConnection == null) {
                        return;
                    }
                    httpURLConnection.disconnect();
                } catch (Exception e2) {
                    g.p(Level.WARNING, "Failed to query the MAMService for policy targeting, activity id: {0}", e2, this.f);
                    httpURLConnection = this.e;
                    if (httpURLConnection == null) {
                        return;
                    }
                    httpURLConnection.disconnect();
                }
            } catch (Throwable th) {
                HttpURLConnection httpURLConnection4 = this.e;
                if (httpURLConnection4 != null) {
                    httpURLConnection4.disconnect();
                }
                throw th;
            }
        }
    }
}