|
|
@ -28,6 +28,7 @@ import feign.auth.BasicAuthRequestInterceptor;
|
|
|
|
import feign.gson.GsonDecoder;
|
|
|
|
import feign.gson.GsonDecoder;
|
|
|
|
import feign.gson.GsonEncoder;
|
|
|
|
import feign.gson.GsonEncoder;
|
|
|
|
import feign.jaxrs.JAXRSContract;
|
|
|
|
import feign.jaxrs.JAXRSContract;
|
|
|
|
|
|
|
|
import feign.slf4j.Slf4jLogger;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.appmgt.mdm.restconnector.Constants;
|
|
|
|
import org.wso2.carbon.appmgt.mdm.restconnector.Constants;
|
|
|
@ -72,7 +73,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
|
|
|
|
refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset();
|
|
|
|
refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset();
|
|
|
|
String username = AuthorizationConfigurationManager.getInstance().getUserName();
|
|
|
|
String username = AuthorizationConfigurationManager.getInstance().getUserName();
|
|
|
|
String password = AuthorizationConfigurationManager.getInstance().getPassword();
|
|
|
|
String password = AuthorizationConfigurationManager.getInstance().getPassword();
|
|
|
|
apiApplicationRegistrationService = Feign.builder().client(getSSLClient()).logger(getLogger()).logLevel(
|
|
|
|
apiApplicationRegistrationService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel(
|
|
|
|
Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password))
|
|
|
|
Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password))
|
|
|
|
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
|
|
|
|
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
|
|
|
|
.target(ApiApplicationRegistrationService.class,
|
|
|
|
.target(ApiApplicationRegistrationService.class,
|
|
|
@ -100,7 +101,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
|
|
|
|
String consumerSecret = apiApplicationKey.getConsumerSecret();
|
|
|
|
String consumerSecret = apiApplicationKey.getConsumerSecret();
|
|
|
|
String username = AuthorizationConfigurationManager.getInstance().getUserName();
|
|
|
|
String username = AuthorizationConfigurationManager.getInstance().getUserName();
|
|
|
|
String password = AuthorizationConfigurationManager.getInstance().getPassword();
|
|
|
|
String password = AuthorizationConfigurationManager.getInstance().getPassword();
|
|
|
|
tokenIssuerService = Feign.builder().client(getSSLClient()).logger(getLogger()).logLevel(Logger.Level.FULL)
|
|
|
|
tokenIssuerService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel(Logger.Level.FULL)
|
|
|
|
.requestInterceptor(new BasicAuthRequestInterceptor(consumerKey, consumerSecret))
|
|
|
|
.requestInterceptor(new BasicAuthRequestInterceptor(consumerKey, consumerSecret))
|
|
|
|
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
|
|
|
|
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
|
|
|
|
.target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenApiURL());
|
|
|
|
.target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenApiURL());
|
|
|
@ -149,31 +150,4 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static Logger getLogger() {
|
|
|
|
|
|
|
|
return new Logger() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void log(String configKey, String format, Object... args) {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug(String.format(methodTag(configKey) + format, args));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void logRequest(String configKey, Level logLevel, Request request) {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
super.logRequest(configKey, logLevel, request);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Response logAndRebufferResponse(String configKey, Level logLevel, Response response,
|
|
|
|
|
|
|
|
long elapsedTime) throws IOException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
return super.logAndRebufferResponse(configKey, logLevel, response, elapsedTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|