From: saurabh.s9 Date: Mon, 29 Feb 2016 08:10:52 +0000 (+0530) Subject: IoTivity Security bug fix and enable security api usage in easysetup Android app X-Git-Tag: 1.2.0+RC1~597^2^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a9d53f35cae085ba9c147114ab9b8db639a97a6;p=platform%2Fupstream%2Fiotivity.git IoTivity Security bug fix and enable security api usage in easysetup Android app - IoTivity bug is fixed by changing IoTivity security libraries from static to dynamic https://jira.iotivity.org/browse/IOT-956 - Enabled Security api usage in Easysetup Android app Change-Id: Id4296c724968cdfe52c673e5ea1696afa0346238 Signed-off-by: lankamadan Signed-off-by: saurabh.s9 Reviewed-on: https://gerrit.iotivity.org/gerrit/5181 Reviewed-by: Ashwini Kumar Tested-by: jenkins-iotivity --- diff --git a/android/android_api/base/jni/Android.mk b/android/android_api/base/jni/Android.mk index e07b671..0381ca4 100644 --- a/android/android_api/base/jni/Android.mk +++ b/android/android_api/base/jni/Android.mk @@ -30,14 +30,14 @@ ifeq ($(SECURED), 1) include $(CLEAR_VARS) OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) LOCAL_MODULE := libandroid-ocprovision -LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocprovision.a -include $(PREBUILT_STATIC_LIBRARY) +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocprovision.so +include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) OIC_LIB_PATH := ../../../../out/android/$(APP_ABI)/$(APP_OPTIM) LOCAL_MODULE := libandroid-ocpmapi -LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocpmapi.a -include $(PREBUILT_STATIC_LIBRARY) +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocpmapi.so +include $(PREBUILT_SHARED_LIBRARY) endif include $(CLEAR_VARS) diff --git a/resource/csdk/security/provisioning/SConscript b/resource/csdk/security/provisioning/SConscript index 0fcd36e..0e741c4 100644 --- a/resource/csdk/security/provisioning/SConscript +++ b/resource/csdk/security/provisioning/SConscript @@ -62,7 +62,7 @@ if target_os not in ['windows', 'winrt']: # Note: 'pthread' is in libc for android. On other platform, if use # new gcc(>4.9?) it isn't required, otherwise, it's required if target_os != 'android': - provisioning_env.AppendUnique(LIBS = ['-lpthread']) + provisioning_env.AppendUnique(LIBS = ['-lpthread', '-ldl']) provisioning_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) @@ -73,7 +73,10 @@ provisioning_env.AppendUnique(LIBS = ['tinydtls']) if env.get('DTLS_WITH_X509') == '1': provisioning_env.AppendUnique(LIBS = ['CKManger']) -provisioning_env.ParseConfig('pkg-config --libs glib-2.0'); +#TODO : Have to remove this comment after 1st level of review +#This change needs a review. +if target_os != 'android': + provisioning_env.ParseConfig('pkg-config --libs glib-2.0'); if target_os == 'android': provisioning_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) @@ -98,7 +101,7 @@ provisioning_src = [ 'src/oxmrandompin.c', 'src/provisioningdatabasemanager.c', root_dir+'/extlibs/sqlite3/sqlite3.c' ] -provisioningserver = provisioning_env.StaticLibrary('ocpmapi', provisioning_src) +provisioningserver = provisioning_env.SharedLibrary('ocpmapi', provisioning_src) provisioning_env.InstallTarget(provisioningserver, 'libocpmapi') diff --git a/resource/provisioning/SConscript b/resource/provisioning/SConscript old mode 100644 new mode 100755 index a7c035d..ecda825 --- a/resource/provisioning/SConscript +++ b/resource/provisioning/SConscript @@ -43,7 +43,11 @@ if target_os not in ['windows', 'winrt']: if target_os == 'android': ocprovision_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) ocprovision_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) - ocprovision_env.AppendUnique(LIBS = ['ocspapi', 'octbstack', 'oc_logger', 'boost_thread', 'gnustl_shared', 'log']) + ocprovision_env.AppendUnique(LIBS = ['oc', 'ocpmapi', 'oc_logger', 'boost_thread', 'gnustl_shared', 'log']) + +if target_os == 'linux': + ocprovision_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) + ocprovision_env.AppendUnique(LIBS = ['oc', 'octbstack', 'ocpmapi', 'oc_logger', 'boost_thread']) if target_os in ['darwin', 'ios']: ocprovision_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) @@ -56,7 +60,7 @@ ocprovision_src = [ 'src/OCProvisioningManager.cpp' ] -ocprovision = ocprovision_env.StaticLibrary('ocprovision', ocprovision_src) +ocprovision = ocprovision_env.SharedLibrary('ocprovision', ocprovision_src) ocprovision_env.InstallTarget(ocprovision, 'libocprovision') if target_os in ['linux']: diff --git a/resource/provisioning/examples/SConscript b/resource/provisioning/examples/SConscript index 184a73a..e701b47 100644 --- a/resource/provisioning/examples/SConscript +++ b/resource/provisioning/examples/SConscript @@ -26,6 +26,9 @@ Import('env') lib_env = env.Clone() SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env') +with_ra = env.get('WITH_RA') +with_ra_ibb = env.get('WITH_RA_IBB') + examples_env = lib_env.Clone() ###################################################################### @@ -55,8 +58,19 @@ examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) examples_env.AppendUnique(RPATH = [env.get('BUILD_DIR')]) examples_env.PrependUnique(LIBS = ['ocprovision', 'oc', 'ocpmapi', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap']) +if with_ra_ibb: + examples_env.AppendUnique(LIBS = examples_env['RALIBS'], LIBPATH = examples_env['RALIBPATH'], RPATH = examples_env['RARPATH']) + print "RALIBS = %s" % examples_env['RALIBS'] + print "RALIBPATH = %s" % examples_env['RALIBPATH'] + print "RARPATH = %s" % examples_env['RARPATH'] + examples_env.AppendUnique(LIBS = 'wksxmppxep') +else : + if with_ra: + examples_env.AppendUnique(LIBS = ['ra_xmpp']) + if env.get('SECURED') == '1': examples_env.AppendUnique(LIBS = ['tinydtls']) + examples_env.AppendUnique(LIBS = ['timer']) if env.get('DTLS_WITH_X509') == '1': examples_env.AppendUnique(LIBS = ['CKManager']) examples_env.AppendUnique(LIBS = ['asn1']) diff --git a/resource/provisioning/unittests/SConscript b/resource/provisioning/unittests/SConscript old mode 100644 new mode 100755 index 20f2a19..3582960 --- a/resource/provisioning/unittests/SConscript +++ b/resource/provisioning/unittests/SConscript @@ -24,6 +24,8 @@ import os.path provisiontests_env = env.Clone() src_dir = provisiontests_env.get('SRC_DIR') +with_ra = env.get('WITH_RA') +with_ra_ibb = env.get('WITH_RA_IBB') ###################################################################### # Build flags ###################################################################### @@ -62,8 +64,18 @@ provisiontests_env.PrependUnique(LIBS = [ 'gtest_main', ]) +if with_ra_ibb: + provisiontests_env.AppendUnique(LIBS = provisiontests_env['RALIBS'], LIBPATH = provisiontests_env['RALIBPATH'], RPATH = provisiontests_env['RARPATH']) + print "RALIBS = %s" % provisiontests_env['RALIBS'] + print "RALIBPATH = %s" % provisiontests_env['RALIBPATH'] + print "RARPATH = %s" % provisiontests_env['RARPATH'] +else : + if with_ra: + provisiontests_env.AppendUnique(LIBS = ['ra_xmpp']) + if env.get('SECURED') == '1': provisiontests_env.AppendUnique(LIBS = ['tinydtls']) + provisiontests_env.AppendUnique(LIBS = ['timer']) if env.get('DTLS_WITH_X509') == '1': provisiontests_env.AppendUnique(LIBS = ['CKManager']) provisiontests_env.AppendUnique(LIBS = ['asn1']) diff --git a/service/easy-setup/mediator/csdk/SConscript b/service/easy-setup/mediator/csdk/SConscript index e68538f..675ab6b 100644 --- a/service/easy-setup/mediator/csdk/SConscript +++ b/service/easy-setup/mediator/csdk/SConscript @@ -94,7 +94,7 @@ if target_os in ['android','linux']: env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include', env.get('SRC_DIR') + '/resource/csdk/connectivity/common/inc', env.get('SRC_DIR') + '/resource/csdk/connectivity/api', - env.get('SRC_DIR') + '/resource/csdk/stack/include', + env.get('SRC_DIR') + '/resource/csdk/stack/include', env.get('SRC_DIR') + '/resource/csdk/security/include', env.get('SRC_DIR') + '/extlibs/cjson', env.get('SRC_DIR') + '/service/easy-setup/inc', diff --git a/service/easy-setup/mediator/richsdk/SConscript b/service/easy-setup/mediator/richsdk/SConscript index 71364d0..c5d2317 100644 --- a/service/easy-setup/mediator/richsdk/SConscript +++ b/service/easy-setup/mediator/richsdk/SConscript @@ -62,30 +62,36 @@ easy_setup_env.AppendUnique(CPPPATH = ['inc', 'src', '../../inc']) if target_os not in ['windows', 'winrt']: easy_setup_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x']) -if target_os == 'linux': +if target_os in ['linux']: easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl']) if target_os in ['android']: easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) + if env.get('SECURED') == '1': + easy_setup_env.AppendUnique(LIBPATH = [env.get('SRC_DIR')+'/android/android_api/base/libs/armeabi']) easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')]) easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared']) + if env.get('SECURED') == '1': + easy_setup_env.AppendUnique(LIBS = ['ocpmapi','ocprovision']) if not env.get('RELEASE'): easy_setup_env.AppendUnique(LIBS = ['log']) -if target_os == 'linux': +if target_os in ['linux']: easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')]) easy_setup_env.AppendUnique(CXXFLAGS = ['-pthread']) easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction']) + if env.get('SECURED') == '1': + easy_setup_env.AppendUnique(LIBS = ['ocpmapi', 'ocprovision']) if target_os in ['android','linux']: easy_setup_env.PrependUnique(CPPPATH = [ env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include', env.get('SRC_DIR') + '/resource/include', env.get('SRC_DIR') + '/resource/csdk/logger/include', - env.get('SRC_DIR') + '/resource/csdk/stack/include', - env.get('SRC_DIR') + '/resource/csdk/logger/include', + env.get('SRC_DIR') + '/resource/csdk/stack/include', + env.get('SRC_DIR') + '/resource/csdk/logger/include', env.get('SRC_DIR') + '/resource/csdk/security/include', env.get('SRC_DIR') + '/extlibs/cjson', env.get('SRC_DIR') + '/extlibs/sqlite3', @@ -96,8 +102,6 @@ if target_os in ['android','linux']: env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include', env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal', env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/oxm']) - easy_setup_env.PrependUnique(LIBS = ['ocprovision', 'ocpmapi']) - ###################################################################### # Source files and Targets diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java index 336edca..cdf60d5 100755 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EasySetupService.java @@ -57,9 +57,6 @@ public class EasySetupService { static { // Load Easy Setup JNI interface - System.loadLibrary("gnustl_shared"); - System.loadLibrary("octbstack"); - System.loadLibrary("connectivity_abstraction"); System.loadLibrary("ESMediatorRich"); System.loadLibrary("easysetup-jni"); } diff --git a/service/easy-setup/mediator/richsdk/android/jni/Android.mk b/service/easy-setup/mediator/richsdk/android/jni/Android.mk index 174daf2..87518ac 100644 --- a/service/easy-setup/mediator/richsdk/android/jni/Android.mk +++ b/service/easy-setup/mediator/richsdk/android/jni/Android.mk @@ -2,14 +2,8 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) OIC_LIB_PATH := ../../../../../../out/android/$(TARGET_ARCH_ABI)/debug -LOCAL_MODULE := android-octbstack -LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboctbstack.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -OIC_LIB_PATH := ../../../../../../out/android/$(TARGET_ARCH_ABI)/debug -LOCAL_MODULE := android-connectivity_abstraction -LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so +LOCAL_MODULE := android-oc +LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc.so include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -59,8 +53,8 @@ LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/*.cpp LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/*.h)) LOCAL_LDLIBS := -llog -LOCAL_SHARED_LIBRARIES += android-connectivity_abstraction -LOCAL_SHARED_LIBRARIES += android-octbstack +#LOCAL_SHARED_LIBRARIES += android-connectivity_abstraction +LOCAL_SHARED_LIBRARIES += android-oc LOCAL_SHARED_LIBRARIES += android-easysetup include $(BUILD_SHARED_LIBRARY) diff --git a/service/easy-setup/sampleapp/enrollee/linux/SConscript b/service/easy-setup/sampleapp/enrollee/linux/SConscript index 03d77fb..6ae239c 100644 --- a/service/easy-setup/sampleapp/enrollee/linux/SConscript +++ b/service/easy-setup/sampleapp/enrollee/linux/SConscript @@ -56,6 +56,8 @@ enrollee_env.PrependUnique(CPPPATH = [ env.get('SRC_DIR') + '/service/easy-setup/enrollee/src']) enrollee_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'ocsrm', 'pthread', 'connectivity_abstraction','coap', 'ESEnrolleeSDK']) +if enrollee_env.get('SECURED') == '1': + enrollee_env.PrependUnique(LIBS = ['ocpmapi', 'ocprovision']) enrollee = enrollee_env.Program('enrollee', 'enrolleewifi.cpp') diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp index 31b304f..caf0020 100755 --- a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp +++ b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp @@ -50,6 +50,9 @@ static char passwd[] = "EasySetup123"; */ static char CRED_FILE[] = "oic_svr_db_server.json"; +OCPersistentStorage ps ; + + /** * @var gIsSecured * @brief Variable to check if secure mode is enabled or not. @@ -59,8 +62,8 @@ static bool gIsSecured = false; void PrintMenu() { cout<<"============"< + +