public class AuthorizationManagementActivity
extends android.app.Activity
Stores state and handles events related to the authorization flow. The activity is
started by AuthorizationService.performAuthorizationRequest, and records all state pertinent to
the authorization request before invoking the authorization intent. It also functions
to control the back stack, ensuring that the authorization activity will not be reachable
via the back button after the flow completes.
The following diagram illustrates the operation of the activity:
Back Stack Towards Top
+------------------------------------------>
+------------+ +---------------+ +----------------+ +--------------+
| | (1) | | (2) | | (S1) | |
| Initiating +----------->| Authorization +----->| Authorization +----->| Redirect URI |
| Activity | | Management | | Activity | | Receiver |
| |<-----------+ Activity |<-----+ (e.g. browser) | | Activity |
| | (C2b, S3b) | | (C1) | | | |
+------------+ +-+---+---------+ +----------------+ +-------+------+
| | ^ |
| | | |
+-------+ | | (S2) |
| | +----------------------------------------------+
| |
| v (S3a)
(C2a) | +------------+
| | |
| | Completion |
| | Activity |
| | |
| +------------+
|
| +-------------+
| | |
+----->| Cancelation |
| Activity |
| |
+-------------+
The process begins with an activity requesting that an authorization flow be started,
using AuthorizationService.performAuthorizationRequest(net.openid.appauth.AuthorizationRequest, android.app.PendingIntent).
Step 1: Using an intent derived from createStartIntent(android.content.Context, net.openid.appauth.AuthorizationRequest, android.content.Intent, android.app.PendingIntent, android.app.PendingIntent), this activity is
started. The state delivered in this intent is recorded for future use.
Step 2: The authorization intent, typically a browser tab, is started. At this point, depending on user action, we will either end up in a “completion” flow (S) or “cancelation flow” (C).
Cancelation (C) flow:
Step C1: If the user presses the back button or otherwise causes the authorization activity to finish, the AuthorizationManagementActivity will be recreated or restarted.
Step C2a: If a cancellation PendingIntent was provided in the call to
AuthorizationService.performAuthorizationRequest(net.openid.appauth.AuthorizationRequest, android.app.PendingIntent), then this is
used to invoke a cancelation activity.
Step C2b: If no cancellation PendingIntent was provided (legacy behavior, or
AuthorizationManagementActivity was started with an intent from
AuthorizationService.getAuthorizationRequestIntent(net.openid.appauth.AuthorizationRequest, android.support.customtabs.CustomTabsIntent)), then the
AuthorizationManagementActivity simply finishes after calling Activity.setResult(int),
with Activity.RESULT_CANCELED, returning control to the activity above
it in the back stack (typically, the initiating activity).
Completion (S) flow:
Step S1: The authorization activity completes with a success or failure, and sends this
result to RedirectUriReceiverActivity.
Step S2: RedirectUriReceiverActivity extracts the forwarded data, and invokes
AuthorizationManagementActivity using an intent derived from
createResponseHandlingIntent(android.content.Context, android.net.Uri). This intent has flag CLEAR_TOP set, which will
result in both the authorization activity and RedirectUriReceiverActivity being
destroyed, if necessary, such that AuthorizationManagementActivity is once again at the
top of the back stack.
Step S3a: If this activity was invoked via
AuthorizationService.performAuthorizationRequest(net.openid.appauth.AuthorizationRequest, android.app.PendingIntent), then the pending intent provided
for completion of the authorization flow is invoked, providing the decoded
AuthorizationResponse or AuthorizationException as appropriate.
The AuthorizationManagementActivity finishes, removing itself from the back stack.
Step S3b: If this activity was invoked via an intent returned by
AuthorizationService.getAuthorizationRequestIntent(net.openid.appauth.AuthorizationRequest, android.support.customtabs.CustomTabsIntent), then this activity
calls Activity.setResult(int, Intent) with Activity.RESULT_OK
and a data intent containing the AuthorizationResponse or
AuthorizationException as appropriate.
The AuthorizationManagementActivity finishes, removing itself from the back stack.
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OKACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, FINGERPRINT_SERVICE, HARDWARE_PROPERTIES_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SHORTCUT_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE| Constructor and Description |
|---|
AuthorizationManagementActivity() |
| Modifier and Type | Method and Description |
|---|---|
static android.content.Intent |
createResponseHandlingIntent(android.content.Context context,
android.net.Uri responseUri)
Creates an intent to handle the completion of an authorization flow.
|
static android.content.Intent |
createStartForResultIntent(android.content.Context context,
AuthorizationRequest request,
android.content.Intent authIntent)
Creates an intent to start an authorization flow.
|
static android.content.Intent |
createStartIntent(android.content.Context context,
AuthorizationRequest request,
android.content.Intent authIntent,
android.app.PendingIntent completeIntent,
android.app.PendingIntent cancelIntent)
Creates an intent to start an authorization flow.
|
protected void |
onCreate(android.os.Bundle savedInstanceState) |
protected void |
onNewIntent(android.content.Intent intent) |
protected void |
onResume() |
protected void |
onSaveInstanceState(android.os.Bundle outState) |
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dismissKeyboardShortcutsHelper, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, enterPictureInPictureMode, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishAfterTransition, finishAndRemoveTask, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getContentScene, getContentTransitionManager, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMediaController, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getReferrer, getRequestedOrientation, getSearchEvent, getSystemService, getTaskId, getTitle, getTitleColor, getVoiceInteractor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isInMultiWindowMode, isInPictureInPictureMode, isLocalVoiceInteractionSupported, isTaskRoot, isVoiceInteraction, isVoiceInteractionRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityReenter, onActivityResult, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreate, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDestroy, onDetachedFromWindow, onEnterAnimationComplete, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLocalVoiceInteractionStarted, onLocalVoiceInteractionStopped, onLowMemory, onMenuItemSelected, onMenuOpened, onMultiWindowModeChanged, onNavigateUp, onNavigateUpFromChild, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPause, onPictureInPictureModeChanged, onPostCreate, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onProvideAssistContent, onProvideAssistData, onProvideKeyboardShortcuts, onProvideReferrer, onRequestPermissionsResult, onRestart, onRestoreInstanceState, onRestoreInstanceState, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onSearchRequested, onStart, onStateNotSaved, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onVisibleBehindCanceled, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, postponeEnterTransition, recreate, registerForContextMenu, releaseInstance, removeDialog, reportFullyDrawn, requestDragAndDropPermissions, requestPermissions, requestShowKeyboardShortcuts, requestVisibleBehind, requestWindowFeature, runOnUiThread, setActionBar, setContentTransitionManager, setContentView, setContentView, setContentView, setDefaultKeyMode, setEnterSharedElementCallback, setExitSharedElementCallback, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setMediaController, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTaskDescription, setTheme, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, setVrModeEnabled, shouldShowRequestPermissionRationale, shouldUpRecreateTask, showAssist, showDialog, showDialog, showLockTaskEscapeMessage, startActionMode, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startLocalVoiceInteraction, startLockTask, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startPostponedEnterTransition, startSearch, stopLocalVoiceInteraction, stopLockTask, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenuapplyOverrideConfiguration, attachBaseContext, getAssets, getResources, getThemebindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getSystemServiceName, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiverpublic static android.content.Intent createStartIntent(android.content.Context context,
AuthorizationRequest request,
android.content.Intent authIntent,
android.app.PendingIntent completeIntent,
android.app.PendingIntent cancelIntent)
Creates an intent to start an authorization flow.
context - the package context for the app.request - the authorization request which is to be sent.authIntent - the intent to be used to get authorization from the user.completeIntent - the intent to be sent when the flow completes.cancelIntent - the intent to be sent when the flow is canceled.public static android.content.Intent createStartForResultIntent(android.content.Context context,
AuthorizationRequest request,
android.content.Intent authIntent)
Creates an intent to start an authorization flow.
context - the package context for the app.request - the authorization request which is to be sent.authIntent - the intent to be used to get authorization from the user.public static android.content.Intent createResponseHandlingIntent(android.content.Context context,
android.net.Uri responseUri)
Creates an intent to handle the completion of an authorization flow. This restores the original AuthorizationManagementActivity that was created at the start of the flow.
context - the package context for the app.responseUri - the response URI, which carries the parameters describing the response.protected void onCreate(android.os.Bundle savedInstanceState)
onCreate in class android.app.Activityprotected void onResume()
onResume in class android.app.Activityprotected void onNewIntent(android.content.Intent intent)
onNewIntent in class android.app.Activityprotected void onSaveInstanceState(android.os.Bundle outState)
onSaveInstanceState in class android.app.Activity