From 2dd7f534894b60c8e81b8c20efd2c2b0a5879359 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 7 Mar 2017 02:04:26 +0530 Subject: [PATCH 1/2] added log support for server to server communication --- .../pom.xml | 7 +++- .../ApplicationOperationsImpl.java | 31 ++--------------- .../client/OAuthRequestInterceptor.java | 32 ++--------------- .../pom.xml | 7 +++- .../http/authorization/DeviceAuthorizer.java | 30 ++-------------- .../client/OAuthRequestInterceptor.java | 34 +++---------------- .../pom.xml | 7 +++- .../authorization/DeviceAuthorizer.java | 30 ++-------------- .../client/OAuthRequestInterceptor.java | 32 ++--------------- .../pom.xml | 7 +++- .../DeviceAccessBasedMQTTAuthorizer.java | 30 ++-------------- .../client/OAuthRequestInterceptor.java | 32 ++--------------- pom.xml | 5 +++ 13 files changed, 51 insertions(+), 233 deletions(-) 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 de5ac8ae8a..303a8349f5 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 ac6cf2fe13..a049c3fabd 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 e3f5858d4d..9c4f80b715 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 6c9e9bf1e2..0449e141f8 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 3c33865830..c6e1952545 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 e09357f764..0c6eff5d81 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 65d8152705..0141c3e91e 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 6cb9e04ee6..c4c40856ee 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 d8f168da56..e6f38d2811 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 cff7f75a62..79a30aa2c1 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 bffe0d5659..6fd2c34648 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 a49af5c839..5f860985d6 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 37b7e0741a..f0543da7c1 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} + From d9d6964fee3637d18988defce347cf6bccfc9499 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 7 Mar 2017 02:14:52 +0530 Subject: [PATCH 2/2] added missing plugins --- .../pom.xml | 3 +++ .../org.wso2.carbon.device.mgt.adapter.feature/pom.xml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml index a8be9fc351..a09b53a80a 100644 --- a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml @@ -80,6 +80,9 @@ io.github.openfeign:feign-gson:${io.github.openfeign.version} + + io.github.openfeign:feign-slf4j:${io.github.openfeign.version} + org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml index 65d06ffea9..e10bd7e2de 100644 --- a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml @@ -198,6 +198,9 @@ io.github.openfeign:feign-core:${io.github.openfeign.version} + + io.github.openfeign:feign-slf4j:${io.github.openfeign.version} + io.github.openfeign:feign-gson:${io.github.openfeign.version}