private boolean verifyToken(TokenTable tokenInfo, String accessToken) {
- if (checkTokenInDB(tokenInfo, accessToken)) {
- if (tokenInfo.getExpiredtime() == Constants.TOKEN_INFINITE) {
- return true;
- }
- if (checkExpiredTime(tokenInfo)) {
- return true;
- }
+ if (!checkAccessTokenInDB(tokenInfo, accessToken)) {
+ return false;
}
- return false;
+
+ if (tokenInfo.getExpiredtime() != Constants.TOKEN_INFINITE
+ && !checkExpiredTime(tokenInfo)) {
+ return false;
+ }
+
+ return true;
}
- private boolean checkTokenInDB(TokenTable tokenInfo, String token) {
+ private boolean checkRefreshTokenInDB(TokenTable tokenInfo, String token) {
+ if (tokenInfo.getRefreshtoken() == null) {
+ Log.w("Refreshtoken doesn't exist");
+ return false;
+ } else if (!tokenInfo.getRefreshtoken().equals(token)) {
+ Log.w("Refreshtoken is not correct");
+ return false;
+ }
+ return true;
+ }
+ private boolean checkAccessTokenInDB(TokenTable tokenInfo, String token) {
if (tokenInfo.getAccesstoken() == null) {
- Log.w("token doesn't exist");
+ Log.w("AccessToken doesn't exist");
return false;
} else if (!tokenInfo.getAccesstoken().equals(token)) {
- Log.w("token is not correct");
+ Log.w("AccessToken is not correct");
return false;
}
return true;
TokenTable oldTokenInfo = castMapToTokenTable(record);
- if (!checkTokenInDB(oldTokenInfo, refreshToken)) {
+ if (!checkRefreshTokenInDB(oldTokenInfo, refreshToken)) {
throw new NotFoundException("refresh token is not correct");
}
// call 3rd party refresh token method