Update a policy of successful cloud provisioning
authorJihun Ha <jihun.ha@samsung.com>
Sun, 11 Sep 2016 11:05:16 +0000 (20:05 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 12 Sep 2016 06:03:21 +0000 (06:03 +0000)
If an enrollee already has an ACL and certificate for communication
with Cloudserver, a mediator does not need to provide them.
That is, ACL and certificate provisioning can be skipped for this case.

Change-Id: Id22566e21c22f92b552a3861a41f0de83959dcf3
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11655
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/easy-setup/mediator/richsdk/inc/ESRichCommon.h
service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp
service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.h [changed mode: 0644->0755]
service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp

index 4830a7e..c7fe9a8 100755 (executable)
@@ -123,15 +123,21 @@ namespace OIC
              */
             CloudProp()
             {
+                m_cloudID = "";
+                m_credID = -1;
             }
 
             CloudProp(const CloudProp& cloudProp) :
-                m_rep(cloudProp.toOCRepresentation()), m_cloudID(cloudProp.getCloudID())
+                                            m_rep(cloudProp.toOCRepresentation()),
+                                            m_cloudID(cloudProp.getCloudID()),
+                                            m_credID(cloudProp.getCredID())
             {
             }
 
             CloudProp(const CloudProp&& cloudProp) :
-                m_rep(std::move(cloudProp.toOCRepresentation())), m_cloudID(cloudProp.getCloudID())
+                                            m_rep(std::move(cloudProp.toOCRepresentation())),
+                                            m_cloudID(cloudProp.getCloudID()),
+                                            m_credID(cloudProp.getCredID())
             {
             }
 
index 1c9703b..6f49af9 100755 (executable)
@@ -373,13 +373,15 @@ namespace OIC
                 throw ESException("Not found owned devices.");
             }
 
-            if(performACLProvisioningForCloudServer(ownedDevice, cloudUuid) != ESResult::ES_OK)
+            if(!cloudUuid.empty()
+                && performACLProvisioningForCloudServer(ownedDevice, cloudUuid) != ESResult::ES_OK)
             {
                 OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "error performACLProvisioningForCloudServer");
                 throw ESException("error performACLProvisioningForCloudServer");
             }
 
-            if(performCertProvisioningForCloudServer(ownedDevice, credId) != ESResult::ES_OK)
+            if(credId != -1
+                && performCertProvisioningForCloudServer(ownedDevice, credId) != ESResult::ES_OK)
             {
                 OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "error performCertProvisioningForCloudServer");
                 throw ESException("error performCertProvisioningForCloudServer");
@@ -524,12 +526,12 @@ namespace OIC
         {
             if (hasError)
             {
-               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Error in provisioning operation!");
+               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Error in ACL provisioning operation!");
                aclResult = false;
             }
             else
             {
-               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Received provisioning results: ");
+               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Received ACL provisioning results: ");
 
                std::string devUuid;
                for (unsigned int i = 0; i < result->size(); i++)
@@ -548,12 +550,12 @@ namespace OIC
         {
             if (hasError)
             {
-               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Error in provisioning operation!");
+               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Error in Cert. provisioning operation!");
                aclResult = false;
             }
             else
             {
-               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Received provisioning results: ");
+               OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "Received Cert. provisioning results: ");
 
                std::string devUuid;
                for (unsigned int i = 0; i < result->size(); i++)
old mode 100644 (file)
new mode 100755 (executable)
index 26b50f8..066ffae
@@ -32,7 +32,7 @@ namespace OIC
 {
     namespace Service
     {
-        #define ENROLEE_SECURITY_TAG "ENROLEE_SECURITY"
+        #define ENROLEE_SECURITY_TAG "ENROLLEE_SECURITY"
         #define UUID_SIZE (16)
         #define UUID_STRING_SIZE (37)
 
index aa266fd..f5c8d7f 100755 (executable)
@@ -409,15 +409,13 @@ namespace OIC
 #if defined(__WITH_DTLS__) && defined(__WITH_TLS__)
             try
             {
-                m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
-
-                if(cloudProp.getCloudID().empty())
+                if(!(cloudProp.getCloudID().empty() && cloudProp.getCredID() == -1))
                 {
-                    throw ESInvalidParameterException("Invalid Cloud Server UUID.");
-                }
+                    m_enrolleeSecurity = std::make_shared <EnrolleeSecurity> (m_ocResource, "");
 
-                m_enrolleeSecurity->provisionSecurityForCloudServer(cloudProp.getCloudID(),
-                                                                    cloudProp.getCredID());
+                    m_enrolleeSecurity->provisionSecurityForCloudServer(cloudProp.getCloudID(),
+                                                                        cloudProp.getCredID());
+                }
             }
 
             catch (const std::exception& e)