diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml index de5ac8ae8..303a8349f 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml @@ -68,7 +68,8 @@ org.json.simple.*, org.wso2.carbon.appmgt.mobile.beans, org.wso2.carbon.context, - javax.net.ssl + javax.net.ssl, + feign.slf4j !org.wso2.carbon.appmgt.mdm.restconnector.internal, @@ -121,6 +122,10 @@ org.wso2.carbon.appmgt org.wso2.carbon.appmgt.mobile + + io.github.openfeign + feign-slf4j + diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java index ac6cf2fe1..a049c3fab 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java @@ -25,6 +25,7 @@ import feign.Response; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.simple.JSONObject; @@ -75,12 +76,12 @@ public class ApplicationOperationsImpl implements ApplicationOperations { public ApplicationOperationsImpl() { String authorizationConfigManagerServerURL = AuthorizationConfigurationManager.getInstance().getServerURL(); OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); - deviceManagementAdminService = Feign.builder().client(getSSLClient()).logger(getLogger()).logLevel( + deviceManagementAdminService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel( Logger.Level.FULL).requestInterceptor(oAuthRequestInterceptor) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(DeviceManagementAdminService.class, authorizationConfigManagerServerURL + CDMF_SERVER_BASE_CONTEXT); - applicationManagementAdminService = Feign.builder().client(getSSLClient()).logger(getLogger()).logLevel( + applicationManagementAdminService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel( Logger.Level.FULL).requestInterceptor(oAuthRequestInterceptor) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(ApplicationManagementAdminService.class, @@ -317,30 +318,4 @@ public class ApplicationOperationsImpl implements ApplicationOperations { } } - 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; - } - }; - } } \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java index e3f5858d4..9c4f80b71 100755 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java @@ -28,6 +28,7 @@ import feign.auth.BasicAuthRequestInterceptor; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.appmgt.mdm.restconnector.Constants; @@ -72,7 +73,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset(); String username = AuthorizationConfigurationManager.getInstance().getUserName(); 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)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(ApiApplicationRegistrationService.class, @@ -100,7 +101,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { String consumerSecret = apiApplicationKey.getConsumerSecret(); String username = AuthorizationConfigurationManager.getInstance().getUserName(); 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)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .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; - } - }; - } - } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml index 6c9e9bf1e..0449e141f 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml @@ -92,6 +92,10 @@ javax.ws.rs jsr311-api + + io.github.openfeign + feign-slf4j + @@ -161,7 +165,8 @@ org.wso2.carbon.identity.oauth2.*, org.wso2.carbon.utils, org.wso2.carbon.utils.multitenancy, - javax.net.ssl + javax.net.ssl, + feign.slf4j jsr311-api, diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/DeviceAuthorizer.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/DeviceAuthorizer.java index 3c3386583..c6e195254 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/DeviceAuthorizer.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/DeviceAuthorizer.java @@ -26,6 +26,7 @@ import feign.Response; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.OAuthRequestInterceptor; @@ -62,7 +63,7 @@ public class DeviceAuthorizer { public DeviceAuthorizer(Map globalProperties) { try { - deviceAccessAuthorizationAdminService = Feign.builder().client(getSSLClient()).logger(getLogger()) + deviceAccessAuthorizationAdminService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()) .logLevel(Logger.Level.FULL).requestInterceptor(new OAuthRequestInterceptor(globalProperties)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(DeviceAccessAuthorizationAdminService.class, getDeviceMgtServerUrl(globalProperties) @@ -143,31 +144,4 @@ public class DeviceAuthorizer { } } - 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; - } - }; - } - } \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/OAuthRequestInterceptor.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/OAuthRequestInterceptor.java index e09357f76..0c6eff5d8 100755 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/OAuthRequestInterceptor.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/OAuthRequestInterceptor.java @@ -25,6 +25,7 @@ import feign.auth.BasicAuthRequestInterceptor; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.AccessTokenInfo; @@ -89,7 +90,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { username = getUsername(globalProperties); password = getPassword(globalProperties); tokenEndpoint = getTokenEndpoint(globalProperties); - 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)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(ApiApplicationRegistrationService.class, @@ -112,7 +113,8 @@ public class OAuthRequestInterceptor implements RequestInterceptor { ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile); String consumerKey = apiApplicationKey.getConsumerKey(); String consumerSecret = apiApplicationKey.getConsumerSecret(); - 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)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(TokenIssuerService.class, tokenEndpoint); @@ -202,32 +204,4 @@ public class OAuthRequestInterceptor implements RequestInterceptor { return null; } } - - 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; - } - }; - } - } diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml index 65d815270..0141c3e91 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml @@ -95,6 +95,10 @@ javax.ws.rs jsr311-api + + io.github.openfeign + feign-slf4j + @@ -170,7 +174,8 @@ feign.codec, feign.gson, javax.cache, - javax.net.ssl + javax.net.ssl, + feign.slf4j * diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java index 6cb9e04ee..c4c40856e 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java @@ -26,6 +26,7 @@ import feign.Response; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.AuthenticationInfo; @@ -80,7 +81,7 @@ public class DeviceAuthorizer implements Authorizer { } } try { - deviceAccessAuthorizationAdminService = Feign.builder().client(getSSLClient()).logger(getLogger()) + deviceAccessAuthorizationAdminService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()) .logLevel(Logger.Level.FULL).requestInterceptor(new OAuthRequestInterceptor(globalProperties)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(DeviceAccessAuthorizationAdminService.class, getDeviceMgtServerUrl(globalProperties) @@ -175,31 +176,4 @@ public class DeviceAuthorizer implements Authorizer { return null; } } - - 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; - } - }; - } } \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java index d8f168da5..e6f38d281 100755 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java @@ -25,6 +25,7 @@ import feign.auth.BasicAuthRequestInterceptor; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.client.dto.AccessTokenInfo; @@ -90,7 +91,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { username = getUsername(globalProperties); password = getPassword(globalProperties); tokenEndpoint = getTokenEndpoint(globalProperties); - apiApplicationRegistrationService = Feign.builder().client(getSSLClient()).logger(getLogger()) + apiApplicationRegistrationService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()) .logLevel(Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(ApiApplicationRegistrationService.class, @@ -113,7 +114,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile); String consumerKey = apiApplicationKey.getConsumerKey(); String consumerSecret = apiApplicationKey.getConsumerSecret(); - 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)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(TokenIssuerService.class, tokenEndpoint); @@ -204,31 +205,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; - } - }; - } - } diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml index cff7f75a6..79a30aa2c 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml @@ -78,6 +78,10 @@ org.wso2.carbon javax.cache.wso2 + + io.github.openfeign + feign-slf4j + @@ -124,7 +128,8 @@ javax.xml.stream, org.wso2.carbon.base, org.wso2.carbon.utils, - javax.net.ssl + javax.net.ssl, + feign.slf4j jsr311-api, diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java index bffe0d565..6fd2c3464 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java @@ -27,6 +27,7 @@ import feign.Response; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dna.mqtt.moquette.server.IAuthorizer; @@ -80,7 +81,7 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { public DeviceAccessBasedMQTTAuthorizer() { this.MQTTAuthorizationConfiguration = AuthorizationConfigurationManager.getInstance(); - deviceAccessAuthorizationAdminService = Feign.builder().client(getSSLClient()).logger(getLogger()) + deviceAccessAuthorizationAdminService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()) .logLevel(Logger.Level.FULL).requestInterceptor(new OAuthRequestInterceptor()) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(DeviceAccessAuthorizationAdminService.class, @@ -268,31 +269,4 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { } } - 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; - } - }; - } - } \ No newline at end of file diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java index a49af5c83..5f860985d 100755 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java @@ -27,6 +27,7 @@ import feign.codec.Encoder; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; +import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.client.dto.AccessTokenInfo; @@ -70,7 +71,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset() * 1000; String username = AuthorizationConfigurationManager.getInstance().getUsername(); 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)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(ApiApplicationRegistrationService.class, @@ -92,7 +93,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { String consumerSecret = apiApplicationKey.getConsumerSecret(); String username = AuthorizationConfigurationManager.getInstance().getUsername(); 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)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(TokenIssuerService.class, @@ -142,31 +143,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; - } - }; - } - } diff --git a/pom.xml b/pom.xml index 37b7e0741..f0543da7c 100644 --- a/pom.xml +++ b/pom.xml @@ -1072,6 +1072,11 @@ feign-gson ${io.github.openfeign.version} + + io.github.openfeign + feign-slf4j + ${io.github.openfeign.version} +