Context manager
The Context Manager simplifies the usage of complex SDK functions by reducing the number of parameters required when setting the operation context, authentication tokens, and other session data.
All the values that are provided to the context manager are automatically stored in secure storage.
Set operation context
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
sdk.contextManager().setOperationContext(
userId = USER_ID,
certificateChain = USER_CERTIFICATE_CHAIN_LIST,
keyPair = KEY_PAIR,
isKeyPairVerified = IS_KEY_PAIR_VERIFIED
)
sdk.contextManager().setOperationContext(USER_ID, USER_CERTIFICATE_CHAIN_LIST, KEY_PAIR, IS_KEY_PAIR_VERIFIED);
sdk.contextManager().setOperationContext(
userId: USER_ID,
certificateChain: USER_CERTIFICATE_CHAIN_LIST,
publicKey: PUBLIC_KEY,
privateKey: PRIVATE_KEY,
isKeyPairVerified: IS_KEY_PAIR_VERIFIED
)
sdk.contextManager().setOperationContext(
"USER_ID",
USER_CERTIFICATE_CHAIN_LIST,
PUBLIC_KEY,
PRIVATE_KEY
);
sdk.GetContextManager().SetOperationContext(
userId: USER_ID,
certificateChain: USER_CERTIFICATE_CHAIN,
publicKey: PUBLIC_KEY,
privateKey: PRIVATE_KEY
);
sdk.contextManager.set_operation_context(
"USER_ID",
"USER_CERTIFICATE_CHAIN_AS_STRING",
"BASE64_PUBLIC_KEY",
"BASE64_PRIVATE_KEY"
)
Get Context State
Checks the state of the context by verifying that the auth token is valid, the key pair is valid and verified, and the certificate chain is valid. When checkServerInvalidation is set to true, it also checks if the auth token has been invalidated on the backend. This requires a network request. When checkServerInvalidation is false, this server check is skipped, meaning the auth token might be accepted even if it has been invalidated.
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
// Returns a ContextState
val result = sdk.contextManager().getContextState(true)
// Returns a CompletableFuture<ContextState>
var result = sdk.contextManager().getContextStateAsync(true);
// Returns a ContextState asynchronously
let result = await sdk.contextManager().getContextState(checkServerInvalidation: true)
// Returns a Promise<string>
const result = await sdk.contextManager().getContextState(true);
// Returns a Task<ContextState>
var result = await sdk.GetContextManager().GetContextState(checkServerInvalidation: true);
# Returns a Future[SimpleNamespace]
result = await sdk.contextManager.get_context_state(True)
Is certificate chain invalid or expired
Checks if the current certificate chain from the context is invalid or expired (we consider it expired if it will expire within the next 7 days).
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
val result = sdk.contextManager().isCertificateChainInvalidOrExpired()
var result = sdk.contextManager().isCertificateChainInvalidOrExpired();
let result = sdk.contextManager().isCertificateChainInvalidOrExpired()
const result = sdk.contextManager().isCertificateChainInvalidOrExpired();
var result = sdk.GetContextManager().IsCertificateChainInvalidOrExpired();
result = sdk.contextManager.is_certificate_chain_invalid_or_expired()
Is key pair valid
Checks if the current key pair from the context is valid.
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
val result = sdk.contextManager().isKeyPairValid()
var result = sdk.contextManager().isKeyPairValid();
let result = sdk.contextManager().isKeyPairValid()
const result = sdk.contextManager().isKeyPairValid();
var result = sdk.GetContextManager().IsKeyPairValid();
result = sdk.contextManager.is_key_pair_valid()
Is key pair verified
Checks if the current key pair from the context has been verified.
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
val result = sdk.contextManager().isKeyPairVerified()
var result = sdk.contextManager().isKeyPairVerified();
let result = sdk.contextManager().isKeyPairVerified()
const result = sdk.contextManager().isKeyPairVerified();
var result = sdk.GetContextManager().IsKeyPairVerified();
result = sdk.contextManager.is_key_pair_verified()
Set cloud auth token
If the SDK was initialized without an authentication token, you can provide or update the token using this function.
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
sdk.contextManager().setCloudAuthToken("AUTH_TOKEN")
sdk.contextManager().setCloudAuthToken("AUTH_TOKEN");
sdk.contextManager().setCloudAuthToken(token: "AUTH_TOKEN")
sdk.contextManager().setCloudAuthToken("AUTH_TOKEN");
sdk.GetContextManager().SetCloudAuthToken("AUTH_TOKEN");
sdk.contextManager.set_cloud_auth_token("AUTH_TOKEN")
Get cloud auth token
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
val token = sdk.contextManager().getCloudAuthToken()
var token = sdk.contextManager().getCloudAuthToken();
let token = sdk.contextManager().getCloudAuthToken()
const token = sdk.contextManager().getCloudAuthToken();
var token = sdk.GetContextManager().GetCloudAuthToken();
token = sdk.contextManager.get_cloud_auth_token()
Is cloud auth token invalid or expired
Checks if the current cloud auth token from the context is invalid, expired (we consider it expired if it will expire within the next 24 hours) or invalidated. When checkServerInvalidation is set to true, it also checks if the auth token has been invalidated on the backend. This requires a network request. When checkServerInvalidation is false, this server check is skipped, meaning the auth token might be accepted even if it has been invalidated on the server.
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
// Returns a Boolean
val result = sdk.contextManager().isCloudAuthTokenInvalidOrExpired(true)
// Returns a CompletableFuture<Boolean>
var result = sdk.contextManager().isCloudAuthTokenInvalidOrExpiredAsync(true);
// Returns a Bool asynchronously
let result = await sdk.contextManager().isCloudAuthTokenInvalidOrExpired(checkServerInvalidation: true)
// Returns a Promise<boolean>
const result = await sdk.contextManager().isCloudAuthTokenInvalidOrExpired(true);
// Returns a Task<bool>
var result = await sdk.GetContextManager().IsCloudAuthTokenInvalidOrExpired(checkServerInvalidation: true);
# Returns a Future[SimpleNamespace]
result = await sdk.contextManager.is_cloud_auth_token_invalid_or_expired(True)
Set cloud refresh token
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
sdk.contextManager().setCloudRefreshToken("REFRESH_TOKEN")
sdk.contextManager().setCloudRefreshToken("REFRESH_TOKEN");
sdk.contextManager().setCloudRefreshToken(token: "REFRESH_TOKEN")
sdk.contextManager().setCloudRefreshToken("REFRESH_TOKEN");
sdk.GetContextManager().SetCloudRefreshToken("REFRESH_TOKEN");
sdk.contextManager.set_cloud_refresh_token("REFRESH_TOKEN")
Get cloud refresh token
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
val token = sdk.contextManager().getCloudRefreshToken()
var token = sdk.contextManager().getCloudRefreshToken();
let token = sdk.contextManager().getCloudRefreshToken()
const token = sdk.contextManager().getCloudRefreshToken();
var token = sdk.GetContextManager().GetCloudRefreshToken();
token = sdk.contextManager.get_cloud_refresh_token()
Set fusion auth token
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
sdk.contextManager().setFusionAuthToken("FUSION_AUTH_TOKEN")
sdk.contextManager().setFusionAuthToken("FUSION_AUTH_TOKEN");
sdk.contextManager().setFusionAuthToken(token: "FUSION_AUTH_TOKEN")
sdk.contextManager().setFusionAuthToken("FUSION_AUTH_TOKEN");
sdk.GetContextManager().SetFusionAuthToken("FUSION_AUTH_TOKEN");
sdk.contextManager.set_fusion_auth_token("FUSION_AUTH_TOKEN")
Get fusion auth token
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
val token = sdk.contextManager().getFusionAuthToken()
var token = sdk.contextManager().getFusionAuthToken();
let token = sdk.contextManager().getFusionAuthToken()
const token = sdk.contextManager().getFusionAuthToken();
var token = sdk.GetContextManager().GetFusionAuthToken();
token = sdk.contextManager.get_fusion_auth_token()
Clear context
This function removes all stored context fields from the secure storage.
- Kotlin
- Java
- Swift
- JavaScript
- C#
- Python
sdk.contextManager().clearContext()
sdk.contextManager().clearContext();
sdk.contextManager().clearContext()
sdk.contextManager().clearContext();
sdk.GetContextManager().ClearContext();
sdk.contextManager.clear_context()