Addition ACL check in "__app_control_launch" function. 84/95084/1
authorsegwon <segwon.han@samsung.com>
Wed, 2 Nov 2016 08:56:34 +0000 (17:56 +0900)
committersegwon <segwon.han@samsung.com>
Wed, 2 Nov 2016 08:58:05 +0000 (17:58 +0900)
Signed-off-by: segwon <segwon.han@samsung.com>
Change-Id: I03cfb0de2dc09f7d7a6ae3aff6882b89e6159f7b

daemon/service_provider/RemoteAppControlServiceProvider.cpp

index 09fcb04..c5f5381 100755 (executable)
@@ -304,18 +304,32 @@ static int __access_control(iotcon_request_h request, iotcon_attributes_h attrib
 
 static int __app_control_launch(iotcon_request_h request, iotcon_attributes_h attributes)
 {
+       char *hostAddress;
+       int ret = iotcon_request_get_host_address(request, &hostAddress);
+       IF_FAIL_RETURN_TAG(ret == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_PARAMETER, _E, "iotcon_request_get_host_address() Fail(%d)", ret);
+       string hostAddressString(hostAddress);
+       string ip = conv::util::getIpAddress(hostAddressString);
+
+       char macAddress[127] = {0,};
+
+       IF_FAIL_RETURN_TAG(conv::util::getPeerMac(ip, -1, macAddress), CONV_ERROR_INVALID_PARAMETER, _E, "getPeerMac failed");
+
+       _D("Device IP : %s, Mac : %s", ip.c_str(), macAddress);
+       ACManagerPolicy acManagerPolicy = ACMANAGER_POLICY_U;
+
+       IF_FAIL_RETURN_TAG(GetACLState(macAddress, &acManagerPolicy) == ACLResult_OK, CONV_ERROR_INVALID_OPERATION, _E, "ACL check failed");
+       if (acManagerPolicy == ACMANAGER_POLICY_P) {
+               _D("PERMITTED");
+       } else {
+               _D("Device is not permitted %d", acManagerPolicy);
+               return CONV_ERROR_INVALID_OPERATION;
+       }
+
        app_control_h app_control;
        int reply = 0;
        char *appctl_char;
 
-// Check if it's permitted device
-#if defined(_TV_)
-       _D("TV:Always PERMITTED");
-#else
-       _D("Always PERMITTED");
-#endif
-
-       int ret = iotcon_attributes_get_str(attributes, CONV_JSON_APP_CONTROL, &appctl_char);
+       ret = iotcon_attributes_get_str(attributes, CONV_JSON_APP_CONTROL, &appctl_char);
        IF_FAIL_RETURN_TAG(ret == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_PARAMETER, _E, "iotcon_attributes_get_str() Fail(%d)", ret);
 
        bundle_raw* encoded = reinterpret_cast<unsigned char*>(appctl_char);