导航菜单

页面标题

页面副标题

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

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

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


package com.microsoft.identity.common.internal.providers.oauth2;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.microsoft.identity.common.adal.internal.AuthenticationConstants;
import com.microsoft.identity.common.internal.ui.DualScreenActivity;
import com.microsoft.identity.common.logging.Logger;

public class CurrentTaskAuthorizationActivity extends DualScreenActivity {
    private static final String TAG = "CurrentTaskAuthorizationActivity";
    private boolean mCloseCustomTabs = true;
    private CurrentTaskBrowserAuthorizationFragment mFragment;
    private BroadcastReceiver redirectReceiver;

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        String str = TAG + ":onCreate";
        Fragment authorizationFragmentFromStartIntent = AuthorizationActivityFactory.getAuthorizationFragmentFromStartIntent(getIntent());
        if (authorizationFragmentFromStartIntent instanceof CurrentTaskBrowserAuthorizationFragment) {
            CurrentTaskBrowserAuthorizationFragment currentTaskBrowserAuthorizationFragment = (CurrentTaskBrowserAuthorizationFragment) authorizationFragmentFromStartIntent;
            this.mFragment = currentTaskBrowserAuthorizationFragment;
            currentTaskBrowserAuthorizationFragment.setInstanceState(getIntent().getExtras());
            if (AuthenticationConstants.AuthorizationIntentAction.REDIRECT_RETURNED_ACTION.equals(getIntent().getAction())) {
                if (CurrentTaskBrowserAuthorizationFragment.class.isInstance(this.mFragment)) {
                    Bundle bundle2 = new Bundle();
                    bundle2.putBoolean("RESPONSE", true);
                    this.mFragment.setArguments(bundle2);
                    this.mFragment.completeAuthorizationInBrowserFlow(getIntent().getStringExtra("RESPONSE_URI"));
                    finish();
                    return;
                }
                return;
            }
            setFragment(this.mFragment);
            if (bundle == null) {
                this.mCloseCustomTabs = false;
                this.redirectReceiver = new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        Intent intent2 = new Intent((Context) CurrentTaskAuthorizationActivity.this, (Class<?>) CurrentTaskAuthorizationActivity.class);
                        intent2.setAction(AuthenticationConstants.AuthorizationIntentAction.REFRESH_TO_CLOSE);
                        intent2.addFlags(603979776);
                        CurrentTaskAuthorizationActivity.this.startActivity(intent2);
                    }
                };
                LocalBroadcastManager.getInstance(this).registerReceiver(this.redirectReceiver, new IntentFilter(AuthenticationConstants.AuthorizationIntentAction.REDIRECT_RETURNED_ACTION));
                return;
            }
            return;
        }
        IllegalStateException illegalStateException = new IllegalStateException("Unexpected fragment type");
        Logger.error(str, "Fragment provided was not of type CurrentTaskBrowserAuthorizationFragment", illegalStateException);
        throw illegalStateException;
    }

    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        if (AuthenticationConstants.AuthorizationIntentAction.REFRESH_TO_CLOSE.equals(intent.getAction())) {
            LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(AuthenticationConstants.AuthorizationIntentAction.DESTROY_REDIRECT_RECEIVING_ACTIVITY_ACTION));
            unregisterAndFinish();
        }
        setIntent(intent);
    }

    protected void onResume() {
        super.onResume();
        if (AuthenticationConstants.AuthorizationIntentAction.REDIRECT_RETURNED_ACTION.equals(getIntent().getAction())) {
            Bundle bundle = new Bundle();
            bundle.putBoolean("RESPONSE", true);
            this.mFragment.setArguments(bundle);
            this.mFragment.completeAuthorizationInBrowserFlow(getIntent().getStringExtra("RESPONSE_URI"));
            setResult(-1);
            unregisterAndFinish();
        }
        if (this.mCloseCustomTabs) {
            unregisterAndFinish();
        }
        this.mCloseCustomTabs = true;
    }

    private void unregisterAndFinish() {
        LocalBroadcastManager.getInstance(this).unregisterReceiver(this.redirectReceiver);
        finish();
    }
}