Update a logic to convert a string UUID to oicuuid type
authorJihun Ha <jihun.ha@samsung.com>
Tue, 13 Sep 2016 02:12:06 +0000 (11:12 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 21 Sep 2016 15:28:46 +0000 (15:28 +0000)
The previous convertStringToUUID function does not works well, which
can not convert from string UUID to oicuuid one, properly. Instead of it,
we use an existing API for that in srmutility, i.e. ConvertStrToUuid.

Change-Id: I09f407e8af1a4395bf1b406bdb0f1a729e75f1fe
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11725
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit 3215cc92a7bccfe2dc2d6e2403b068fe38721554)
Reviewed-on: https://gerrit.iotivity.org/gerrit/11779
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Heewon Park <h_w.park@samsung.com>
service/easy-setup/mediator/richsdk/SConscript
service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp
service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.h

index 60c1c00..1b54d12 100644 (file)
@@ -106,6 +106,7 @@ if target_os in ['android','linux']:
                        # For bring up purposes only, the forked version will live here.
                        easy_setup_env.AppendUnique(CPPPATH = [env.get('SRC_DIR') + '/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
                easy_setup_env.AppendUnique(CPPPATH = [
+                        env.get('SRC_DIR') + '/resource/csdk/connectivity/lib/libcoap-4.1.1',
                        env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
                        env.get('SRC_DIR') + '/resource/csdk/security/include/internal',
                        env.get('SRC_DIR') + '/resource/csdk/connectivity/api/',
index 6f49af9..9d93eca 100755 (executable)
@@ -30,6 +30,7 @@
 #include "provisioningdatabasemanager.h"
 #include "oic_string.h"
 #include "utlist.h"
+#include "srmutility.h"
 
 namespace OIC
 {
@@ -105,35 +106,6 @@ namespace OIC
             uuidString = uuidArray;
         }
 
-        void EnrolleeSecurity::convertStringToUUID(OicUuid_t& uuid,
-                                                              const std::string uuidString)
-        {
-            size_t outBufSize = B64DECODE_OUT_SAFESIZE((uuidString.length() + 1));
-            uint8_t* outKey = (uint8_t*)OICCalloc(1, outBufSize);
-            uint32_t outKeySize = 0;
-            if(NULL == outKey)
-            {
-                OIC_LOG (ERROR, ENROLEE_SECURITY_TAG, "Failed to memoray allocation.");
-                throw ESBadRequestException ("Failed to memoray allocation.");
-            }
-
-            if(B64_OK == b64Decode((char*)uuidString.c_str(),
-                                    uuidString.length(),
-                                    outKey,
-                                    outBufSize,
-                                    &outKeySize))
-            {
-                memcpy(uuid.id, outKey, outKeySize);
-            }
-            else
-            {
-                OIC_LOG (ERROR, ENROLEE_SECURITY_TAG, "Failed to base64 decoding.");
-                throw ESBadRequestException ("Failed to base64 decoding.");
-            }
-
-            OICFree(outKey);
-        }
-
         void EnrolleeSecurity::ownershipTransferCb(OC::PMResultList_t *result, int hasError)
         {
             if (hasError)
@@ -438,7 +410,7 @@ namespace OIC
             }
 
             OicUuid_t uuid;
-            convertStringToUUID(uuid, cloudUuid);
+            ConvertStrToUuid(cloudUuid.c_str(), &uuid);
 
             // Create Acl for Cloud Server to be provisioned to Enrollee
             OicSecAcl_t* acl = createAcl(uuid);
@@ -511,6 +483,7 @@ namespace OIC
             size_t arrLen = 1;
             rsrc->typeLen = arrLen;
             rsrc->types = (char**)OICCalloc(arrLen, sizeof(char*));
+            rsrc->interfaceLen = 1;
             rsrc->interfaces = (char**)OICCalloc(arrLen, sizeof(char*));
             rsrc->types[0] = OICStrdup("rt");   // ignore
             rsrc->interfaces[0] = OICStrdup("if");  // ignore
index 066ffae..644eddd 100755 (executable)
@@ -80,7 +80,6 @@ namespace OIC
             void ownershipTransferCb(OC::PMResultList_t *result, int hasError);
             void convertUUIDToString(const uint8_t uuid[UUID_SIZE],
                                                 std::string& uuidString);
-            void convertStringToUUID(OicUuid_t& uuid, const std::string uuidString);
 
 #if defined(__WITH_DTLS__) && defined(__WITH_TLS__)
         public: