diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml index dbcb1dc4c..ab4b08515 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml @@ -38,26 +38,6 @@ org.wso2.carbon org.wso2.carbon.logging - - org.wso2.carbon - org.wso2.carbon.core - - - javax.websocket - javax.websocket-api - - - com.google.code.gson - gson - - - org.apache.httpcomponents.wso2 - httpcore - - - org.wso2.orbit.org.apache.httpcomponents - httpclient - org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub @@ -66,10 +46,6 @@ commons-pool.wso2 commons-pool - - javax.ws.rs - jsr311-api - org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core @@ -111,7 +87,28 @@ org.wso2.carbon.device.mgt.extensions.remote.session.* - *;resolution:=optional + javax.websocket, + org.apache.axis2; version="${axis2.osgi.version.range}", + org.apache.axis2.client; version="${axis2.osgi.version.range}", + org.apache.axis2.context; version="${axis2.osgi.version.range}", + org.apache.axis2.transport.http; version="${axis2.osgi.version.range}", + org.apache.commons.httpclient, + org.apache.commons.httpclient.contrib.ssl, + org.apache.commons.httpclient.params, + org.apache.commons.httpclient.protocol, + org.apache.commons.logging, + org.apache.commons.pool, + org.apache.commons.pool.impl, + org.json, + org.osgi.framework, + org.osgi.service.component, + org.wso2.carbon.context, + org.wso2.carbon.core, + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.device.mgt.core.*, + org.wso2.carbon.identity.oauth2.stub, + org.wso2.carbon.identity.oauth2.stub.dto, + org.wso2.carbon.utils.multitenancy diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java index bf5182c0f..1274d7921 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java @@ -17,7 +17,6 @@ */ package org.wso2.carbon.device.mgt.extensions.remote.session; -import org.apache.commons.collections.map.HashedMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; @@ -43,6 +42,7 @@ import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -67,7 +67,7 @@ public class RemoteSessionManagementServiceImpl implements RemoteSessionManageme } // Read Query Parameters for obtain the token - Map> sessionQueryParam = new HashedMap(); + Map> sessionQueryParam = new HashMap(); List sessionQueryParamList = new LinkedList<>(); sessionQueryParamList.add(session.getQueryString()); sessionQueryParam.put(RemoteSessionConstants.QUERY_STRING, sessionQueryParamList); @@ -94,8 +94,10 @@ public class RemoteSessionManagementServiceImpl implements RemoteSessionManageme .isUserAuthorized(deviceIdentifier, authenticationInfo.getUsername()); if (userAuthorized) { // set common settings for session - session.setMaxBinaryMessageBufferSize(RemoteSessionConstants.MAX_BUFFER_SIZE); - session.setMaxTextMessageBufferSize(RemoteSessionConstants.MAX_BUFFER_SIZE); + session.setMaxBinaryMessageBufferSize(RemoteSessionManagementDataHolder.getInstance() + .getMaxMessageBufferSize()); + session.setMaxTextMessageBufferSize(RemoteSessionManagementDataHolder.getInstance() + .getMaxMessageBufferSize()); session.setMaxIdleTimeout(RemoteSessionManagementDataHolder.getInstance().getMaxIdleTimeout()); // if session initiated using operation id means request came from device diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementDataHolder.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementDataHolder.java index 310affbb0..ef92860f6 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementDataHolder.java +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementDataHolder.java @@ -38,6 +38,7 @@ public class RemoteSessionManagementDataHolder { private boolean isEnabled; private String serverUrl; private long maxIdleTimeout; + private int maxMessageBufferSize; private int maxMessagesPerSecond; private OAuthAuthenticator oAuthAuthenticator; private Map activeDeviceClientSessionMap = new ConcurrentHashMap(); @@ -110,4 +111,12 @@ public class RemoteSessionManagementDataHolder { public void setMaxIdleTimeout(long maxIdleTimeout) { this.maxIdleTimeout = maxIdleTimeout; } + + public int getMaxMessageBufferSize() { + return maxMessageBufferSize; + } + + public void setMaxMessageBufferSize(int MaxMessageBufferSize) { + this.maxMessageBufferSize = MaxMessageBufferSize; + } } diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/listener/RemoteSessionManagerStartupListener.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/listener/RemoteSessionManagerStartupListener.java index 19b89f369..8236cb848 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/listener/RemoteSessionManagerStartupListener.java +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/listener/RemoteSessionManagerStartupListener.java @@ -64,6 +64,14 @@ public class RemoteSessionManagerStartupListener implements ServerStartupObserve // Set max idle timeout in milliseconds RemoteSessionManagementDataHolder.getInstance().setMaxIdleTimeout((long) rsConfig.getSessionIdleTimeOut() * 60000); + // Set max buffer size for messages. + if (rsConfig.getMaxMessageBufferSize() > 0) { + RemoteSessionManagementDataHolder.getInstance() + .setMaxMessageBufferSize(rsConfig.getMaxMessageBufferSize() * 1024); + } else { + RemoteSessionManagementDataHolder.getInstance(). + setMaxMessageBufferSize(RemoteSessionConstants.MAX_BUFFER_SIZE); + } // Set max messages per second. if (rsConfig.getMaxMessagesPerSession() > 0) { diff --git a/components/extensions/remote-session-extension/pom.xml b/components/extensions/remote-session-extension/pom.xml index e63341f51..cceaf0e62 100644 --- a/components/extensions/remote-session-extension/pom.xml +++ b/components/extensions/remote-session-extension/pom.xml @@ -43,7 +43,7 @@ org.apache.felix maven-scr-plugin - 1.7.2 + ${maven.scr.version} generate-scr-scrdescriptor