Class AuthActivity

  • All Implemented Interfaces:
    android.content.ComponentCallbacks, android.content.ComponentCallbacks2, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.LayoutInflater.Factory2, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback

    public class AuthActivity
    extends android.app.Activity
    This activity is used internally for authentication, but must be exposed both so that Android can launch it and for backwards compatibility.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  AuthActivity.SecurityProvider
      Provider of the local security needs of an AuthActivity.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ACTION_AUTHENTICATE_V1
      The Android action which the official Dropbox app will accept to authenticate a user.
      static java.lang.String ACTION_AUTHENTICATE_V2
      The Android action which the official Dropbox app will accept to authenticate a user.
      static java.lang.String AUTH_PATH_CONNECT
      The path for a successful callback with token (not the initial auth request).
      static int AUTH_VERSION
      The version of the API for the web-auth callback with token (not the initial auth request).
      static java.lang.String EXTRA_ACCESS_SECRET
      The extra that goes in an intent when returning from Dropbox auth to provide the user's access token secret, if auth succeeded.
      static java.lang.String EXTRA_ACCESS_TOKEN
      The extra that goes in an intent when returning from Dropbox auth to provide the user's access token, if auth succeeded.
      static java.lang.String EXTRA_ALREADY_AUTHED_UIDS
      Used for internal authentication.
      static java.lang.String EXTRA_AUTH_QUERY_PARAMS
      Used for internal authentication.
      static java.lang.String EXTRA_AUTH_STATE
      Used for internal authentication.
      static java.lang.String EXTRA_CALLING_CLASS
      Used for internal authentication.
      static java.lang.String EXTRA_CALLING_PACKAGE
      Used for internal authentication.
      static java.lang.String EXTRA_CONSUMER_KEY
      The extra that goes in an intent to provide your consumer key for Dropbox authentication.
      static java.lang.String EXTRA_CONSUMER_SIG
      Used for internal authentication.
      static java.lang.String EXTRA_DESIRED_UID
      Used for internal authentication.
      static java.lang.String EXTRA_EXPIRES_AT  
      static java.lang.String EXTRA_REFRESH_TOKEN  
      static java.lang.String EXTRA_SCOPE  
      static java.lang.String EXTRA_SESSION_ID
      Used for internal authentication.
      static java.lang.String EXTRA_UID
      The extra that goes in an intent when returning from Dropbox auth to provide the user's Dropbox UID, if auth succeeded.
      static android.content.Intent result
      Used internally.
      • Fields inherited from class android.app.Activity

        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_OK
      • Fields inherited from class android.content.Context

        ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
      • Fields inherited from interface android.content.ComponentCallbacks2

        TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
    • Constructor Summary

      Constructors 
      Constructor Description
      AuthActivity()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean checkAppBeforeAuth​(android.content.Context context, java.lang.String appKey, boolean alertUser)
      Check's the current app's manifest setup for authentication.
      static android.content.Intent makeIntent​(android.content.Context context, java.lang.String appKey, java.lang.String webHost, java.lang.String apiType)
      Create an intent which can be sent to this activity to start OAuth 2 authentication.
      static android.content.Intent makeIntent​(android.content.Context context, java.lang.String appKey, java.lang.String desiredUid, java.lang.String[] alreadyAuthedUids, java.lang.String sessionId, java.lang.String webHost, java.lang.String apiType)
      Create an intent which can be sent to this activity to start OAuth 2 authentication.
      protected void onCreate​(android.os.Bundle savedInstanceState)  
      protected void onNewIntent​(android.content.Intent intent)  
      protected void onResume()  
      protected void onSaveInstanceState​(android.os.Bundle outState)  
      protected void onTopResumedActivityChanged​(boolean onTop)
      AuthActivity is launched first time, or user didn't finish oauth/dauth flow but switched back to this activity.
      static void setSecurityProvider​(AuthActivity.SecurityProvider prov)
      Sets the SecurityProvider interface to use for all AuthActivity instances.
      • Methods inherited from class android.app.Activity

        addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityResult, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDestroy, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPause, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onRetainNonConfigurationInstance, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
      • Methods inherited from class android.view.ContextThemeWrapper

        attachBaseContext, getTheme, setTheme
      • Methods inherited from class android.content.ContextWrapper

        bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
      • Methods inherited from class android.content.Context

        getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EXTRA_CONSUMER_KEY

        public static final java.lang.String EXTRA_CONSUMER_KEY
        The extra that goes in an intent to provide your consumer key for Dropbox authentication. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_ACCESS_TOKEN

        public static final java.lang.String EXTRA_ACCESS_TOKEN
        The extra that goes in an intent when returning from Dropbox auth to provide the user's access token, if auth succeeded. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_ACCESS_SECRET

        public static final java.lang.String EXTRA_ACCESS_SECRET
        The extra that goes in an intent when returning from Dropbox auth to provide the user's access token secret, if auth succeeded. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_UID

        public static final java.lang.String EXTRA_UID
        The extra that goes in an intent when returning from Dropbox auth to provide the user's Dropbox UID, if auth succeeded. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_REFRESH_TOKEN

        public static final java.lang.String EXTRA_REFRESH_TOKEN
        See Also:
        Constant Field Values
      • EXTRA_EXPIRES_AT

        public static final java.lang.String EXTRA_EXPIRES_AT
        See Also:
        Constant Field Values
      • EXTRA_CONSUMER_SIG

        public static final java.lang.String EXTRA_CONSUMER_SIG
        Used for internal authentication. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_CALLING_PACKAGE

        public static final java.lang.String EXTRA_CALLING_PACKAGE
        Used for internal authentication. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_CALLING_CLASS

        public static final java.lang.String EXTRA_CALLING_CLASS
        Used for internal authentication. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_AUTH_STATE

        public static final java.lang.String EXTRA_AUTH_STATE
        Used for internal authentication. You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_DESIRED_UID

        public static final java.lang.String EXTRA_DESIRED_UID
        Used for internal authentication. Allows app to request a specific UID to auth against You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_ALREADY_AUTHED_UIDS

        public static final java.lang.String EXTRA_ALREADY_AUTHED_UIDS
        Used for internal authentication. Allows app to request array of UIDs that should not be auth'd You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_SESSION_ID

        public static final java.lang.String EXTRA_SESSION_ID
        Used for internal authentication. Allows app to transfer session info to/from DbApp You won't ever have to use this.
        See Also:
        Constant Field Values
      • EXTRA_AUTH_QUERY_PARAMS

        public static final java.lang.String EXTRA_AUTH_QUERY_PARAMS
        Used for internal authentication. You won't ever have to use this.
        See Also:
        Constant Field Values
      • ACTION_AUTHENTICATE_V1

        public static final java.lang.String ACTION_AUTHENTICATE_V1
        The Android action which the official Dropbox app will accept to authenticate a user. You won't ever have to use this.
        See Also:
        Constant Field Values
      • ACTION_AUTHENTICATE_V2

        public static final java.lang.String ACTION_AUTHENTICATE_V2
        The Android action which the official Dropbox app will accept to authenticate a user. You won't ever have to use this.
        See Also:
        Constant Field Values
      • AUTH_VERSION

        public static final int AUTH_VERSION
        The version of the API for the web-auth callback with token (not the initial auth request).
        See Also:
        Constant Field Values
      • AUTH_PATH_CONNECT

        public static final java.lang.String AUTH_PATH_CONNECT
        The path for a successful callback with token (not the initial auth request).
        See Also:
        Constant Field Values
      • result

        public static android.content.Intent result
        Used internally.
    • Constructor Detail

      • AuthActivity

        public AuthActivity()
    • Method Detail

      • makeIntent

        public static android.content.Intent makeIntent​(android.content.Context context,
                                                        java.lang.String appKey,
                                                        java.lang.String webHost,
                                                        java.lang.String apiType)
        Create an intent which can be sent to this activity to start OAuth 2 authentication.
        Parameters:
        context - the source context
        appKey - the consumer key for the app
        webHost - the host to use for web authentication, or null for the default
        apiType - an identifier for the type of API being supported, or null for the default
        Returns:
        a newly created intent.
      • makeIntent

        public static android.content.Intent makeIntent​(android.content.Context context,
                                                        java.lang.String appKey,
                                                        java.lang.String desiredUid,
                                                        java.lang.String[] alreadyAuthedUids,
                                                        java.lang.String sessionId,
                                                        java.lang.String webHost,
                                                        java.lang.String apiType)
        Create an intent which can be sent to this activity to start OAuth 2 authentication.
        Parameters:
        context - the source context
        appKey - the consumer key for the app
        desiredUid - Encourage user to authenticate account defined by this uid. (note that user still can authenticate other accounts). May be null if no uid desired.
        alreadyAuthedUids - Array of any other uids currently authenticated with this app. May be null if no uids previously authenticated. Authentication screen will encourage user to not authorize these user accounts. (note that user may still authorize the accounts).
        sessionId - The SESSION_ID Extra on an OpenWith intent. null if dAuth is being launched outside of OpenWith flow
        webHost - the host to use for web authentication, or null for the default
        apiType - an identifier for the type of API being supported, or null for the default
        Returns:
        a newly created intent.
      • checkAppBeforeAuth

        public static boolean checkAppBeforeAuth​(android.content.Context context,
                                                 java.lang.String appKey,
                                                 boolean alertUser)
        Check's the current app's manifest setup for authentication. If the manifest is incorrect, an exception will be thrown. If another app on the device is conflicting with this one, the user will (optionally) be alerted and false will be returned.
        Parameters:
        context - the app context
        appKey - the consumer key for the app
        alertUser - whether to alert the user for the case where multiple apps are conflicting.
        Returns:
        true if this app is properly set up for authentication.
      • setSecurityProvider

        public static void setSecurityProvider​(AuthActivity.SecurityProvider prov)
        Sets the SecurityProvider interface to use for all AuthActivity instances. If set to null (or never set at all), default java.security providers will be used instead.

        You shouldn't need to use this method directly in your app. Instead, simply configure java.security's providers to match your preferences.

        Parameters:
        prov - the new SecurityProvider interface.
      • onCreate

        protected void onCreate​(android.os.Bundle savedInstanceState)
        Overrides:
        onCreate in class android.app.Activity
      • onSaveInstanceState

        protected void onSaveInstanceState​(android.os.Bundle outState)
        Overrides:
        onSaveInstanceState in class android.app.Activity
      • onResume

        protected void onResume()
        Overrides:
        onResume in class android.app.Activity
      • onTopResumedActivityChanged

        protected void onTopResumedActivityChanged​(boolean onTop)
        AuthActivity is launched first time, or user didn't finish oauth/dauth flow but switched back to this activity. (hit back button) If DAuth/Browser Auth succeeded, this flow should finish through onNewIntent() instead of onResume(). NOTE: Although Android Studio doesn't think this overrides a method, it actually overrides onTopResumedActivityChanged() introduced in Android level 29. See: https://developer.android.com/reference/android/app/Activity#onTopResumedActivityChanged(boolean)
      • onNewIntent

        protected void onNewIntent​(android.content.Intent intent)
        Overrides:
        onNewIntent in class android.app.Activity