Merge pull request #1111 from ruwany/master
Resolving conflicts for Remote Control feature on behalf of Warunamerge-requests/1/head
commit
bb88b4ed43
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "RemoteSessionInfo", description = "Template of the remote session")
|
||||
public class RemoteSessionInfo {
|
||||
|
||||
@ApiModelProperty(name = "Server Url", value = "Url of the remote session server.", required = true)
|
||||
private String serverUrl;
|
||||
|
||||
@ApiModelProperty(name = "isEnabled", value = "Is remote session functionality enabled", required = true)
|
||||
private Boolean isEnabled;
|
||||
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
public void setServerUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
isEnabled = enabled;
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Extension;
|
||||
import io.swagger.annotations.ExtensionProperty;
|
||||
import io.swagger.annotations.Info;
|
||||
import io.swagger.annotations.ResponseHeader;
|
||||
import io.swagger.annotations.SwaggerDefinition;
|
||||
import io.swagger.annotations.Tag;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "1.0.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "remote_session_services"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/remote-session-services"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "device_management", description = "")
|
||||
}
|
||||
)
|
||||
@Scopes(
|
||||
scopes = {
|
||||
@Scope(
|
||||
name = "Remote Session Connection",
|
||||
description = "",
|
||||
key = "perm:remote-session-service:connect",
|
||||
permissions = {"/device-mgt/devices/owning-device/remote-session"}
|
||||
)
|
||||
}
|
||||
)
|
||||
@Path("/remote-session-services")
|
||||
@Api(value = "Remote Session Service",
|
||||
description = "This carries all the resources related to the remote session service functionality.")
|
||||
public interface RemoteSessionService {
|
||||
/**
|
||||
* Retrieve Analytics for the device type
|
||||
*/
|
||||
@GET
|
||||
@Path("connection/{deviceType}/{deviceId}")
|
||||
@ApiOperation(
|
||||
consumes = "application/json",
|
||||
produces = "application/json",
|
||||
httpMethod = "GET",
|
||||
value = "Retrieve Connection Information for the device type",
|
||||
notes = "",
|
||||
response = Response.class,
|
||||
tags = "Remote Session Service Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:remote-session-service:connect")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK.",
|
||||
response = Response.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid Device Identifiers found.",
|
||||
response = Response.class),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized. \n Unauthorized request."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Error on retrieving stats",
|
||||
response = Response.class)
|
||||
})
|
||||
Response getRemoteSessionDeviceConnect(
|
||||
@ApiParam(
|
||||
name = "deviceId",
|
||||
value = "The registered device Id.",
|
||||
required = true)
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(
|
||||
name = "device-type",
|
||||
value = "The device type, such as ios, android or windows.",
|
||||
required = true)
|
||||
@PathParam("deviceType")
|
||||
@Size(max = 45)
|
||||
String deviceType);
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
|
||||
import org.wso2.carbon.device.mgt.core.config.remote.session.RemoteSessionConfiguration;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RemoteSessionInfo;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.RemoteSessionService;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* The api for
|
||||
*/
|
||||
public class RemoteSessionServiceImpl implements RemoteSessionService {
|
||||
|
||||
private static Log log = LogFactory.getLog(RemoteSessionServiceImpl.class);
|
||||
|
||||
@Path("connect/{deviceType}/{deviceId}")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public Response getRemoteSessionDeviceConnect(@PathParam("deviceId") String deviceId,
|
||||
@PathParam("deviceType") String deviceType) {
|
||||
//First, check whether the remote session is enabled.
|
||||
RemoteSessionInfo sessionInfo = new RemoteSessionInfo();
|
||||
sessionInfo.setEnabled(false);
|
||||
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance()
|
||||
.getDeviceManagementConfig();
|
||||
if (deviceManagementConfig != null) {
|
||||
RemoteSessionConfiguration remoteSessionConfiguration = deviceManagementConfig.getRemoteSessionConfiguration();
|
||||
if (remoteSessionConfiguration != null) {
|
||||
boolean isEnabled = remoteSessionConfiguration.isEnabled();
|
||||
sessionInfo.setEnabled(isEnabled);
|
||||
if (isEnabled) {
|
||||
sessionInfo.setServerUrl(remoteSessionConfiguration.getRemoteSessionServerUrl());
|
||||
}
|
||||
return Response.ok().entity(sessionInfo).build();
|
||||
}
|
||||
}
|
||||
|
||||
return Response.ok().entity(sessionInfo).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.core.config.keymanager;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Configurations related to key management.
|
||||
*/
|
||||
@XmlRootElement(name = "KeyManagerConfiguration")
|
||||
public class KeyManagerConfigurations {
|
||||
private String serverUrl;
|
||||
private String adminUsername;
|
||||
private String adminPassword;
|
||||
|
||||
@XmlElement(name = "AdminUsername", required = true)
|
||||
public String getAdminUsername() {
|
||||
return adminUsername;
|
||||
}
|
||||
|
||||
public void setAdminUsername(String adminUsername) {
|
||||
this.adminUsername = adminUsername;
|
||||
}
|
||||
|
||||
@XmlElement(name = "AdminPassword", required = true)
|
||||
public String getAdminPassword() {
|
||||
return adminPassword;
|
||||
}
|
||||
|
||||
public void setAdminPassword(String adminPassword) {
|
||||
this.adminPassword = adminPassword;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ServerUrl", required = true)
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
public void setServerUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* you may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.core.config.remote.session;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* This class represents the information related to Remote Session configuration.
|
||||
*/
|
||||
@XmlRootElement(name = "RemoteSessionConfiguration")
|
||||
public class RemoteSessionConfiguration {
|
||||
|
||||
private String remoteSessionServerUrl;
|
||||
private boolean enabled;
|
||||
private int maxHTTPConnectionPerHost;
|
||||
private int maxTotalHTTPConnections;
|
||||
private int maxMessagesPerSecond;
|
||||
private int sessionIdleTimeOut;
|
||||
private int maxSessionDuration;
|
||||
private int sessionBufferSize;
|
||||
|
||||
public void setRemoteSessionServerUrl(String remoteSessionServerUrl) {
|
||||
this.remoteSessionServerUrl = remoteSessionServerUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote session server url
|
||||
* @return
|
||||
*/
|
||||
@XmlElement(name = "RemoteSessionServerUrl", required = true)
|
||||
public String getRemoteSessionServerUrl() {
|
||||
return remoteSessionServerUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote session enabled
|
||||
* @return
|
||||
*/
|
||||
@XmlElement(name = "Enabled", required = true)
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum connections per host for external http invocations
|
||||
* @return
|
||||
*/
|
||||
@XmlElement(name = "MaximumHTTPConnectionPerHost", required = true, defaultValue = "2")
|
||||
public int getMaxHTTPConnectionPerHost() {
|
||||
return maxHTTPConnectionPerHost;
|
||||
}
|
||||
|
||||
public void setMaxHTTPConnectionPerHost(int maxHTTPConnectionPerHost) {
|
||||
this.maxHTTPConnectionPerHost = maxHTTPConnectionPerHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum total connections for external http invocation
|
||||
*/
|
||||
@XmlElement(name = "MaximumTotalHTTPConnections", required = true, defaultValue = "100")
|
||||
public int getMaxTotalHTTPConnections() {
|
||||
return maxTotalHTTPConnections;
|
||||
}
|
||||
|
||||
public void setMaxTotalHTTPConnections(int maxTotalHTTPConnections) {
|
||||
this.maxTotalHTTPConnections = maxTotalHTTPConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for protect device from message spamming. Throttling limit in term of messages for device
|
||||
* @return
|
||||
*/
|
||||
@XmlElement(name = "MaximumMessagesPerSecond", required = true, defaultValue = "10")
|
||||
public int getMaxMessagesPerSession() {
|
||||
return maxMessagesPerSecond;
|
||||
}
|
||||
|
||||
public void setMaxMessagesPerSession(int maxMessagesPerSession) {
|
||||
this.maxMessagesPerSecond = maxMessagesPerSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum idle timeout in minutes
|
||||
* @return
|
||||
*/
|
||||
@XmlElement(name = "SessionIdleTimeOut", required = true, defaultValue = "5")
|
||||
public int getSessionIdleTimeOut() {
|
||||
return sessionIdleTimeOut;
|
||||
}
|
||||
|
||||
public void setSessionIdleTimeOut(int sessionIdleTimeOut) {
|
||||
this.sessionIdleTimeOut = sessionIdleTimeOut;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum session duration in minutes
|
||||
* @return
|
||||
*/
|
||||
@XmlElement(name = "MaximumSessionDuration", required = true, defaultValue = "15")
|
||||
public int getMaxSessionDuration() {
|
||||
return maxSessionDuration;
|
||||
}
|
||||
|
||||
public void setMaxSessionDuration(int maxSessionDuration) {
|
||||
this.maxSessionDuration = maxSessionDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum session buffer size in kilo bytes
|
||||
* @return
|
||||
*/
|
||||
@XmlElement(name = "SessionBufferSize", required = true, defaultValue = "640")
|
||||
public int getSessionBufferSize() {
|
||||
return sessionBufferSize;
|
||||
}
|
||||
|
||||
public void setSessionBufferSize(int sessionBufferSize) {
|
||||
this.sessionBufferSize = sessionBufferSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in new issue