X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Feasy-setup%2Fmediator%2Frichsdk%2Fandroid%2FEasySetupCore%2Fsrc%2Fmain%2Fjava%2Forg%2Fiotivity%2Fservice%2Feasysetup%2Fmediator%2FCloudProp.java;h=22a2acb7e7cf8542d410daf5b40f2852b9f77b4d;hb=c315c87e07c4080ecd0ef488e7a1047bc3c509b2;hp=008828c02af6067129543b50fa31301bbf44200e;hpb=edcfc3d2329da7b914771c0dcff5f42c9b74fd93;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java index 008828c..22a2acb 100755 --- a/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java +++ b/service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/CloudProp.java @@ -22,6 +22,8 @@ package org.iotivity.service.easysetup.mediator; import android.util.Log; +import org.iotivity.service.easysetup.mediator.enums.OAUTH_TOKENTYPE; + import org.iotivity.base.OcException; import org.iotivity.base.OcRepresentation; @@ -65,6 +67,31 @@ public class CloudProp { } } + public void setCloudPropWithAccessToken(String accessToken, OAUTH_TOKENTYPE tokenType, + String authProvider, String ciServer) + { + if(accessToken == null) + { + accessToken = ""; + } + if(authProvider == null) + { + authProvider = ""; + } + if(ciServer == null) + { + ciServer = ""; + } + try { + mRep.setValue(ESConstants.OC_RSRVD_ES_ACCESSTOKEN, accessToken); + mRep.setValue(ESConstants.OC_RSRVD_ES_ACCESSTOKEN_TYPE, tokenType.getValue()); + mRep.setValue(ESConstants.OC_RSRVD_ES_AUTHPROVIDER, authProvider); + mRep.setValue(ESConstants.OC_RSRVD_ES_CISERVER, ciServer); + } catch (OcException e) { + Log.e(TAG, "setCloudPropWithAccessToken is failed."); + } + } + public void setCloudID(String cloudID) { mCloudID = cloudID; @@ -161,6 +188,52 @@ public class CloudProp { return mCredID; } + /** + * This method returns an accessToken used for the first registration to IoTivity cloud + * @return accessToken for sign-up to IoTivity cloud + */ + public String getAccessToken() + { + if(mRep == null) + { + return null; + } + + try + { + if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_ACCESSTOKEN)) + return mRep.getValue(ESConstants.OC_RSRVD_ES_ACCESSTOKEN); + } + catch (OcException e) + { + Log.e(TAG, "getAccessToken is failed."); + } + return null; + } + + /** + * This method returns an access token type + * @return tokenType of access token + */ + public OAUTH_TOKENTYPE getAccessTokenType() + { + if(mRep == null) + { + return null; + } + + try + { + if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_ACCESSTOKEN_TYPE)) + return OAUTH_TOKENTYPE.fromInt((int)mRep.getValue(ESConstants.OC_RSRVD_ES_ACCESSTOKEN_TYPE)); + } + catch (OcException e) + { + Log.e(TAG, "getAccessTokenType is failed."); + } + return OAUTH_TOKENTYPE.NONE_OAUTH_TOKENTYPE; + } + public OcRepresentation toOCRepresentation() { return mRep;