apim seperation

revert-dabc3590
ayyoob 8 years ago
parent dad3a34a27
commit f1e75d9375

@ -73,7 +73,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
this.globalProperties = globalProperties; this.globalProperties = globalProperties;
try { try {
deviceMgtServerUrl = getDeviceMgtServerUrl(globalProperties); deviceMgtServerUrl = getDeviceMgtServerUrl(globalProperties);
refreshTimeOffset = getRefreshTimeOffset(globalProperties); refreshTimeOffset = getRefreshTimeOffset(globalProperties) * 1000;
username = getUsername(globalProperties); username = getUsername(globalProperties);
password = getPassword(globalProperties); password = getPassword(globalProperties);
tokenEndpoint = getTokenEndpoint(globalProperties); tokenEndpoint = getTokenEndpoint(globalProperties);
@ -105,7 +105,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
.target(TokenIssuerService.class, tokenEndpoint); .target(TokenIssuerService.class, tokenEndpoint);
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()) {

@ -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()) {

Loading…
Cancel
Save