Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Update clearAccessToken method #374

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@ public void onAccessTokenAvailable(String accessToken, String refreshToken, long
* Clear the access token, forcing the next request to obtain a new one.
*/
public void clearAccessToken() {
privateTokens.clear();
privateTokens.clearAccessToken();
}

/**
* Clears the access token and refresh token, leaving the ID token, if present.
*/
public void clearAccessAndRefreshTokens() {
privateTokens.clear();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ private String findAccessToken(MssoContext mssoContext, MAGInternalRequest reque
} else {
accessToken = null;
}
}

String refreshToken = mssoContext.getRefreshToken();
if (refreshToken != null) {
accessToken = obtainAccessTokenUsingRefreshToken(mssoContext, refreshToken);
}
String refreshToken = mssoContext.getRefreshToken();
if (refreshToken != null) {
accessToken = obtainAccessTokenUsingRefreshToken(mssoContext, refreshToken);
}

if (accessToken != null)
return accessToken;
if (accessToken != null) {
return accessToken;
}

// Obtain an access token from the token server.
Expand Down Expand Up @@ -258,7 +259,7 @@ private String obtainAccessTokenUsingRefreshToken(MssoContext mssoContext, Strin

if(tse.getResponse()!= null){
//The access token and refresh token are no longer valid.
mssoContext.clearAccessToken();
mssoContext.clearAccessAndRefreshTokens();
}
accessToken = null;
if (DEBUG) Log.w(TAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void processRequest(MssoContext mssoContext, RequestInfo request) {
if (revokeRequest != null) {
MAS.invoke(OAuthClientUtil.getRevokeRequest(), null);
}
mssoContext.clearAccessToken();
mssoContext.clearAccessAndRefreshTokens();
throw new SecureLockException("The session is currently locked.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public InvalidClientCredentialException(Throwable throwable) {

@Override
public void recover(MssoContext context) {
context.clearAccessToken();
context.clearAccessAndRefreshTokens();
context.clearClientCredentials();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public interface OAuthTokenContainer {
*/
long getExpiry();

void clearAccessToken();

void clear();

void clearAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public long getExpiry() {
}
}

@Override
public void clearAccessToken() {
storage.remove(getKey(KEY.PREF_ACCESS_TOKEN.name()));
storage.remove(getKey(KEY.PREF_EXPIRY_UNIXTIME.name()));
}

@Override
public void clear() {
for (KEY k : KEY.values()) {
Expand Down