forked from community/product-iots
Conflicts: modules/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/transport/ConnectedCupMQTTConnector.java modules/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/ConnectedCupServiceUtils.java modules/samples/connectedcup/component/controller/src/main/java/org/coffeeking/controller/service/ConnectedCupControllerService.java modules/samples/connectedcup/component/manager/src/main/java/org/coffeeking/manager/service/ConnectedCupManagerService.java modules/samples/connectedcup/component/manager/src/main/webapp/WEB-INF/cxf-servlet.xml modules/samples/currentsensor/component/api/src/main/java/org/homeautomation/currentsensor/api/util/CurrentSensorServiceUtils.java modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorControllerService.java modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorManagerService.java modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/constants/CurrentSensorConstants.java modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManager.java modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManagerService.java modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/CurrentSensorDAOUtil.java modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/impl/CurrentSensorDeviceDAOImpl.java modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/util/CurrentSensorUtils.java modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/internal/ServiceComponent.java modules/samples/firealarm/component/controller/src/main/java/org.homeautomation/firealarm/controller/api/ControllerService.javaapplication-manager-new
commit
ab7ee2dbb8
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- This file contains the list of permissions that are associated with URL end points
|
||||||
|
of the web app. Each permission should contain the name, permission path ,API path
|
||||||
|
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||||
|
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||||
|
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||||
|
it will result 403 error at the runtime.
|
||||||
|
-->
|
||||||
|
<PermissionConfiguration>
|
||||||
|
<APIVersion></APIVersion>
|
||||||
|
<!-- Device related APIs -->
|
||||||
|
<Permission>
|
||||||
|
<name>Request coffee level</name>
|
||||||
|
<path>/device-mgt/devices/connectedcup/coffeelevel</path>
|
||||||
|
<url>/controller/coffeelevel</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope>connectedcup_user</scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Request temperature</name>
|
||||||
|
<path>/device-mgt/devices/connectedcup/temperature</path>
|
||||||
|
<url>/controller/temperature</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope>connectedcup_user</scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Order coffee cup</name>
|
||||||
|
<path>/device-mgt/devices/connectedcup/ordercoffee</path>
|
||||||
|
<url>/controller/ordercoffee</url>
|
||||||
|
<method>POST</method>
|
||||||
|
<scope>connectedcup_user</scope>
|
||||||
|
</Permission>
|
||||||
|
</PermissionConfiguration>
|
@ -0,0 +1,36 @@
|
|||||||
|
package org.coffeeking.manager.service.util;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides utility functions used by REST-API.
|
||||||
|
*/
|
||||||
|
public class APIUtil {
|
||||||
|
|
||||||
|
private static Log log = LogFactory.getLog(APIUtil.class);
|
||||||
|
|
||||||
|
public static String getAuthenticatedUser() {
|
||||||
|
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
String username = threadLocalCarbonContext.getUsername();
|
||||||
|
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||||
|
if (username.endsWith(tenantDomain)) {
|
||||||
|
return username.substring(0, username.lastIndexOf("@"));
|
||||||
|
}
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService =
|
||||||
|
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||||
|
if (deviceManagementProviderService == null) {
|
||||||
|
String msg = "Device Management service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- This file contains the list of permissions that are associated with URL end points
|
||||||
|
of the web app. Each permission should contain the name, permission path ,API path
|
||||||
|
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||||
|
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||||
|
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||||
|
it will result 403 error at the runtime.
|
||||||
|
-->
|
||||||
|
<PermissionConfiguration>
|
||||||
|
<APIVersion></APIVersion>
|
||||||
|
<!-- Device related APIs -->
|
||||||
|
<Permission>
|
||||||
|
<name>Get device</name>
|
||||||
|
<path>/device-mgt/user/devices/list</path>
|
||||||
|
<url>/manager/device/{device_id}</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Add device</name>
|
||||||
|
<path>/device-mgt/user/devices/add</path>
|
||||||
|
<url>/manager/device</url>
|
||||||
|
<method>POST</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Remove device</name>
|
||||||
|
<path>/device-mgt/user/devices/remove</path>
|
||||||
|
<url>/manager/device/{device_id}</url>
|
||||||
|
<method>DELETE</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Update device</name>
|
||||||
|
<path>/device-mgt/user/devices/update</path>
|
||||||
|
<url>/manager/device/{device_id}</url>
|
||||||
|
<method>POST</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
</PermissionConfiguration>
|
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- This file contains the list of permissions that are associated with URL end points
|
||||||
|
of the web app. Each permission should contain the name, permission path ,API path
|
||||||
|
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||||
|
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||||
|
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||||
|
it will result 403 error at the runtime.
|
||||||
|
-->
|
||||||
|
<PermissionConfiguration>
|
||||||
|
<APIVersion></APIVersion>
|
||||||
|
<!-- Device related APIs -->
|
||||||
|
<Permission>
|
||||||
|
<name></name>
|
||||||
|
<path>/device-mgt/devices/currentsensor/register</path>
|
||||||
|
<url>/controller/register/{owner}/{deviceId}/{ip}/{port}</url>
|
||||||
|
<method>POST</method>
|
||||||
|
<scope>currentsensor_device</scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name></name>
|
||||||
|
<path>/device-mgt/devices/currentsensor/read-current</path>
|
||||||
|
<url>/controller/read-current</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope>currentsensor_user</scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name></name>
|
||||||
|
<path>/device-mgt/devices/currentsensor/read-power</path>
|
||||||
|
<url>/controller/read-power</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope>currentsensor_user</scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name></name>
|
||||||
|
<path>/device-mgt/devices/currentsensor/read-flowrate</path>
|
||||||
|
<url>/controller/read-flowrate</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope>currentsensor_user</scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name></name>
|
||||||
|
<path>/device-mgt/devices/currentsensor/push-data</path>
|
||||||
|
<url>/controller/push-data</url>
|
||||||
|
<method>POST</method>
|
||||||
|
<scope>currentsensor_device</scope>
|
||||||
|
</Permission>
|
||||||
|
</PermissionConfiguration>
|
@ -0,0 +1,36 @@
|
|||||||
|
package org.homeautomation.currentsensor.manager.api.util;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides utility functions used by REST-API.
|
||||||
|
*/
|
||||||
|
public class APIUtil {
|
||||||
|
|
||||||
|
private static Log log = LogFactory.getLog(APIUtil.class);
|
||||||
|
|
||||||
|
public static String getAuthenticatedUser() {
|
||||||
|
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
String username = threadLocalCarbonContext.getUsername();
|
||||||
|
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||||
|
if (username.endsWith(tenantDomain)) {
|
||||||
|
return username.substring(0, username.lastIndexOf("@"));
|
||||||
|
}
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService =
|
||||||
|
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||||
|
if (deviceManagementProviderService == null) {
|
||||||
|
String msg = "Device Management service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- This file contains the list of permissions that are associated with URL end points
|
||||||
|
of the web app. Each permission should contain the name, permission path ,API path
|
||||||
|
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||||
|
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||||
|
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||||
|
it will result 403 error at the runtime.
|
||||||
|
-->
|
||||||
|
<PermissionConfiguration>
|
||||||
|
<APIVersion></APIVersion>
|
||||||
|
<!-- Device related APIs -->
|
||||||
|
<Permission>
|
||||||
|
<name>Get device</name>
|
||||||
|
<path>/device-mgt/user/devices/list</path>
|
||||||
|
<url>/manager/device/{device_id}</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Add device</name>
|
||||||
|
<path>/device-mgt/user/devices/add</path>
|
||||||
|
<url>/manager/device</url>
|
||||||
|
<method>POST</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Remove device</name>
|
||||||
|
<path>/device-mgt/user/devices/remove</path>
|
||||||
|
<url>/manager/device/{device_id}</url>
|
||||||
|
<method>DELETE</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Download device</name>
|
||||||
|
<path>/device-mgt/user/devices/add</path>
|
||||||
|
<url>/manager/device/{sketch_type}/download</url>
|
||||||
|
<method>GET</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Update device</name>
|
||||||
|
<path>/device-mgt/user/devices/update</path>
|
||||||
|
<url>/manager/device/{device_id}</url>
|
||||||
|
<method>POST</method>
|
||||||
|
<scope></scope>
|
||||||
|
</Permission>
|
||||||
|
</PermissionConfiguration>
|
Loading…
Reference in new issue