Modified Android to resolve
authorSandeep Sharma <sandeep.s9@samsung.com>
Mon, 28 Mar 2016 15:03:25 +0000 (20:33 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Tue, 29 Mar 2016 04:46:36 +0000 (04:46 +0000)
1. Build Issue with SECURED=1
2. Run time library loading Issue with SECURED=0
3. Updated DAT file for android sample provisioning client app.

PS: Currently both SECURED=0 and SECURED=1 build is successful
    but run time loading is failing for SECURED=1.

Change-Id: I8b88092e682f2c3095ba0ccc4f81f4f40d205490
Signed-off-by: Sandeep Sharma <sandeep.s9@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7407
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
14 files changed:
android/android_api/SConscript
android/android_api/base/jni/Android.mk
android/android_api/base/jni/JniOcStack.cpp
android/android_api/base/jni/JniOcStack.h
android/android_api/base/jni/JniSecureUtils.cpp
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/base/OicSecAcl.java
android/examples/provisioningclient/src/main/assets/oic_svr_db_client.dat [new file with mode: 0644]
android/examples/provisioningclient/src/main/assets/oic_svr_db_client.json
android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java
android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/StringConstants.java
android/examples/settings.gradle
resource/provisioning/SConscript
resource/provisioning/src/OCProvisioningManager.cpp

index 38fd526..32ffb22 100644 (file)
@@ -48,11 +48,11 @@ def ensure_libs(target, source, env):
 
 # build android_api
 jdk_env = Environment(ENV=os.environ)
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), emitter = ensure_libs)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED, ANDROID_SECURED), emitter = ensure_libs)
 jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
 cmdBuildApi=jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java")
 
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED))
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED, ANDROID_SECURED))
 cmdBuildExamples=jdk_env.Gradle(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java")
 
 # android examples require android api to be built before being invoked
index 08f2b79..cc43275 100644 (file)
@@ -106,10 +106,12 @@ LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/stack/include
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/ocsocket/include\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/oc_logger/include\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/boost/boost_1_58_0\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/cjson\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../build_common/android/compatibility\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/oxm/\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/internal\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/include\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/api\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/lib/libcoap-4.1.1\r
 include $(BUILD_SHARED_LIBRARY)\r
index affc4dd..c5c3d7d 100644 (file)
@@ -102,8 +102,7 @@ jmethodID g_mid_OcOicSecAcl_get_permission = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_periods_cnt = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_periods = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_recurrences = nullptr;
-jmethodID g_mid_OcOicSecAcl_get_owners_cnt = nullptr;
-jmethodID g_mid_OcOicSecAcl_get_owners = nullptr;
+jmethodID g_mid_OcOicSecAcl_get_rownerID = nullptr;
 
 jobject getOcException(JNIEnv* env, const char* file, const char* functionName,
     const int line, const int code, const char* message)
@@ -458,11 +457,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
     g_mid_OcOicSecAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecAcl, "getRecurrences", "(I)Ljava/lang/String;");
     if (!g_mid_OcOicSecAcl_get_recurrences) return JNI_ERR;
 
-    g_mid_OcOicSecAcl_get_owners_cnt = env->GetMethodID(g_cls_OcOicSecAcl, "getOwnersCount", "()I");
-    if (!g_mid_OcOicSecAcl_get_owners_cnt) return JNI_ERR;
-
-    g_mid_OcOicSecAcl_get_owners = env->GetMethodID(g_cls_OcOicSecAcl, "getOwners", "(I)Ljava/lang/String;");
-    if (!g_mid_OcOicSecAcl_get_owners) return JNI_ERR;
+    g_mid_OcOicSecAcl_get_rownerID = env->GetMethodID(g_cls_OcOicSecAcl, "getRownerID", "()Ljava/lang/String;");
+    if (!g_mid_OcOicSecAcl_get_rownerID) return JNI_ERR;
 
     return JNI_CURRENT_VERSION;
 }
index 79ede36..b9f2ccd 100644 (file)
@@ -121,8 +121,7 @@ extern jmethodID g_mid_OcOicSecAcl_get_permission;
 extern jmethodID g_mid_OcOicSecAcl_get_periods_cnt;
 extern jmethodID g_mid_OcOicSecAcl_get_periods;
 extern jmethodID g_mid_OcOicSecAcl_get_recurrences;
-extern jmethodID g_mid_OcOicSecAcl_get_owners_cnt;
-extern jmethodID g_mid_OcOicSecAcl_get_owners;
+extern jmethodID g_mid_OcOicSecAcl_get_rownerID;
 
 typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener);
 
index dc7ca43..24e4f57 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "JniSecureUtils.h"
 #include "JniOcSecureResource.h"
+#include "srmutility.h"
 #include "base64.h"
 
 jobject JniSecureUtils::convertProvisionresultVectorToJavaList(JNIEnv *env, const OC::PMResultList_t *result)
@@ -107,16 +108,6 @@ std::string JniSecureUtils::convertUUIDtoStr(OicUuid_t uuid)
     return deviceId.str();
 }
 
-void JniSecureUtils::convertStrToUUID(char *str, OicUuid_t &uuid)
-{
-    unsigned char base64Buff[sizeof(((OicUuid_t*)0)->id)] = {};
-    uint32_t outLen = 0;
-    B64Result b64Ret = B64_OK;
-
-    b64Ret = b64Decode(str, strlen(str), base64Buff, sizeof(base64Buff), &outLen);
-    memcpy(uuid.id, base64Buff, outLen);
-}
-
 jobject JniSecureUtils::convertUUIDVectorToJavaStrList(JNIEnv *env, UuidList_t &vector)
 {
     jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
@@ -153,8 +144,14 @@ OCStackResult JniSecureUtils::convertJavaACLToOCAcl(JNIEnv *env, jobject in, Oic
     }
 
     char *str = (char*) env->GetStringUTFChars(jData, 0);
-    convertStrToUUID(str, acl->subject);
-    env->ReleaseStringUTFChars(jData, str);
+    if (OC_STACK_OK == ConvertStrToUuid(str, &acl->subject))
+    {
+        env->ReleaseStringUTFChars(jData, str);
+    }
+    else
+    {
+        return OC_STACK_ERROR;
+    }
 
     jint jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecAcl_get_resources_cnt);
     if (!jCount || env->ExceptionCheck())
@@ -216,31 +213,22 @@ OCStackResult JniSecureUtils::convertJavaACLToOCAcl(JNIEnv *env, jobject in, Oic
         acl->recurrences[i] = (char*) env->GetStringUTFChars(jData, 0);
     }
 
-    jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecAcl_get_owners_cnt);
-    if (!jCount ||  env->ExceptionCheck())
+    jData = (jstring) env->CallObjectMethod(in, g_mid_OcOicSecAcl_get_rownerID);
+    if (!jData || env->ExceptionCheck())
     {
         return OC_STACK_ERROR;
     }
 
-    acl->ownersLen = jCount;
-    acl->owners = new OicUuid_t[acl->ownersLen];
-    if (!acl->owners)
-    {
-        return OC_STACK_ERROR;
-    }
+    str = (char*) env->GetStringUTFChars(jData, 0);
 
-    for (jint i = 0; i < jCount; ++i)
+    if (OC_STACK_OK == ConvertStrToUuid(str, &acl->rownerID))
     {
-        args[0].i = i;
-        jData = (jstring) env->CallObjectMethodA(in, g_mid_OcOicSecAcl_get_owners, args);
-        if (!jData ||  env->ExceptionCheck())
-        {
-            return OC_STACK_ERROR;
-        }
-
-        str = (char*) env->GetStringUTFChars(jData, 0);
-        convertStrToUUID(str, acl->owners[i]);
         env->ReleaseStringUTFChars(jData, str);
     }
+    else
+    {
+        return OC_STACK_ERROR;
+    }
+
     return OC_STACK_OK;
 }
index 381f36b..d0aa37d 100644 (file)
@@ -40,7 +40,7 @@ public final class OcPlatform {
         System.loadLibrary("octbstack");
         System.loadLibrary("connectivity_abstraction");
         System.loadLibrary("oc");
-        System.loadLibrary("ocprovision");
+        //System.loadLibrary("ocprovision");
         System.loadLibrary("ocstack-jni");
     }
 
index 5ca6d96..a47ffaa 100644 (file)
@@ -33,16 +33,16 @@ public class OicSecAcl implements Serializable {
     private List<String> resources;
     private List<String> periods;
     private List<String> recurrences;
-    private List<String> owners;
+    private String rownerID;
 
     public OicSecAcl(String subject, List<String> recurrences, List<String> periods, int permission,
-            List<String> resources, List<String> owners) {
+            List<String> resources, String rownerID) {
         this.subject = subject;
         this.recurrences = recurrences;
         this.periods = periods;
         this.permission = permission;
         this.resources = resources;
-        this.owners = owners;
+        this.rownerID = rownerID;
     }
 
     public String getSubject() {
@@ -53,12 +53,9 @@ public class OicSecAcl implements Serializable {
         this.subject = subject;
     }
 
-    public List<String> getOwners() {
-        return owners;
-    }
 
-    public void setOwners(List<String> owners) {
-        this.owners = owners;
+    public void setRownerID(String rownerID) {
+        this.rownerID = rownerID;
     }
 
     public List<String> getRecurrences() {
@@ -113,11 +110,7 @@ public class OicSecAcl implements Serializable {
         return this.recurrences.get(i);
     }
 
-    public int getOwnersCount() {
-        return this.owners.size();
-    }
-
-    public String getOwners(int i) {
-        return this.owners.get(i);
+    public String getRownerID() {
+        return this.rownerID;
     }
 }
diff --git a/android/examples/provisioningclient/src/main/assets/oic_svr_db_client.dat b/android/examples/provisioningclient/src/main/assets/oic_svr_db_client.dat
new file mode 100644 (file)
index 0000000..b8d249c
Binary files /dev/null and b/android/examples/provisioningclient/src/main/assets/oic_svr_db_client.dat differ
index 1089925..22dfeba 100644 (file)
@@ -36,7 +36,7 @@
                             "if": ""\r
                         },\r
                         {\r
-                            "href": "/oic/sec/acl",\r
+                            "href": "/oic/sec/amacl",\r
                             "rel": "",\r
                             "rt": "",\r
                             "if": ""\r
                             "rel": "",\r
                             "rt": "",\r
                             "if": ""\r
-                        } ,\r
+                        },\r
                         {\r
                             "href": "/oic/sec/pstat",\r
                             "rel": "",\r
                             "rt": "",\r
                             "if": ""\r
-                        }\r
+                        }                  \r
                     ],\r
                     "permission": 2\r
                 }\r
             ]\r
         },\r
-        "rowneruuid" : "61646d69-6e44-6576-6963-655555494430"\r
-    },\r
+        "rowneruuid" : "61646D69-6E44-6576-6963-655575696430"\r
+    },    \r
     "pstat": {\r
         "isop": true,\r
-        "deviceuuid": "61646d69-6e44-6576-6963-655555494430",\r
-        "rowneruuid": "61646d69-6e44-6576-6963-655555494430",\r
-        "cm": 0,\r
+        "cm": 2,\r
         "tm": 0,\r
         "om": 3,\r
-        "sm": 3\r
-        },\r
+        "sm": 3,\r
+        "deviceuuid": "61646D69-6E44-6576-6963-655575696430",\r
+        "rowneruuid": "61646D69-6E44-6576-6963-655575696430"\r
+    },\r
     "doxm": {\r
         "oxms": [0],\r
         "oxmsel": 0,\r
         "sct": 1,\r
         "owned": true,\r
-        "deviceuuid": "61646d69-6e44-6576-6963-655555494430",\r
-        "devowneruuid": "61646d69-6e44-6576-6963-655555494430",\r
-        "rowneruuid": "61646d69-6e44-6576-6963-655555494430",\r
-        "dpc": false\r
+        "deviceuuid": "61646D69-6E44-6576-6963-655575696430",\r
+        "dpc": false,\r
+        "devowneruuid": "61646D69-6E44-6576-6963-655575696430",\r
+        "rowneruuid": "61646D69-6E44-6576-6963-655575696430"\r
     }\r
-}
\ No newline at end of file
+}\r
index df92e2f..bc590b0 100644 (file)
@@ -198,17 +198,17 @@ public class ProvisioningClient extends Activity implements
             newSecureResource = ownedDeviceList.get(0);
             OcSecureResource newSecureResource2 = ownedDeviceList.get(1);
             List<String> resources = new ArrayList<String>();
-            List<String> owners = new ArrayList<String>();
             List<String> periods = new ArrayList<String>();
             List<String> recurrences = new ArrayList<String>();
+            String rownerID= "61646d69-6e44-6576-6963-655555494430";
             recurrences.add("Daily");
             resources.add("*");
-            owners.add("adminDeviceUUID0");
+            //owners.add("adminDeviceUUID0");
             periods.add("01-01-15");
             OicSecAcl acl1 = new OicSecAcl(newSecureResource.getDeviceID(), recurrences, periods,
-                    31, resources, owners);
+                    31, resources, rownerID);
             OicSecAcl acl2 = new OicSecAcl(newSecureResource2.getDeviceID(), recurrences, periods,
-                    31, resources, owners);
+                    31, resources, rownerID);
             newSecureResource.provisionPairwiseDevices(EnumSet.of(CredType.SYMMETRIC_PAIR_WISE_KEY),
                     KeySize.OWNER_PSK_LENGTH_128, acl1, newSecureResource2, acl2, this);
         } catch (Exception e) {
@@ -369,15 +369,18 @@ public class ProvisioningClient extends Activity implements
                     OcSecureResource ocSecureResourceDest = ownedDeviceList.get(1);
                     publishProgress(TAG + "ACL Provision for " + ocSecureResource.getDeviceID());
                     List<String> resources = new ArrayList<String>();
-                    List<String> owners = new ArrayList<String>();
+                    
                     List<String> periods = new ArrayList<String>();
                     List<String> recurrences = new ArrayList<String>();
+
+                    String rownerID="61646d69-6e44-6576-6963-655555494430";
+
                     recurrences.add("Daily");
                     resources.add("*");
-                    owners.add("adminDeviceUUID0");
+                    
                     periods.add("01-01-15");
                     OicSecAcl aclObject = new OicSecAcl(ocSecureResourceDest.getDeviceID(),
-                            recurrences, periods, 31, resources, owners);
+                            recurrences, periods, 31, resources, rownerID);
                     ocSecureResource.provisionACL(aclObject, provisionAclListener);
                 } else {
                     publishProgress(TAG + "No Owned devices present");
index 9c9baed..7199913 100644 (file)
@@ -6,7 +6,7 @@ public interface StringConstants {
     public static final int DISCOVERY_TIMEOUT_10 =  10;
     public static final int DISCOVERY_TIMEOUT_20 =  20;
     public static final int ERROR_CODE =  1;
-    public static final String OIC_CLIENT_JSON_DB_FILE =  "oic_svr_db_client.json";
+    public static final String OIC_CLIENT_JSON_DB_FILE =  "oic_svr_db_client.dat";
     public static final String MESSAGE = "message";
     public static final String OIC_SQL_DB_FILE =  "Pdm.db";
     public static final int  CREDENTIAL_TYPE=1;
index ded7b86..5a0364c 100755 (executable)
@@ -1 +1,5 @@
-include ':simpleserver', ':simpleclient', ':fridgeserver', ':fridgeclient', ':guiclient', ':provisioningclient', ':presenceserver', ':presenceclient', ':devicediscoveryclient', ':devicediscoveryserver', ':groupclient', ':groupserver', ':fridgegroupclient', ':fridgegroupserver'
+include ':simpleserver', ':simpleclient', ':fridgeserver', ':fridgeclient', ':guiclient', ':presenceserver', ':presenceclient', ':devicediscoveryclient', ':devicediscoveryserver', ':groupclient', ':groupserver', ':fridgegroupclient', ':fridgegroupserver'
+SECURED=System.getProperty('SECURE')
+if(SECURED== "1"){
+        include ':provisioningclient'
+}
index 8fb7905..05186c1 100644 (file)
@@ -34,7 +34,9 @@ ocprovision_env.AppendUnique(CPPPATH = [
                '../csdk/security/include',
                '../csdk/security/provisioning/include',
                '../csdk/security/provisioning/include/oxm',
-               '../csdk/security/provisioning/include/internal'
+               '../csdk/security/provisioning/include/internal',
+        '../csdk/connectivity/lib/libcoap-4.1.1/',
+        '../../extlibs/cjson/'
                ])
 
 target_os = env.get('TARGET_OS')
index 751ed44..8a2c076 100644 (file)
@@ -19,6 +19,7 @@
  * *****************************************************************/
 
 #include "ocstack.h"
+#include "srmutility.h"
 #include "base64.h"
 #include "OCProvisioningManager.h"
 
@@ -489,18 +490,18 @@ namespace OC
 
     std::string OCSecureResource::getDeviceID()
     {
-        char base64Buff[B64ENCODE_OUT_SAFESIZE(sizeof(((OicUuid_t*)0)->id)) + 1] = {0,};
-        uint32_t outLen = 0;
-        B64Result b64Ret = B64_OK;
         std::ostringstream deviceId("");
+        char *devID = nullptr;
 
         validateSecureResource();
-        b64Ret = b64Encode(devPtr->doxm->deviceID.id, sizeof(devPtr->doxm->deviceID.id), base64Buff,
-                sizeof(base64Buff), &outLen);
 
-        if (B64_OK == b64Ret)
+        if (OC_STACK_OK == ConvertUuidToStr(&(devPtr->doxm->deviceID), &devID))
         {
-            deviceId << base64Buff;
+            deviceId << devID;
+        }
+        else
+        {
+            oclog() <<"Can not convert uuid to struuid";
         }
         return deviceId.str();
     }