From 6e0b5a8fab46101fd7704a8cab9e2f1792566de5 Mon Sep 17 00:00:00 2001 From: Jay Sharma Date: Thu, 24 Mar 2016 19:59:05 +0530 Subject: [PATCH] [Easy-setup] Fixed Security feature - Updated Mediator and enrollee sample applications [Android, Linux,Tizen] - Updated iotivity.spec file - Updated tizen-sdb README file Change-Id: I95a8540ced6c9b5ac5036afb2763aeb02ec24a09 Signed-off-by: Jay Sharma Reviewed-on: https://gerrit.iotivity.org/gerrit/6303 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- .../sampleapp/enrollee/linux/enrolleewifi.c | 4 +- .../tizen-sdb/EnrolleeSample/enrolleewifi.cpp | 2 +- .../sampleapp/enrollee/tizen-sdb/README.txt | 4 +- .../app/src/main/assets/oic_svr_db_client.dat | Bin 0 -> 711 bytes .../app/src/main/assets/oic_svr_db_client.json | 43 ------------- .../iotivity/service/easysetup/MainActivity.java | 2 +- .../mediator/linux/richsdk_sample/mediator_cpp.cpp | 67 +++++++++++++++------ tools/tizen/iotivity.spec | 4 +- 8 files changed, 56 insertions(+), 70 deletions(-) create mode 100644 service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.dat delete mode 100755 service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.json diff --git a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c index 33ad05d..9016ab1 100644 --- a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c +++ b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c @@ -47,7 +47,7 @@ static char passwd[] = "EasySetup123"; * It contains Server's Identity and the PSK credentials * of other devices which the server trusts */ -static char CRED_FILE[] = "oic_svr_db_server.json"; +static char CRED_FILE[] = "oic_svr_db_server.dat"; OCPersistentStorage ps ; @@ -180,7 +180,7 @@ int main() printf("EasySetup Enrollee SAMPLE\n"); printf("#########################\n"); PrintMenu(); - char option = 'T'; + char option = 'T'; while(true) { 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 fac4c5d..5783b4d 100755 --- a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp +++ b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp @@ -49,7 +49,7 @@ static char passwd[] = "EasySetup123"; * It contains Server's Identity and the PSK credentials * of other devices which the server trusts */ -static char CRED_FILE[] = "oic_svr_db_server.json"; +static char CRED_FILE[] = "oic_svr_db_server.dat"; OCPersistentStorage ps ; diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt b/service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt index f5f4f2f..4d44594 100644 --- a/service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt +++ b/service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt @@ -32,7 +32,7 @@ scons -f service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/ti ES_ROLE=enrollee ES_TARGET_ENROLLEE=android ES_SOFTAP_MODE=ENROLLEE_SOFTAP 4) If built for security mode: - After installing sample RPM on device, copy required json files and other applications to the same path where enrollee_wifi(executable) is available + After installing sample RPM on device, copy required .dat files and other applications to the same path where enrollee_wifi(executable) is available (If needed, modify the parameters accordingly) Note :- Upon successful execution of above command(s) RI library and sample console application(for tizen enrollee) @@ -59,7 +59,7 @@ Procedure to Execute Sample App: Execute the sample app by below commands i) cd /usr/apps/com.oic.es.sample/bin If executing with secure mode enabled then do the below step (no. ii) - ii) cp /usr/lib/oic_svr_db_server.json . + ii) cp /usr/lib/oic_svr_db_server.dat . Execute the application ./enrollee_wifi diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.dat b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.dat new file mode 100644 index 0000000000000000000000000000000000000000..b8d249c3e77fb17c527c029b08c1d67dca7eeeb0 GIT binary patch literal 711 zcmb7=O-{ow5QWqBDy)#AfSS1KP0B9zctRcG*z!2g?w||q!H)zdV9TXo4NfWwky44Q zX5?@D=Dm3b4%Nlv_OS?6k$;dJkaka3)QA$nH;t0~R5>KmxIpfo<=SDfPK<&iyn@3j z7tZHG75SbO9g|0i9U%5cFY#N8lnnj8>}L27syjpo3D+SvIUFTlFdVxWs5Ad>HG{k zz18+bDl+!7lz6QG|Nmcro(iucVf0Lpo{csj+r+E4*S64IRI~-F2nhTH+c0vxsVbxx Nd56)yL0b6u`UVTP_g?@2 literal 0 HcmV?d00001 diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.json b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.json deleted file mode 100755 index 1219d6a..0000000 --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "acl": [ - { - "sub": "Kg==", - "rsrc": [ - "/oic/res", - "/oic/d", - "/oic/p", - "/oic/res/types/d", - "/oic/ad", - "/oic/sec/amacl" - ], - "perms": 2, - "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="] - }, - { - "sub": "Kg==", - "rsrc": [ - "/oic/sec/doxm", - "/oic/sec/pstat" - ], - "perms": 2, - "ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="] - } - ], - "pstat": { - "isop": true, - "deviceid": "YWRtaW5EZXZpY2VVVUlEMA==", - "ch": 0, - "cm": 0, - "tm": 0, - "om": 3, - "sm": [3] - }, - "doxm": { - "oxm": [0], - "oxmsel": 0, - "sct": 1, - "owned": true, - "deviceid": "YWRtaW5EZXZpY2VVVUlEMA==", - "ownr": "YWRtaW5EZXZpY2VVVUlEMA==" - } -} diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java index d9db11e..20e6780 100755 --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java @@ -79,7 +79,7 @@ public class MainActivity extends Activity { public static final int FAILED = 1; public static final int STATE_CHANGED = 2; - 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 OIC_SQL_DB_FILE = "PDM.db"; private static final int BUFFER_SIZE = 1024; diff --git a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator_cpp.cpp b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator_cpp.cpp index ff41ecc..ec960bc 100755 --- a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator_cpp.cpp +++ b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator_cpp.cpp @@ -31,7 +31,7 @@ #define ES_SAMPLE_APP_TAG "ES_SAMPLE_APP_TAG" #define DECLARE_MENU(FUNC, ...) { #FUNC, FUNC } -#define JSON_DB_PATH "./oic_svr_db_client.json" +#define JSON_DB_PATH "./oic_svr_db_client.dat" using namespace OC; using namespace OIC::Service; @@ -42,6 +42,7 @@ static WiFiOnboadingConnection onboardingConn; static RemoteEnrollee::shared_ptr remoteEnrollee = nullptr; static std::string ipaddress, ssid, pwd; +char security; struct CloseApp { @@ -95,29 +96,57 @@ void initEasySetup() easySetupIntance = EasySetup::getInstance(); - ipaddress = "192.168.1.104"; - ssid = "hub2.4G"; - pwd = "22221111"; + cout<<"\n Enter the IP address : "; + cin>>ipaddress; + cout<<"\n Enter the Target Network SSID : "; + cin>>ssid; + cout<<"\n Enter the Target Network Password : "; + cin>>pwd; + cout<<"\n Enable Security: [Y/N] "; + cin>>security; - netInfo.connType = CT_ADAPTER_IP; - - OICStrcpy(netInfo.provData.WIFI.ssid, NET_WIFI_SSID_SIZE - 1, ssid.c_str()); - OICStrcpy(netInfo.provData.WIFI.pwd, NET_WIFI_PWD_SIZE - 1, pwd.c_str()); - - onboardingConn.isSecured = false; - OICStrcpy(onboardingConn.ipAddress, IPV4_ADDR_SIZE - 1, ipaddress.c_str()); - - try + if ( ipaddress.size() == 0 || ssid.size() == 0 || pwd.size()==0 ) { - remoteEnrollee = easySetupIntance->createEnrolleeDevice(netInfo,onboardingConn); + cout<<"\n Invalid information try again !!!"; } - catch (OCException &e) - { - std::cout << "Exception during createEnrolleeDevice call" << e.reason(); - return; + else + { + cout <<"\n Entered details are : \n"; + cout<<"\n IP address : "<createEnrolleeDevice(netInfo,onboardingConn); + } + catch (OCException &e) + { + std::cout << "Exception during createEnrolleeDevice call" << e.reason(); + return; + } + + remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback); } - remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback); } void runEasySetupMenu() { diff --git a/tools/tizen/iotivity.spec b/tools/tizen/iotivity.spec index b940b5c..9b72899 100644 --- a/tools/tizen/iotivity.spec +++ b/tools/tizen/iotivity.spec @@ -163,7 +163,7 @@ cp ./resource/csdk/security/include/pinoxmcommon.h %{buildroot}%{_includedir} cp ./resource/csdk/security/provisioning/include/oxm/*.h %{buildroot}%{_includedir} cp ./resource/csdk/security/provisioning/include/internal/*.h %{buildroot}%{_includedir} cp ./resource/csdk/security/provisioning/include/*.h %{buildroot}%{_includedir} -cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json %{buildroot}%{_libdir}/oic_svr_db_server.json +cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{buildroot}%{_libdir}/oic_svr_db_server.dat %endif @@ -216,7 +216,7 @@ cp service/easy-setup/enrollee/inc/*.h %{buildroot}%{_includedir} %if 0%{?SECURED} == 1 %{_libdir}/libocpmapi.so %{_libdir}/libocprovision.so -%{_libdir}/oic_svr_db_server.json +%{_libdir}/oic_svr_db_server.dat %endif %if 0%{?tizen_version_major} < 3 %{_datadir}/license/%{name}-service -- 2.7.4