导航菜单

页面标题

页面副标题

St.John's v1.0.9 - BrokerHelperActivity.java 源代码

正在查看: St.John's v1.0.9 应用的 BrokerHelperActivity.java JAVA 源代码文件

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


package com.microsoft.identity.client.helper;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.microsoft.identity.common.internal.broker.PackageHelper;
import com.microsoft.identity.msal.R;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class BrokerHelperActivity extends Activity {
    private final String MANIFEST_TEMPLATE = "<activity android:name=\"com.microsoft.identity.client.BrowserTabActivity\">\n    <intent-filter>\n        <action android:name=\"android.intent.action.VIEW\" />\n        <category android:name=\"android.intent.category.DEFAULT\" />\n        <category android:name=\"android.intent.category.BROWSABLE\" />\n        <data\n            android:host=\"%s\"\n            android:path=\"/%s\"\n            android:scheme=\"msauth\" />\n    </intent-filter>\n</activity>";
    TextView mManifest;
    TextView mPackageName;
    TextView mRedirect;
    TextView mSignature;

    public static Intent createStartIntent(Context context) {
        return new Intent(context, (Class<?>) BrokerHelperActivity.class);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.broker_helper);
        this.mPackageName = (TextView) findViewById(R.id.txtPackageName);
        this.mSignature = (TextView) findViewById(R.id.txtSignature);
        this.mRedirect = (TextView) findViewById(R.id.txtRedirect);
        this.mManifest = (TextView) findViewById(R.id.txtManifest);
        this.mSignature.append(getSignature(false));
        this.mRedirect.append(PackageHelper.getBrokerRedirectUri(getApplicationContext(), getPackageName()));
        this.mManifest.append(String.format("<activity android:name=\"com.microsoft.identity.client.BrowserTabActivity\">\n    <intent-filter>\n        <action android:name=\"android.intent.action.VIEW\" />\n        <category android:name=\"android.intent.category.DEFAULT\" />\n        <category android:name=\"android.intent.category.BROWSABLE\" />\n        <data\n            android:host=\"%s\"\n            android:path=\"/%s\"\n            android:scheme=\"msauth\" />\n    </intent-filter>\n</activity>", getPackageName(), getSignature(false)));
        this.mPackageName.append(getPackageName());
    }

    private String getSignature(boolean z) {
        String sha1SignatureForPackage = new PackageHelper(getApplicationContext().getPackageManager()).getSha1SignatureForPackage(getPackageName());
        if (!z) {
            return sha1SignatureForPackage;
        }
        try {
            return URLEncoder.encode(sha1SignatureForPackage, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            Log.e("getSignature", "Character encoding UTF-8 is not supported.", e);
            throw new RuntimeException("Unexpected: Unable to get the signature for this application package.");
        }
    }
}