public class CognitoUserSession
extends java.lang.Object
Constructor and Description |
---|
CognitoUserSession(CognitoIdToken idToken,
CognitoAccessToken accessToken,
CognitoRefreshToken refreshToken)
Constructs a new Cognito session.
|
Modifier and Type | Method and Description |
---|---|
CognitoAccessToken |
getAccessToken()
Returns Access Token.
|
CognitoIdToken |
getIdToken()
Returns ID Token.
|
CognitoRefreshToken |
getRefreshToken()
Returns Refresh Token.
|
java.lang.String |
getUsername()
Returns username contained in this session.
|
boolean |
isValid()
Returns if the access and id tokens have not expired.
|
boolean |
isValidForThreshold()
Returns true if this session is valid for the threshold set in
CognitoIdentityProviderClientConfig.getRefreshThreshold() . |
public CognitoUserSession(CognitoIdToken idToken, CognitoAccessToken accessToken, CognitoRefreshToken refreshToken)
idToken
- REQUIRED: ID Token for this session.accessToken
- REQUIRED: Access Token for this session.refreshToken
- REQUIRED: Refresh Token.public CognitoIdToken getIdToken()
public CognitoAccessToken getAccessToken()
public CognitoRefreshToken getRefreshToken()
public boolean isValid()
public boolean isValidForThreshold()
CognitoIdentityProviderClientConfig.getRefreshThreshold()
.
Checks for the following conditions to determine if the session is valid:
1) Existence of an idToken
2) Existence of an accessToken
3) idToken is not expired
4) accessToken is not expiredCognitoIdentityProviderClientConfig.getRefreshThreshold()
seconds.public java.lang.String getUsername()
Reads the username from Access Tokens. Returns null on Exceptions - This would mean that the contained tokens are not parsable and hence are not valid.
Copyright © 2018 Amazon Web Services, Inc. All Rights Reserved.