From a998a8aaaf6a98b186413d883d6a55077ecb1b48 Mon Sep 17 00:00:00 2001 From: Senthil Kumar G S Date: Fri, 19 May 2017 20:41:10 +0530 Subject: [PATCH] Updated mediator android application for secure mode. In secure mode, mediator should send requests to the secure endpoint of the easy-setup resource. Updated the sample to handle the same. Change-Id: I5a27f06bcf2f8698d58e2b79049d7b342e303599 Signed-off-by: Senthil Kumar G S Reviewed-on: https://gerrit.iotivity.org/gerrit/20153 Reviewed-by: Jihun Ha Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../app/src/main/assets/oic_svr_db_client.dat | Bin 1392 -> 3204 bytes .../service/easysetup/EasysetupActivity.java | 27 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) 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 index 025c39b11c83829f03ee1a9d0c4171767692017e..08a76e22911995780edb6811948b057c2cc3558a 100644 GIT binary patch literal 3204 zcmeHJ%a)r)5VhmH4quT)R?!&=hQ~Dj)*hQ~oR0ho};d<@yj+;;~#GqDtHyiX`z;2o&CnZu}?^M-|DpX`BGCXwy3cZMylf zH|tUjXgIBoJ;g=($RJj8Az5tJ9>an%y2)jv@a1r?-ROjlOP@`94qa@&t7PN(#%EQp5?TD##Xfp!6FH<>%j zy)WQZJX|dtk;a4q$!stw*}~FbrIRyy>Pb}-@yr6`i%V0*<6=)=+WXjJH?~gC!7i<* zS2m2~)n)D53Q=1g>3CMtuza8gnD(;WZpueVdNTmRc(swXr*t0HXrgU%U#~_z04Qm* zH${$dBWo@a>B%uB+q_tna@@2rWb)yX9{Ad@CQ(zB%N-jH6e{N=au&ehB*5E%wY*L0 z)4^Do!vR5=gJhmzz3ECq1$O?TtJ9J)Tya!J zW~M@5(>CPdu%GPR*(jpAx@&*OIRv?ybqXB>yyKo;iP<0?{@WL28x zv?l0jJ~*jz1a@eU4cFO3Ybz_>d`q;~Yx)_ELr9d+$;k7{Q z_yz+HIt#?BX z_B~-Lqbpzb89P~2$3?LoqGE|_xD;q9GPXct%t^bI76n;ALL)eMSao_b!@9Ta4l2U? z&F+bpp)$uN{ypd#YLS~By6c>srjN5C$F><}Np(coZG$G?J{O(*$KSg(E5pyjt_NrR zZXYXfpC{ckaQl{-qc}Js+q7fj>94QcRt7o#(J^h5zj%57GBCdjGL$Dp)~@{U%JDPg z`h#|xL94y9Ysvyts|-aE`9Ms0L0_AMQA1{qyugr}h`K;~h5ba@c{Rj$zinoj-)W zAK%{+`0>|{_X^MlKx@YhbIV{MF6x@Wai=9SQ z1g;8IS1clXl6iXi=Gj?eAG3Ssay8W}m8$o$0v`h<&8f_T7_fScFi%sp%pmqtp1PQU zFQ@>?bAdrVuSg^yjJllSu6`Q`Rm6Jl&1aq|X;@HG($HfJ3t$gBL0AfiX^*OQqMM(1 z)g1T|7)_!4sKw%kHmhs1 fYJ#C9o0z~O#qfJ-rUic-)JbgRpYQNh*>1l8TU!f= diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java index 5cadbcb..0ef8f42 100755 --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java @@ -88,9 +88,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; +import java.util.Iterator; import java.util.List; - public class EasysetupActivity extends Activity implements OcPlatform.OnPresenceListener, OcResource.OnObserveListener{ @@ -422,6 +422,31 @@ public class EasysetupActivity extends Activity Log.d(TAG,"URI of the resource: " + resourceUri); Log.d(TAG,"Host address of the resource: " + hostAddress); + if(mSecurityMode.isChecked()) + { + // Change the host of the resource to secure endpoint. + List endpoints = ocResource.getAllHosts(); + if(null != endpoints || 0 == endpoints.size()) + { + Log.d(TAG, "Endpoints of the resource: " + endpoints); + Iterator itr = endpoints.iterator(); + while(itr.hasNext()) + { + String endpoint = itr.next(); + if(null != endpoint && endpoint.contains("coaps://")) + { + String retval = ocResource.setHost(endpoint); + Log.d(TAG, "Found coaps endpoint: setHost() returned " + retval); + break; + } + } + } + else + { + Log.d(TAG, "No endpoints found"); + } + } + mRemoteEnrollee = mEasySetup.createRemoteEnrollee(ocResource); if(mRemoteEnrollee == null) { -- 2.7.4