正在查看: St.John's v1.0.9 应用的 BrokerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 BrokerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.microsoft.identity.common.internal.broker;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.microsoft.identity.common.PropertyBagUtil;
import com.microsoft.identity.common.internal.result.BrokerResultAdapterFactory;
import com.microsoft.identity.common.java.AuthenticationConstants;
import com.microsoft.identity.common.java.exception.ClientException;
import com.microsoft.identity.common.java.exception.ErrorStrings;
import com.microsoft.identity.common.java.request.SdkType;
import com.microsoft.identity.common.java.util.ported.LocalBroadcaster;
import com.microsoft.identity.common.java.util.ported.PropertyBag;
import com.microsoft.identity.common.logging.Logger;
public final class BrokerActivity extends Activity {
public static final String BROKER_INTENT = "broker_intent";
static final int BROKER_INTENT_REQUEST_CODE = 1001;
static final String BROKER_INTENT_STARTED = "broker_intent_started";
private static final String TAG = "BrokerActivity";
private Intent mBrokerInteractiveRequestIntent;
private Boolean mBrokerIntentStarted = false;
private Boolean mBrokerResultReceived = false;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
String str = TAG + ":onCreate";
if (bundle == null) {
Bundle extras = getIntent().getExtras();
if (extras != null) {
this.mBrokerInteractiveRequestIntent = (Intent) extras.getParcelable(BROKER_INTENT);
return;
} else {
Logger.warn(str, "Extras is null.");
return;
}
}
this.mBrokerInteractiveRequestIntent = (Intent) bundle.getParcelable(BROKER_INTENT);
this.mBrokerIntentStarted = Boolean.valueOf(bundle.getBoolean(BROKER_INTENT_STARTED));
}
@Override
protected void onResume() {
super.onResume();
if (this.mBrokerIntentStarted.booleanValue()) {
return;
}
this.mBrokerIntentStarted = true;
startActivityForResult(this.mBrokerInteractiveRequestIntent, 1001);
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onDestroy() {
if (!this.mBrokerResultReceived.booleanValue()) {
returnsExceptionOnActivityUnexpectedlyKilled();
}
super.onDestroy();
}
private void returnsExceptionOnActivityUnexpectedlyKilled() {
PropertyBag fromBundle = PropertyBagUtil.fromBundle(BrokerResultAdapterFactory.getBrokerResultAdapter(SdkType.MSAL).bundleFromBaseException(new ClientException(ErrorStrings.BROKER_REQUEST_CANCELLED, "The activity is killed unexpectedly."), null));
fromBundle.put(AuthenticationConstants.LocalBroadcasterFields.REQUEST_CODE, Integer.valueOf(AuthenticationConstants.UIRequest.BROKER_FLOW));
fromBundle.put(AuthenticationConstants.LocalBroadcasterFields.RESULT_CODE, Integer.valueOf(AuthenticationConstants.BrokerResponse.BROKER_OPERATION_CANCELLED));
LocalBroadcaster.INSTANCE.broadcast(AuthenticationConstants.LocalBroadcasterAliases.RETURN_BROKER_INTERACTIVE_ACQUIRE_TOKEN_RESULT, fromBundle);
}
@Override
protected void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putParcelable(BROKER_INTENT, this.mBrokerInteractiveRequestIntent);
bundle.putBoolean(BROKER_INTENT_STARTED, this.mBrokerIntentStarted.booleanValue());
}
@Override
protected void onActivityResult(int i, int i2, Intent intent) {
String str = TAG + ":onActivityResult";
Logger.info(str, "Result received from Broker Request code: " + i + " Result code: " + i);
this.mBrokerResultReceived = true;
if (i2 == 2004 || i2 == 2001 || i2 == 2002) {
Logger.verbose(str, "Completing interactive request ");
PropertyBag fromBundle = PropertyBagUtil.fromBundle(intent.getExtras());
fromBundle.put(AuthenticationConstants.LocalBroadcasterFields.REQUEST_CODE, Integer.valueOf(AuthenticationConstants.UIRequest.BROKER_FLOW));
fromBundle.put(AuthenticationConstants.LocalBroadcasterFields.RESULT_CODE, Integer.valueOf(i2));
LocalBroadcaster.INSTANCE.broadcast(AuthenticationConstants.LocalBroadcasterAliases.RETURN_BROKER_INTERACTIVE_ACQUIRE_TOKEN_RESULT, fromBundle);
} else {
returnsExceptionOnActivityUnexpectedlyKilled();
}
finish();
}
}