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 = null;
34 protected String mCloudID = null;
35 protected int mCredID ;
41 mRep = new OcRepresentation();
45 public void setCloudProp(String authCode, String authProvider, String ciServer)
51 if(authProvider == null)
60 mRep.setValue(ESConstants.OC_RSRVD_ES_AUTHCODE, authCode);
61 mRep.setValue(ESConstants.OC_RSRVD_ES_AUTHPROVIDER, authProvider);
62 mRep.setValue(ESConstants.OC_RSRVD_ES_CISERVER, ciServer);
63 } catch (OcException e) {
64 Log.e(TAG, "setCloudProp is failed.");
68 public void setCloudID(String cloudID)
73 public void setCredID(int credID)
78 * This method returns the authCode used for the first registration to IoTivity cloud
79 * @return AuthCode for sign-up to IoTivity cloud
81 public String getAuthCode()
90 if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_AUTHCODE))
91 return mRep.getValue(ESConstants.OC_RSRVD_ES_AUTHCODE);
95 Log.e(TAG, "getAuthCode is failed.");
101 * This method returns the auth provider which issued the given AuthCode
102 * @return Auth provider which issued the given AuthCode
104 public String getAuthProvider()
113 if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_AUTHPROVIDER))
114 return mRep.getValue(ESConstants.OC_RSRVD_ES_AUTHPROVIDER);
116 catch (OcException e)
118 Log.e(TAG, "getAuthProvider is failed.");
124 * This method returns the Cloud Interface server's URL to be registered
125 * @return CI server's URL to be registered
127 public String getCiServer()
136 if (mRep.hasAttribute(ESConstants.OC_RSRVD_ES_CISERVER))
137 return mRep.getValue(ESConstants.OC_RSRVD_ES_CISERVER);
139 catch (OcException e)
141 Log.e(TAG, "getCiServer is failed.");
147 * This method returns the Cloud Interface server's UUID
148 * @return CI server's UUID
150 public String getCloudID()
156 * This method returns the Cloud Certificate's Cred ID
157 * @return CI server's Credential ID of Certificate
159 public int getCredID()
164 public OcRepresentation toOCRepresentation()