For Babelfish Release 1.11.1.3

UserAuthentication Class

Represents a single user (who is hopefully logged in) and their aws cognito credentials. The code in this class is based on documentation and examples from the following sources. https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/cognito-authentication-extension.html https://github.com/aws/aws-sdk-net-extensions-cognito#authenticating-with-secure-remote-protocol-srp

Definition

Namespace: Scopos.BabelFish.Runtime.Authentication
Assembly: BabelFish (in BabelFish.dll) Version: 1.11.1.4+b1da393815f6638555a663d9a94167ecabea5695
C#
public class UserAuthentication
Inheritance
Object    UserAuthentication

Constructors

UserAuthentication(CognitoUser) 
UserAuthentication(String, String) Creates a new instance of UserAuthentication and attempts to authenticate the user (identified by their email) using their password. This flow also assumes logging on with a new Device and will save the DeviceKey and DeviceGroupKey to the private variables. The caller is responsible for verifying the device is legit. After the contructor returns, call InitializeAsync() to complete the constructor / initialziation process.
UserAuthentication(String, String, String, String, DateTime, DateTime) Constructs a new User Authentication instance. To complete the re-authentication process, user should call .RefreshedTokens(). After the contructor returns, call InitializeAsync() to complete the constructor / initialziation process.

Properties

AccessKey 
AccessToken 
CognitoUser 
Email Emailaddress the user uses to log in with. It is the same as the user's username
ExpirationTime 
IamCredentialsExpiration 
IdToken 
ImmutableCredentials 
IssuedTime 
RefreshToken 
SecretKey 
SessionToken 

Methods

CleanUpOldDevicesAsync Removes devices from the user, if they have not been used in the last 45 days.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GenerateIAMCredentialsAsync Generates the temporary IAM credentials for the logged in user. These would be AccessKey, SecretKey, and SessionToken. Invokes the GenerateIAMCredentialsSuccessful event on success, and GenerateIAMCredentialsFailed on failure. If the credentials do not need to be refreshed (have not expired yet), neither event is invoked.
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
GetUserIdAsync 
InitializeAsync To complete the Constructor process a number of Async calls need to be made. Because it is not possible (at least not wise) to call Async within a constructor this InitializaAsync() method is used to complete the process. It should be called immediatly after the Constructor. If InitializeAsync() is not called an exception InitializeAsyncNotCompletedException() will be thrown.
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
RefreshTokensAsync Attempts to refresh the user's cognito tokens. Invokes the RefreshTokensSuccessful when the tokens are refreshed. Invoked the RefreshTokensFailed when a failure happens (and then throws one of the Exceptions).
ToStringReturns a string that represents the current object.
(Inherited from Object)

Fields

OnGenerateIAMCredentialsFailed 
OnGenerateIAMCredentialsSuccessful 
OnRefreshTokensFailed Invoked when a previously authenticated user attempts to refresh their cognito tokens, but the process is unsuccessful.
OnRefreshTokensSuccessful Invoked when a already authenticated user has their Cognito tokens refreshed successfully.
OnUserAuthenticationFailed Invoked when a new instance of UserAuthentication is constructed using email and password, and the authentication into AWS failed.
OnUserAuthenticationSuccessful Invoked when a new instance of UserAuthentication is constructed using email and password, and the authentication into AWS is successful.

See Also