|
|
@ -50,7 +50,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
|
|
|
|
* Creates an interceptor that authenticates all requests.
|
|
|
|
* Creates an interceptor that authenticates all requests.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public OAuthRequestInterceptor() {
|
|
|
|
public OAuthRequestInterceptor() {
|
|
|
|
refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset();
|
|
|
|
refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset() * 1000;
|
|
|
|
String username = AuthorizationConfigurationManager.getInstance().getUsername();
|
|
|
|
String username = AuthorizationConfigurationManager.getInstance().getUsername();
|
|
|
|
String password = AuthorizationConfigurationManager.getInstance().getPassword();
|
|
|
|
String password = AuthorizationConfigurationManager.getInstance().getPassword();
|
|
|
|
apiApplicationRegistrationService = Feign.builder().requestInterceptor(
|
|
|
|
apiApplicationRegistrationService = Feign.builder().requestInterceptor(
|
|
|
@ -81,7 +81,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
|
|
|
|
.target(TokenIssuerService.class,
|
|
|
|
.target(TokenIssuerService.class,
|
|
|
|
AuthorizationConfigurationManager.getInstance().getTokenEndpoint());
|
|
|
|
AuthorizationConfigurationManager.getInstance().getTokenEndpoint());
|
|
|
|
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, REQUIRED_SCOPE);
|
|
|
|
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, REQUIRED_SCOPE);
|
|
|
|
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
|
|
|
|
tokenInfo.setExpires_in(System.currentTimeMillis() + (tokenInfo.getExpires_in() * 1000));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
synchronized (this) {
|
|
|
|
synchronized (this) {
|
|
|
|
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
|
|
|
|
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
|
|
|
|