[Easy-setup] Fixed Security feature
authorJay Sharma <jay.sharma@samsung.com>
Thu, 24 Mar 2016 14:29:05 +0000 (19:59 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Thu, 24 Mar 2016 23:06:37 +0000 (23:06 +0000)
 - 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 <jay.sharma@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6303
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp
service/easy-setup/sampleapp/enrollee/tizen-sdb/README.txt
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.dat [new file with mode: 0644]
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.json [deleted file]
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/MainActivity.java
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator_cpp.cpp
tools/tizen/iotivity.spec

index 33ad05d..9016ab1 100644 (file)
@@ -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)
     {
index fac4c5d..5783b4d 100755 (executable)
@@ -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 ;
 
index f5f4f2f..4d44594 100644 (file)
@@ -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 (file)
index 0000000..b8d249c
Binary files /dev/null and b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/assets/oic_svr_db_client.dat differ
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 (executable)
index 1219d6a..0000000
+++ /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=="
-       }
-}
index d9db11e..20e6780 100755 (executable)
@@ -79,7 +79,7 @@ public class MainActivity extends Activity {
     public static final int FAILED        = 1;\r
     public static final int STATE_CHANGED = 2;\r
 \r
-    public static final String OIC_CLIENT_JSON_DB_FILE =  "oic_svr_db_client.json";\r
+    public static final String OIC_CLIENT_JSON_DB_FILE =  "oic_svr_db_client.dat";\r
     public static final String OIC_SQL_DB_FILE =  "PDM.db";\r
 \r
     private static final int BUFFER_SIZE = 1024;\r
index ff41ecc..ec960bc 100755 (executable)
@@ -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 : "<<ipaddress;
+           cout<<"\n Target Network SSID : "<<ssid;
+           cout<<"\n Target Network Password : "<<pwd;
+
+          if (security == 'Y' || security == 'y' )
+          {
+                  onboardingConn.isSecured = true;
+                  cout<<"\n Security is Enabled\n\n\n";
+           }
+           else
+           {
+                 onboardingConn.isSecured = false;
+                 cout<<"\n Security is not Enabled\n\n\n";
+           }
+
+          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());
+
+         OICStrcpy(onboardingConn.ipAddress, IPV4_ADDR_SIZE - 1, ipaddress.c_str());
+
+         try
+         {
+             remoteEnrollee = easySetupIntance->createEnrolleeDevice(netInfo,onboardingConn);
+         }
+         catch (OCException &e)
+         {
+             std::cout << "Exception during createEnrolleeDevice call" << e.reason();
+             return;
+         }
+
+         remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback);
     }
 
-    remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback);
 }
 void runEasySetupMenu()
 {
index b940b5c..9b72899 100644 (file)
@@ -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