DefaultSudoUserClient

class DefaultSudoUserClient(context: Context, namespace: String = "ids", logger: Logger = DefaultLogger.instance, config: JSONObject? = null, keyManager: KeyManagerInterface? = null, identityProvider: IdentityProvider? = null, apiClient: AWSAppSyncClient? = null, credentialsProvider: CognitoCredentialsProvider? = null, authUI: AuthUI? = null, idGenerator: IdGenerator = IdGenerateImpl(), databaseName: String = AndroidSQLiteStore.DEFAULT_DATABASE_NAME) : SudoUserClient

Default implementation of SudoUserClient interface.

Parameters

config

configuration parameters.

context

Android app context.

namespace

namespace to use for internal data and cryptographic keys. This should be unique per client per app to avoid name conflicts between multiple clients.

databaseName

database name to use for the exportable key store database.

logger

logger to use for logging messages.

keyManager

custom KeyManagerInterface implementation. Mainly used for unit testing (optional)

identityProvider

custom identity provider. Mainly used for unit testing (optional).

apiClient

custom API client. Mainly used for unit testing (optional).

credentialsProvider

custom credentials provider. Mainly used for unit testing (optional).

authUI

custom auth UI. Mainly used for unit testing (optional).

idGenerator

custom ID generator. Mainly used for unit testing (optional).

Constructors

Link copied to clipboard
constructor(context: Context, namespace: String = "ids", logger: Logger = DefaultLogger.instance, config: JSONObject? = null, keyManager: KeyManagerInterface? = null, identityProvider: IdentityProvider? = null, apiClient: AWSAppSyncClient? = null, credentialsProvider: CognitoCredentialsProvider? = null, authUI: AuthUI? = null, idGenerator: IdGenerator = IdGenerateImpl(), databaseName: String = AndroidSQLiteStore.DEFAULT_DATABASE_NAME)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun clearAuthTokens()

Clears cached authentication tokens.

Link copied to clipboard
open suspend override fun deregister()

De-registers a user.

Link copied to clipboard
open override fun deregisterSignInStatusObserver(id: String)

Deregisters an existing sign in status observer.

Link copied to clipboard
open override fun getAccessToken(): String?

Returns the access token cached from the last sign-in.

Link copied to clipboard
open override fun getCredentialsProvider(): CognitoCredentialsProvider

Returns a credentials provider that can be used for authenticating into various services provided by Sudo Platform.

Link copied to clipboard
open override fun getIdToken(): String?

Returns the ID token cached from the last sign-in.

Link copied to clipboard
open override fun getLogins(): Map<String, String>

Returns the logins to use for accessing other Sudo Platform services. You must be signed in to get logins.

Link copied to clipboard
open override fun getRefreshToken(): String?

Returns the refresh token cached from the last sign-in.

Link copied to clipboard
open override fun getRefreshTokenExpiry(): Date?

Returns the refresh token expiry cached from the last sign-in.

Link copied to clipboard
open override fun getSubject(): String?

Returns the subject of the user associated with this client. Note: This is an internal method used by other Sudo platform SDKs.

Link copied to clipboard
open override fun getTokenExpiry(): Date?

Returns the ID and access token expiry cached from the last sign-in.

Link copied to clipboard
open override fun getUserClaim(name: String): Any?

Returns the specified claim associated with the user's identity.

Link copied to clipboard
open override fun getUserName(): String?

Returns the user name associated with this client. The username maybe needed to contact the support team when diagnosing an issue related to a specific user.

Link copied to clipboard
open suspend override fun globalSignOut()

Signs out the user from all devices.

Link copied to clipboard
open override fun isRegistered(): Boolean

Indicates whether or not this client is registered with Sudo Platform backend.

Link copied to clipboard
open override fun isSignedIn(): Boolean

Indicates whether or not this client is signed in with Sudo Platform backend. The client is considered signed in if it cached valid ID and access tokens.

Link copied to clipboard
open override fun presentFederatedSignInUI(activity: Activity, callback: (SignInResult) -> Unit)

Presents the sign in UI for federated sign in using an external identity provider.

Link copied to clipboard
open override fun presentFederatedSignOutUI(callback: (ApiResult) -> Unit)

Presents the sign out UI for federated sign in using an external identity provider.

Link copied to clipboard
open override fun processFederatedSignInTokens(data: Uri, callback: (FederatedSignInResult) -> Unit)

Processes tokens from federated sign in via Android intent data pointed to by the specified URL. The tokens are passed to the app via a redirect URL with custom scheme mapped to the app.

Link copied to clipboard
open suspend override fun refreshTokens(refreshToken: String): AuthenticationTokens

Refresh the access and ID tokens using the refresh token.

Link copied to clipboard
open override fun registerSignInStatusObserver(id: String, observer: SignInStatusObserver)

Registers an observer for sign in status changes.

Link copied to clipboard
open suspend override fun registerWithAuthenticationProvider(authenticationProvider: AuthenticationProvider, registrationId: String?): String

Registers this client against the backend with an external authentication provider. Caller must implement AuthenticationProvider protocol to return appropriate authentication token required to authorize the registration request.

Link copied to clipboard
open suspend override fun registerWithGooglePlayIntegrity(packageName: String, deviceId: String, token: String, registrationId: String?): String

Registers this client against the backend with a Google Play Integrity token.

Link copied to clipboard
open override fun reset()

Removes all keys associated with this client and invalidates any cached authentication credentials.

Link copied to clipboard
open suspend override fun resetUserData()

Removes all data owned by the signed-in user from Sudo Platform Services without deregistering the user. Should only be used in tests.

Link copied to clipboard
open override fun setUserName(name: String)

Sets the user name associated with this client.

Link copied to clipboard
open suspend override fun signInWithAuthenticationProvider(authenticationProvider: AuthenticationProvider): AuthenticationTokens

Sign into the backend with an external authentication provider. Caller must implement AuthenticationProvider protocol to return the appropriate authentication token associated with the external identity registered with registerWithAuthenticationProvider.

Link copied to clipboard
open suspend override fun signInWithKey(): AuthenticationTokens

Sign into the backend using a private key. The client must have created a private/public key pair via one of the register methods.

Link copied to clipboard
open suspend override fun signOut()

Signs out the user from this device only.

Properties

Link copied to clipboard
open override val version: String

Checksum's for each file are generated and are used to create a checksum that is used when publishing to maven central. In order to retry a failed publish without needing to change any functionality, we need a way to generate a different checksum for the source code. We can change the value of this property which will generate a different checksum for publishing and allow us to retry. The value of version doesn't need to be kept up-to-date with the version of the code.