274 lines
		
	
	
		
			8.7 KiB
		
	
	
	
		
			Smali
		
	
	
	
	
	
			
		
		
	
	
			274 lines
		
	
	
		
			8.7 KiB
		
	
	
	
		
			Smali
		
	
	
	
	
	
| .class public Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;
 | |
| .super Ljava/lang/Object;
 | |
| .source "CognitoUserSession.java"
 | |
| 
 | |
| 
 | |
| # static fields
 | |
| .field private static final SECS_CONVERSION:I = 0x3e8
 | |
| 
 | |
| .field private static final TAG:Ljava/lang/String; = "CognitoUserSession"
 | |
| 
 | |
| 
 | |
| # instance fields
 | |
| .field private final accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
| .field private final idToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;
 | |
| 
 | |
| .field private final refreshToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoRefreshToken;
 | |
| 
 | |
| 
 | |
| # direct methods
 | |
| .method public static constructor <clinit>()V
 | |
|     .locals 0
 | |
| 
 | |
|     return-void
 | |
| .end method
 | |
| 
 | |
| .method public constructor <init>(Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoRefreshToken;)V
 | |
|     .locals 0
 | |
| 
 | |
|     .line 1
 | |
|     invoke-direct {p0}, Ljava/lang/Object;-><init>()V
 | |
| 
 | |
|     .line 2
 | |
|     iput-object p1, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->idToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;
 | |
| 
 | |
|     .line 3
 | |
|     iput-object p2, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
|     .line 4
 | |
|     iput-object p3, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->refreshToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoRefreshToken;
 | |
| 
 | |
|     return-void
 | |
| .end method
 | |
| 
 | |
| 
 | |
| # virtual methods
 | |
| .method public getAccessToken()Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
|     .locals 1
 | |
| 
 | |
|     .line 1
 | |
|     iget-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
|     return-object v0
 | |
| .end method
 | |
| 
 | |
| .method public getIdToken()Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;
 | |
|     .locals 1
 | |
| 
 | |
|     .line 1
 | |
|     iget-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->idToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;
 | |
| 
 | |
|     return-object v0
 | |
| .end method
 | |
| 
 | |
| .method public getRefreshToken()Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoRefreshToken;
 | |
|     .locals 1
 | |
| 
 | |
|     .line 1
 | |
|     iget-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->refreshToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoRefreshToken;
 | |
| 
 | |
|     return-object v0
 | |
| .end method
 | |
| 
 | |
| .method public getUsername()Ljava/lang/String;
 | |
|     .locals 2
 | |
| 
 | |
|     .line 1
 | |
|     iget-object v0, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
|     const/4 v1, 0x0
 | |
| 
 | |
|     if-eqz v0, :cond_0
 | |
| 
 | |
|     .line 2
 | |
|     :try_start_0
 | |
|     invoke-virtual {v0}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;->getUsername()Ljava/lang/String;
 | |
| 
 | |
|     move-result-object v0
 | |
|     :try_end_0
 | |
|     .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
 | |
| 
 | |
|     return-object v0
 | |
| 
 | |
|     :catch_0
 | |
|     :cond_0
 | |
|     return-object v1
 | |
| .end method
 | |
| 
 | |
| .method public isValid()Z
 | |
|     .locals 4
 | |
| 
 | |
|     .line 1
 | |
|     new-instance v0, Ljava/util/Date;
 | |
| 
 | |
|     invoke-direct {v0}, Ljava/util/Date;-><init>()V
 | |
| 
 | |
|     const/4 v1, 0x0
 | |
| 
 | |
|     .line 2
 | |
|     :try_start_0
 | |
|     iget-object v2, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->idToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;
 | |
| 
 | |
|     if-nez v2, :cond_0
 | |
| 
 | |
|     .line 3
 | |
|     sget-object v0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->TAG:Ljava/lang/String;
 | |
| 
 | |
|     const-string v2, "CognitoUserSession is not valid because idToken is null."
 | |
| 
 | |
|     invoke-static {v0, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
 | |
| 
 | |
|     return v1
 | |
| 
 | |
|     .line 4
 | |
|     :cond_0
 | |
|     iget-object v3, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
|     if-nez v3, :cond_1
 | |
| 
 | |
|     .line 5
 | |
|     sget-object v0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->TAG:Ljava/lang/String;
 | |
| 
 | |
|     const-string v2, "CognitoUserSession is not valid because accessToken is null."
 | |
| 
 | |
|     invoke-static {v0, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
 | |
| 
 | |
|     return v1
 | |
| 
 | |
|     .line 6
 | |
|     :cond_1
 | |
|     invoke-virtual {v2}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;->getExpiration()Ljava/util/Date;
 | |
| 
 | |
|     move-result-object v2
 | |
| 
 | |
|     invoke-virtual {v0, v2}, Ljava/util/Date;->before(Ljava/util/Date;)Z
 | |
| 
 | |
|     move-result v2
 | |
| 
 | |
|     iget-object v3, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
|     .line 7
 | |
|     invoke-virtual {v3}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;->getExpiration()Ljava/util/Date;
 | |
| 
 | |
|     move-result-object v3
 | |
| 
 | |
|     invoke-virtual {v0, v3}, Ljava/util/Date;->before(Ljava/util/Date;)Z
 | |
| 
 | |
|     move-result v0
 | |
|     :try_end_0
 | |
|     .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
 | |
| 
 | |
|     and-int/2addr v0, v2
 | |
| 
 | |
|     return v0
 | |
| 
 | |
|     :catch_0
 | |
|     return v1
 | |
| .end method
 | |
| 
 | |
| .method public isValidForThreshold()Z
 | |
|     .locals 7
 | |
| 
 | |
|     const/4 v0, 0x0
 | |
| 
 | |
|     .line 1
 | |
|     :try_start_0
 | |
|     iget-object v1, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->idToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;
 | |
| 
 | |
|     if-nez v1, :cond_0
 | |
| 
 | |
|     .line 2
 | |
|     sget-object v1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->TAG:Ljava/lang/String;
 | |
| 
 | |
|     const-string v2, "CognitoUserSession is not valid because idToken is null."
 | |
| 
 | |
|     invoke-static {v1, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
 | |
| 
 | |
|     return v0
 | |
| 
 | |
|     .line 3
 | |
|     :cond_0
 | |
|     iget-object v1, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
|     if-nez v1, :cond_1
 | |
| 
 | |
|     .line 4
 | |
|     sget-object v1, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->TAG:Ljava/lang/String;
 | |
| 
 | |
|     const-string v2, "CognitoUserSession is not valid because accessToken is null."
 | |
| 
 | |
|     invoke-static {v1, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
 | |
| 
 | |
|     return v0
 | |
| 
 | |
|     .line 5
 | |
|     :cond_1
 | |
|     invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
 | |
| 
 | |
|     move-result-wide v1
 | |
| 
 | |
|     .line 6
 | |
|     invoke-static {}, Lcom/amazonaws/SDKGlobalConfiguration;->getGlobalTimeOffset()I
 | |
| 
 | |
|     move-result v3
 | |
| 
 | |
|     mul-int/lit16 v3, v3, 0x3e8
 | |
| 
 | |
|     int-to-long v3, v3
 | |
| 
 | |
|     sub-long/2addr v1, v3
 | |
| 
 | |
|     .line 7
 | |
|     iget-object v3, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->idToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;
 | |
| 
 | |
|     invoke-virtual {v3}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoIdToken;->getExpiration()Ljava/util/Date;
 | |
| 
 | |
|     move-result-object v3
 | |
| 
 | |
|     invoke-virtual {v3}, Ljava/util/Date;->getTime()J
 | |
| 
 | |
|     move-result-wide v3
 | |
| 
 | |
|     sub-long/2addr v3, v1
 | |
| 
 | |
|     .line 8
 | |
|     iget-object v5, p0, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUserSession;->accessToken:Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;
 | |
| 
 | |
|     invoke-virtual {v5}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/tokens/CognitoAccessToken;->getExpiration()Ljava/util/Date;
 | |
| 
 | |
|     move-result-object v5
 | |
| 
 | |
|     invoke-virtual {v5}, Ljava/util/Date;->getTime()J
 | |
| 
 | |
|     move-result-wide v5
 | |
| 
 | |
|     sub-long/2addr v5, v1
 | |
| 
 | |
|     .line 9
 | |
|     invoke-static {}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/util/CognitoIdentityProviderClientConfig;->getRefreshThreshold()J
 | |
| 
 | |
|     move-result-wide v1
 | |
| 
 | |
|     cmp-long v1, v3, v1
 | |
| 
 | |
|     if-lez v1, :cond_2
 | |
| 
 | |
|     .line 10
 | |
|     invoke-static {}, Lcom/amazonaws/mobileconnectors/cognitoidentityprovider/util/CognitoIdentityProviderClientConfig;->getRefreshThreshold()J
 | |
| 
 | |
|     move-result-wide v1
 | |
|     :try_end_0
 | |
|     .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
 | |
| 
 | |
|     cmp-long v1, v5, v1
 | |
| 
 | |
|     if-lez v1, :cond_2
 | |
| 
 | |
|     const/4 v0, 0x1
 | |
| 
 | |
|     :catch_0
 | |
|     :cond_2
 | |
|     return v0
 | |
| .end method
 |