2 * ***************************************************************
4 * Copyright 2016 Samsung Electronics All Rights Reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * ****************************************************************
21 package org.iotivity.service.easysetup.mediator;
23 import android.util.Log;
25 import org.iotivity.base.OcException;
26 import org.iotivity.base.OcRepresentation;
29 * This class contains cloud server properties to be delivered to Enrollee
31 public class CloudProp {
32 private static final String TAG = CloudProp.class.getName();
33 protected OcRepresentation mRep;
34 protected String mCloudID;
40 mRep = new OcRepresentation();
44 public void setCloudProp(String authCode, String authProvider, String ciServer)
47 mRep.setValue(ESConstants.OC_RSRVD_ES_AUTHCODE, authCode);
48 mRep.setValue(ESConstants.OC_RSRVD_ES_AUTHPROVIDER, authProvider);
49 mRep.setValue(ESConstants.OC_RSRVD_ES_CISERVER, ciServer);
50 } catch (OcException e) {
51 Log.e(TAG, "setCloudProp is failed.");
55 public void setCloudID(String cloudID)
61 * This method returns the authCode used for the first registration to IoTivity cloud
62 * @return AuthCode for sign-up to IoTivity cloud
64 public String getAuthCode()
67 if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_AUTHCODE))
68 return mRep.getValue(ESConstants.OC_RSRVD_ES_AUTHCODE);
69 } catch (OcException e) {
70 Log.e(TAG, "getAuthCode is failed.");
72 return new String("");
76 * This method returns the auth provider which issued the given AuthCode
77 * @return Auth provider which issued the given AuthCode
79 public String getAuthProvider()
82 if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_AUTHPROVIDER))
83 return mRep.getValue(ESConstants.OC_RSRVD_ES_AUTHPROVIDER);
84 } catch (OcException e) {
85 Log.e(TAG, "getAuthProvider is failed.");
87 return new String("");
91 * This method returns the Cloud Interface server's URL to be registered
92 * @return CI server's URL to be registered
94 public String getCiServer()
97 if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_CISERVER))
98 return mRep.getValue(ESConstants.OC_RSRVD_ES_CISERVER);
99 } catch (OcException e) {
100 Log.e(TAG, "getCiServer is failed.");
102 return new String("");
106 * This method returns the Cloud Interface server's UUID
107 * @return CI server's UUID
109 public String getCloudID()
114 public OcRepresentation toOCRepresentation()