Merge branch 'release-3.0.x' of https://github.com/wso2/carbon-device-mgt-plugins into release-3.0.x

revert-dabc3590
Rasika Perera 8 years ago
commit d1842ca64c

@ -96,7 +96,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
} }
synchronized(tokenInfo) { synchronized(this) {
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) { if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token()); tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());

@ -79,9 +79,11 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
} }
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) { synchronized (this) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token()); if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
}
} }
String headerValue = "Bearer " + tokenInfo.getAccess_token(); String headerValue = "Bearer " + tokenInfo.getAccess_token();
template.header("Authorization", headerValue); template.header("Authorization", headerValue);

Loading…
Cancel
Save