Gathika94 7 years ago
commit 6b6b82e639

@ -38,26 +38,6 @@
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.wso2</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
@ -66,10 +46,6 @@
<groupId>commons-pool.wso2</groupId>
<artifactId>commons-pool</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
@ -111,7 +87,28 @@
org.wso2.carbon.device.mgt.extensions.remote.session.*
</Export-Package>
<Import-Package>
*;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
</Import-Package>
</instructions>
</configuration>

@ -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<String, List<String>> sessionQueryParam = new HashedMap();
Map<String, List<String>> sessionQueryParam = new HashMap();
List<String> 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

@ -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<String, RemoteSession> activeDeviceClientSessionMap = new ConcurrentHashMap<String, RemoteSession>();
@ -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;
}
}

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

@ -43,7 +43,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version>
<version>${maven.scr.version}</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>

@ -21,6 +21,7 @@ package org.wso2.carbon.mdm.services.android.util;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.logging.Log;
@ -371,13 +372,12 @@ public class AndroidDeviceUtils {
// {"name":"BATTERY_LEVEL","value":"100"},{"name":"INTERNAL_TOTAL_MEMORY","value":"0.76"}]
JsonElement jsonElement = new JsonParser().parse(properties);
JsonArray jsonArray = jsonElement.getAsJsonArray();
boolean exist = false;
for (JsonElement element : jsonArray) {
if (element.isJsonObject()) {
JsonObject jsonObject = element.getAsJsonObject();
if (jsonObject.has("name")
&& jsonObject.get("name").getAsString().equalsIgnoreCase(needed)) {
if (jsonObject.has("value")) {
if (jsonObject.has("value") && jsonObject.get("value") != JsonNull.INSTANCE) {
return jsonObject.get("value").getAsString().replace("%", "");
} else {
return "";

Loading…
Cancel
Save