AWSSAMLSignInProvider Class Reference

Inherits from NSObject
Conforms to AWSSignInProvider
Declared in AWSSAMLSignInProvider.h
AWSSAMLSignInProvider.m

Other Methods

– handleLoginWithTaskCompletionSource:

This method will be called when loginWithSignInProvider is invoked from AWSIdentityManager. Developer is expected to call setResult on taskCompletionSource with the SAML login token on a successful login, or setError when the login is cancelled or encounters an error.

- (void)handleLoginWithTaskCompletionSource:(AWSTaskCompletionSource<NSString*> *)taskCompletionSource

Parameters

taskCompletionSource

the AWSTaskCompletionSource object which is used to call setResult or setError

Discussion

The token internally is stored in the keychain store, and a flag is set in NSUserDefaults indicating the user is logged in using this SAML sign-in provider.

Objective-C - (void)handleLoginWithTaskCompletionSource:(AWSTaskCompletionSource )taskCompletionSource { // handle login logic if(loginSuccessful) { [taskCompletionSource setResult:@“SuccessfullyGeneratedToken”]; } else { [taskCompletionSource setError:error]; } }

Swift func handleLogicWithTaskCompletionSource(taskCompletionSource: AWSTaskCompletionSource) { if(loginSuccessful) { taskCompletionSource.setResult(“SuccessfullyGeneratedToken”) } else { taskCompletionSource.setError(error) } }

Declared In

AWSSAMLSignInProvider.h

– fetchLatestToken

This method is called whenver the cognito credentials are refreshed or when app is loaded from background state / closed state. The previous saved token can be fetched using fetchStoredToken, and if it is valid the same can be returned without refreshing.

- (AWSTask<NSString*> *)fetchLatestToken

Return Value

an instance of AWSTask. task.result should contain the valid token in case of successful token fetch, or task.error should be set

Declared In

AWSSAMLSignInProvider.h

– interceptApplication:didFinishLaunchingWithOptions:

Passes parameters used to launch the application to the current identity provider. It can be used to complete the user sign-in call flow, which uses a browser to get information from the user, directly. The current sign-in provider will be set to nil if the sign-in provider is not registered using registerAWSSignInProvider:forKey method of AWSSignInProviderFactory class.

- (BOOL)interceptApplication:(UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions

Parameters

application

application

launchOptions

options used to launch the application

Return Value

true if this call handled the operation

Declared In

AWSSAMLSignInProvider.h

– interceptApplication:openURL:sourceApplication:annotation:

Passes parameters used to launch the application to the current identity provider. It can be used to complete the user sign-in call flow, which uses a browser to get information from the user, directly. The developer should store a reference to the taskCompletionSource instance provided by the handleLoginWithTaskCompletionSouce method to set the result with successfully retrieved token.

- (BOOL)interceptApplication:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation

Parameters

application

application

url

url used to open the application

sourceApplication

source application

annotation

annotation

Return Value

true if this call handled the operation

Declared In

AWSSAMLSignInProvider.h

– setUserName:

Sets the userName value of the signed-in user into a persistent store. Should be called on a successful login to set the user name which is used by AWSIdentityManager.

- (void)setUserName:(NSString *)userName

Parameters

userName

the user name of the signed-in user

Declared In

AWSSAMLSignInProvider.h

– setImageURL:

Sets the imageURL value of the signed-in user into a persistent store. Should be called on a successful login to set the user name which is used by AWSIdentityManager.

- (void)setImageURL:(NSURL *)imageURL

Parameters

imageURL

the image URL for a picture of the signed-in user

Declared In

AWSSAMLSignInProvider.h

– setViewControllerForSignIn:

Can be used to store a reference of teh view controller from which loginWithSignInProvider is invoked by AWSIdentityManager

- (void)setViewControllerForSignIn:(UIViewController *)signInViewController

Parameters

signInViewController

the signInViewController object whose reference needs to be stored

Declared In

AWSSAMLSignInProvider.h

– getViewControllerForSignIn

This method returns the view controller whose reference was stored using setViewControllerForSignIn

- (UIViewController *)getViewControllerForSignIn

Return Value

the stored view controller if set, else nil

Declared In

AWSSAMLSignInProvider.h

– fetchStoredToken

Returns the token stored in keychain as-is (without refreshing)

- (NSString *)fetchStoredToken

Return Value

the token if available in keychain, else nil

Declared In

AWSSAMLSignInProvider.h

– isLoggedIn

Determines if the user is logged in based on the token available in keychain and if the login flag is set internally.

- (BOOL)isLoggedIn

Return Value

YES if the user is logged in using SAML sign-in provider instance

Declared In

AWSSAMLSignInProvider.h

Other Methods

– userName

The User Name of a user.

- (NSString *)userName

Declared In

AWSSignInProvider.h

– imageURL

The URL for profile image of a user.

- (NSURL *)imageURL

Declared In

AWSSignInProvider.h

– reloadSession

The handler method for managing the session reload for the Sign-In Provider.

- (void)reloadSession

Declared In

AWSSignInProvider.h

– setCachedLoginFlag

Call this method on a successful login. This method should store a flag in persistent storage which determines if the user has signed-in using this sign-in provider. This method is called by AWSIdentityManager on interceptApplication:didFinishLaunchingWithOptions method to set the current sign-in provider.

- (void)setCachedLoginFlag

Declared In

AWSSignInProvider.h

– isCachedLoginFlagSet

Fetches the status of the cached login flag set using setCachedLoginFlag.

- (BOOL)isCachedLoginFlagSet

Return Value

YES if the setCachedLoginFlag is set.

Declared In

AWSSignInProvider.h

– clearCachedLoginFlag

Clears the cached login flag. This method should be called during logout to clear the stored flag.

- (void)clearCachedLoginFlag

Declared In

AWSSignInProvider.h

– login:

The login handler method for the Sign-In Provider. The completionHandler will bubble back errors to the developers.

- (void)login:(AWSIdentityManagerCompletionBlock)completionHandler

Declared In

AWSSignInProvider.h

– logout

The logout handler method for the Sign-In Provider.

- (void)logout

Declared In

AWSSignInProvider.h

Extension Methods

  userName

The User Name of a user.

@property (strong, nonatomic) NSString *userName

Declared In

AWSSignInProvider.h

  imageURL

The URL for profile image of a user.

@property (strong, nonatomic) NSURL *imageURL

Declared In

AWSSignInProvider.h