-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from auth0/save-refreshed-credentials
Make Credential Managers save the refreshed value
- Loading branch information
Showing
14 changed files
with
257 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
auth0/src/main/java/com/auth0/android/request/internal/GsonProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
package com.auth0.android.request.internal; | ||
|
||
import android.support.annotation.VisibleForTesting; | ||
|
||
import com.auth0.android.result.Credentials; | ||
import com.auth0.android.result.UserProfile; | ||
import com.auth0.android.util.JsonRequiredTypeAdapterFactory; | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
|
||
public abstract class GsonProvider { | ||
|
||
static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; | ||
|
||
public static Gson buildGson() { | ||
return new GsonBuilder() | ||
.registerTypeAdapterFactory(new JsonRequiredTypeAdapterFactory()) | ||
.registerTypeAdapter(UserProfile.class, new UserProfileDeserializer()) | ||
.registerTypeAdapter(Credentials.class, new CredentialsDeserializer()) | ||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") | ||
.setDateFormat(DATE_FORMAT) | ||
.create(); | ||
} | ||
|
||
@VisibleForTesting | ||
static String formatDate(Date date) { | ||
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US); | ||
return sdf.format(date); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
auth0/src/test/java/com/auth0/android/request/internal/CredentialsDeserializerMock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.auth0.android.request.internal; | ||
|
||
import com.auth0.android.result.Credentials; | ||
import com.auth0.android.result.CredentialsMock; | ||
|
||
import java.util.Date; | ||
|
||
class CredentialsDeserializerMock extends CredentialsDeserializer { | ||
|
||
@Override | ||
long getCurrentTimeInMillis() { | ||
return CredentialsMock.CURRENT_TIME_MS; | ||
} | ||
|
||
@Override | ||
Credentials createCredentials(String idToken, String accessToken, String type, String refreshToken, Date expiresAt, String scope) { | ||
return new CredentialsMock(idToken, accessToken, type, refreshToken, expiresAt, scope); | ||
} | ||
} |
Oops, something went wrong.