replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / inc / ESRichCommon.h
index a5af75c..48584d1 100755 (executable)
 #include "OCPlatform.h"
 #include "ocstack.h"
 #include "octypes.h"
+#ifdef __WITH_DTLS__
+#include "securevirtualresourcetypes.h"
+#include "OCProvisioningManager.hpp"
+#include "ocrandom.h"
+#endif
 
 #include "escommon.h"
 
@@ -43,7 +48,7 @@ namespace OIC
     namespace Service
     {
         /**
-         * @brief Properties of provisioning resource. It includes a provisioning status and last
+         * @brief Properties of easysetup resource. It includes a provisioning status and last
          *        error code.
          */
         class EnrolleeStatus
@@ -53,7 +58,10 @@ namespace OIC
             /**
              * Constructor
              */
-            EnrolleeStatus(const OCRepresentation& rep) { m_rep = rep; }
+            EnrolleeStatus(const OCRepresentation& rep)
+            {
+                m_rep = rep;
+            }
 
             EnrolleeStatus(const EnrolleeStatus& enrolleeStatus) :
                 m_rep(enrolleeStatus.getRepresentation())
@@ -70,11 +78,13 @@ namespace OIC
              *
              * @return a provisioning status property of Enrollee
              */
-            ProvStatus getProvStatus()
+            ProvStatus getProvStatus() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_PROVSTATUS))
+                {
                     return static_cast<ProvStatus>(
                                         m_rep.getValue<int>(OC_RSRVD_ES_PROVSTATUS));
+                }
                 return ES_STATE_INIT;
             }
 
@@ -83,11 +93,13 @@ namespace OIC
              *
              * @return a last error code property of Enrollee.
              */
-            ESErrorCode getLastErrCode()
+            ESErrorCode getLastErrCode() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_LAST_ERRORCODE))
+                {
                     return static_cast<ESErrorCode>(
                                         m_rep.getValue<int>(OC_RSRVD_ES_LAST_ERRORCODE));
+                }
                 return ES_ERRCODE_NO_ERROR;
             }
 
@@ -105,7 +117,7 @@ namespace OIC
         };
 
         /**
-         * @brief Data class stored for Cloud server property provisioning
+         * @brief Data class stored for provisioning of coap cloud server properties
          */
         class CloudProp
         {
@@ -114,7 +126,25 @@ namespace OIC
             /**
              * Constructor
              */
-            CloudProp() {};
+            CloudProp()
+            {
+                m_cloudID = "";
+                m_credID = 0;
+            }
+
+            CloudProp(const CloudProp& cloudProp) :
+                                            m_rep(cloudProp.toOCRepresentation()),
+                                            m_cloudID(cloudProp.getCloudID()),
+                                            m_credID(cloudProp.getCredID())
+            {
+            }
+
+            CloudProp(const CloudProp&& cloudProp) :
+                                            m_rep(std::move(cloudProp.toOCRepresentation())),
+                                            m_cloudID(cloudProp.getCloudID()),
+                                            m_credID(cloudProp.getCredID())
+            {
+            }
 
             /**
              * Constructor with OCRepresentation object. This is used for JNI communication.
@@ -123,10 +153,11 @@ namespace OIC
             {
                 m_rep = rep;
                 m_cloudID = "";
+                m_credID = 0;
             }
 
             /**
-             * Set CloudServer resource properties to be delivered to Enrollee
+             * Set CoapCloudConf resource properties to be delivered to Enrollee
              *
              * @param authCode  Auth code issued by OAuth2.0-compatible account server
              * @param authProvider Auth provider ID
@@ -140,6 +171,26 @@ namespace OIC
             }
 
             /**
+             * Set CoapCloudConf resource properties with Access token to be delivered to Enrollee
+             *
+             * @param accessToken  Access token which is given in a return of auth code issued by
+             *                     OAuth2.0-compatible account server
+             * @param tokenType Access token type, i.e. "bearer"
+             * @param authProvider Auth provider ID
+             * @param ciServer Cloud interface server URL which an Enrollee is going to registered
+             *
+             * @see OAUTH_TOKENTYPE
+             */
+            void setCloudPropWithAccessToken(string accessToken, OAUTH_TOKENTYPE tokenType,
+                                                string authProvider, string ciServer)
+            {
+                m_rep.setValue(OC_RSRVD_ES_ACCESSTOKEN, accessToken);
+                m_rep.setValue(OC_RSRVD_ES_ACCESSTOKEN_TYPE, tokenType);
+                m_rep.setValue(OC_RSRVD_ES_AUTHPROVIDER, authProvider);
+                m_rep.setValue(OC_RSRVD_ES_CISERVER, ciServer);
+            }
+
+            /**
              * Set CloudServer's UUID
              *
              * @param cloudID Cloud Interface server's UUID
@@ -150,14 +201,26 @@ namespace OIC
             }
 
             /**
+             * Set CloudServer's credential ID of certificate
+             *
+             * @param credID Cloud Interface server's credential ID of certificate
+             */
+            void setCredID(int credID)
+            {
+                m_credID = credID;
+            }
+
+            /**
              * Get an auth code to be delivered.
              *
              * @return an auth code to be delivered.
              */
-            std::string getAuthCode()
+            std::string getAuthCode() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_AUTHCODE))
+                {
                     return m_rep.getValue<std::string>(OC_RSRVD_ES_AUTHCODE);
+                }
                 return std::string("");
             }
 
@@ -166,10 +229,12 @@ namespace OIC
              *
              * @return an auth provider which issued an auth code
              */
-            std::string getAuthProvider()
+            std::string getAuthProvider() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_AUTHPROVIDER))
+                {
                     return m_rep.getValue<std::string>(OC_RSRVD_ES_AUTHPROVIDER);
+                }
                 return std::string("");
             }
 
@@ -178,10 +243,12 @@ namespace OIC
              *
              * @return a CI server to be delivered
              */
-            std::string getCiServer()
+            std::string getCiServer() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_CISERVER))
+                {
                     return m_rep.getValue<std::string>(OC_RSRVD_ES_CISERVER);
+                }
                 return std::string("");
             }
 
@@ -196,6 +263,46 @@ namespace OIC
             }
 
             /**
+             * Get a CI server's credential ID of certificate
+             *
+             * @return a CI server's credential ID of certificated
+             */
+            int getCredID() const
+            {
+                return m_credID;
+            }
+
+            /**
+             * Get an access token to be delivered.
+             *
+             * @return an access token to be delivered.
+             */
+            std::string getAccessToken() const
+            {
+                if(m_rep.hasAttribute(OC_RSRVD_ES_ACCESSTOKEN))
+                {
+                    return m_rep.getValue<std::string>(OC_RSRVD_ES_ACCESSTOKEN);
+                }
+                return std::string("");
+            }
+
+            /**
+             * Get an access token type to be delivered.
+             *
+             * @return an access token type to be delivered.
+             */
+            OAUTH_TOKENTYPE getAccessTokenType() const
+            {
+
+                if(m_rep.hasAttribute(OC_RSRVD_ES_ACCESSTOKEN_TYPE))
+                {
+                    return static_cast<OAUTH_TOKENTYPE>(
+                                m_rep.getValue<int>(OC_RSRVD_ES_ACCESSTOKEN_TYPE));
+                }
+                return NONE_OAUTH_TOKENTYPE;
+            }
+
+            /**
              * Get OCRepresentation object
              *
              * @return OCRepresentation object
@@ -207,11 +314,12 @@ namespace OIC
         protected:
             OCRepresentation m_rep;
             std::string m_cloudID;
+            int m_credID;
         };
 
         /**
-         * @brief Data class stored for Device property provisioning which includes a WiFi
-         *        and device configuration provisioning
+         * @brief Data class stored for provisioning of Device properties which includes
+         *        properties of WiFiConf resource and DevConf resource
          */
         class DeviceProp
         {
@@ -220,15 +328,30 @@ namespace OIC
             /**
              * Constructor
              */
-            DeviceProp() {}
+            DeviceProp()
+            {
+            }
+
+            DeviceProp(const DeviceProp& deviceProp) :
+                m_rep(deviceProp.toOCRepresentation())
+            {
+            }
+
+            DeviceProp(const DeviceProp&& deviceProp) :
+                m_rep(std::move(deviceProp.toOCRepresentation()))
+            {
+            }
 
             /**
              * Constructor with OCRepresentation object. This is used for JNI communication.
              */
-            DeviceProp(const OCRepresentation &rep) { m_rep = rep; }
+            DeviceProp(const OCRepresentation &rep)
+            {
+                m_rep = rep;
+            }
 
             /**
-             * Set WiFi resource properties to be delivered to Enrollee
+             * Set WiFiConf resource properties to be delivered to Enrollee
              *
              * @param ssid Ssid of the Enroller
              * @param pwd Pwd of the Enrolle
@@ -247,26 +370,16 @@ namespace OIC
             }
 
             /**
-             * Set DevConf resource properties to be delivered to Enrollee
-             *
-             * @param language IETF language tag using ISO 639X
-             * @param country ISO Country Code (ISO 3166-1 Alpha-2)
-             */
-            void setDevConfProp(string language, string country)
-            {
-                m_rep.setValue(OC_RSRVD_ES_LANGUAGE, language);
-                m_rep.setValue(OC_RSRVD_ES_COUNTRY, country);
-            }
-
-            /**
              * Get a SSID of Enroller
              *
              * @return a SSID of enroller
              */
-            std::string getSsid()
+            std::string getSsid() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_SSID))
+                {
                     return m_rep.getValue<std::string>(OC_RSRVD_ES_SSID);
+                }
                 return std::string("");
             }
 
@@ -275,10 +388,12 @@ namespace OIC
              *
              * @return a password of enroller
              */
-            std::string getPassword()
+            std::string getPassword() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_CRED))
+                {
                     return m_rep.getValue<std::string>(OC_RSRVD_ES_CRED);
+                }
                 return std::string("");
             }
 
@@ -289,10 +404,12 @@ namespace OIC
              *
              * @see WIFI_AUTHTYPE
              */
-            WIFI_AUTHTYPE getAuthType()
+            WIFI_AUTHTYPE getAuthType() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_AUTHTYPE))
+                {
                     return static_cast<WIFI_AUTHTYPE>(m_rep.getValue<int>(OC_RSRVD_ES_AUTHTYPE));
+                }
                 return NONE_AUTH;
             }
 
@@ -303,40 +420,16 @@ namespace OIC
              *
              * @see WIFI_ENCTYPE
              */
-            WIFI_ENCTYPE getEncType()
+            WIFI_ENCTYPE getEncType() const
             {
                 if(m_rep.hasAttribute(OC_RSRVD_ES_ENCTYPE))
+                {
                     return static_cast<WIFI_ENCTYPE>(m_rep.getValue<int>(OC_RSRVD_ES_ENCTYPE));
+                }
                 return NONE_ENC;
             }
 
             /**
-             * Get a language to be set. A language is expressed in IETF language tag
-             * using ISO 639X.
-             *
-             * @return a language to be set
-             */
-            std::string getLanguage()
-            {
-                if(m_rep.hasAttribute(OC_RSRVD_ES_LANGUAGE))
-                    return m_rep.getValue<std::string>(OC_RSRVD_ES_LANGUAGE);
-                return std::string("");
-            }
-
-            /**
-             * Get a country to be set. A country is expressed in ISO Country Code
-             * (ISO 3166-1 Alpha-2)
-             *
-             * @return a country to be set
-             */
-            std::string getCountry()
-            {
-                if(m_rep.hasAttribute(OC_RSRVD_ES_COUNTRY))
-                    return m_rep.getValue<std::string>(OC_RSRVD_ES_COUNTRY);
-                return std::string("");
-            }
-
-            /**
              * Get OCRepresentation object
              *
              * @return OCRepresentation object
@@ -351,17 +444,6 @@ namespace OIC
         };
 
         /**
-         * @brief Provisioning state in cloud server property provisioning.
-         */
-        typedef enum
-        {
-            ES_CLOUD_PROVISIONING_ERROR = -1,   /**< An error in cloud provisioning happens **/
-            ES_CLOUD_PROVISIONING_SUCCESS,      /**< Cloud provisioning is successfully done **/
-            ES_CLOUD_ENROLLEE_FOUND,            /**< An enrollee is found in a given network **/
-            ES_CLOUD_ENROLLEE_NOT_FOUND         /**< NO enrollee is found in a given network **/
-        }ESCloudProvState;
-
-        /**
          * Security Provisioning Status
          */
         class SecProvisioningStatus
@@ -370,13 +452,79 @@ namespace OIC
             SecProvisioningStatus(string deviceUUID, ESResult result) :
                 m_devUUID(deviceUUID), m_result(result)
             {
+#ifdef __WITH_DTLS__
+                m_selectedOTMethod = OIC_JUST_WORKS;
+                m_isMOTEnabled = false;
+                m_isOwned = false;
+                m_ownerID = {};
+#endif
+            }
+#ifdef __WITH_DTLS__
+            SecProvisioningStatus(std::shared_ptr<OCSecureResource> resource, ESResult result) :
+                m_result(result)
+            {
+                m_isMOTEnabled = false;
+                if(resource.get() != nullptr)
+                {
+                    m_devUUID = resource->getDeviceID();
+                    m_isOwned = resource->getOwnedStatus();
+#ifdef MULTIPLE_OWNER
+                    m_isMOTEnabled = resource->isMOTEnabled();
+#endif
+
+                    if( OC_STACK_OK != resource->getOTMethod(&m_selectedOTMethod) )
+                    {
+                        m_selectedOTMethod = OIC_OXM_COUNT; // Out-of-range
+                    }
+
+                    if(resource->getOwnedStatus())
+                    {
+                        char uuidString[UUID_STRING_SIZE] = {};
+                        if(RAND_UUID_OK == OCConvertUuidToString(resource->getDevPtr()->doxm->owner.id, uuidString))
+                        {
+                            m_ownerID = uuidString;
+                        }
+                        else
+                        {
+                            m_ownerID = {};
+                        }
+                    }
+                }
+            }
+
+            OicSecOxm_t getSelectedOTMethod() const
+            {
+                return m_selectedOTMethod;
             }
 
-            const string getDeviceUUID()
+            bool isMOTEnabled() const
             {
-                return m_devUUID;
+                return m_isMOTEnabled;
             }
 
+            bool isOwnedDevice() const
+            {
+                return m_isOwned;
+            }
+
+            const std::string getOwnerID()
+            {
+                return m_ownerID;
+            }
+#endif
+            const std::string getDeviceUUID()
+            {
+                return m_devUUID;
+            }
+            /**
+             * Get a result for about security provisioning is success or not.
+             *
+             * @return ::ES_OK\n
+             *         ::ES_SEC_OPERATION_IS_NOT_SUPPORTED\n
+             *         ::ES_SECURE_RESOURCE_DISCOVERY_FAILURE\n
+             *         ::ES_OWNERSHIP_TRANSFER_FAILURE\n
+             *         ::ES_ERROR\n
+             */
             ESResult getESResult()
             {
                 return m_result;
@@ -384,6 +532,12 @@ namespace OIC
         private:
             string m_devUUID;
             ESResult m_result;
+#ifdef __WITH_DTLS__
+            OicSecOxm_t m_selectedOTMethod;
+            bool m_isMOTEnabled;
+            bool m_isOwned;
+            std::string m_ownerID;
+#endif
         };
 
         /**
@@ -398,30 +552,22 @@ namespace OIC
             /**
              * Constructor
              * The expected OCRepresentation is one for collection resource and has several child
-             * OCRepresentation object corresponding to WiFi, DevConf, and CloudServer resource's
-             * representation.
+             * OCRepresentation object corresponding to WiFiConf, DevConf, and CoapCloudConf
+             * resources' representations.
              */
-            EnrolleeConf(const OCRepresentation& rep)
+            EnrolleeConf(const OCRepresentation& rep) :
+                m_EasySetupRep(rep)
             {
-                m_ProvRep = rep;
+            }
 
-                std::vector<OCRepresentation> children = rep.getChildren();
+            EnrolleeConf(const EnrolleeConf& enrolleeConf) :
+                m_EasySetupRep(enrolleeConf.getEasySetupRep())
+            {
+            }
 
-                for(auto child = children.begin(); child != children.end(); ++child)
-                {
-                    if(child->getUri().find(OC_RSRVD_ES_URI_WIFI) != std::string::npos)
-                    {
-                        m_WiFiRep = *child;
-                    }
-                    else if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
-                    {
-                        m_DevConfRep = *child;
-                    }
-                    else if(child->getUri().find(OC_RSRVD_ES_URI_CLOUDSERVER) != std::string::npos)
-                    {
-                        m_CloudRep = *child;
-                    }
-                }
+            EnrolleeConf(const EnrolleeConf&& enrolleeConf) :
+                m_EasySetupRep(std::move(enrolleeConf.getEasySetupRep()))
+            {
             }
 
             /**
@@ -430,10 +576,29 @@ namespace OIC
              *
              * @return a device name of Enrollee
              */
-            std::string getDeviceName()
+            std::string getDeviceName() const
             {
-                if(m_DevConfRep.hasAttribute(OC_RSRVD_ES_DEVNAME))
-                    return m_DevConfRep.getValue<std::string>(OC_RSRVD_ES_DEVNAME);
+                std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+                for(auto child = children.begin(); child != children.end(); ++child)
+                {
+                    if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
+                    {
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return std::string("");
+                        }
+
+                        if(rep.hasAttribute(OC_RSRVD_ES_DEVNAME))
+                        {
+                            return rep.getValue<std::string>(OC_RSRVD_ES_DEVNAME);
+                        }
+                    }
+                }
                 return std::string("");
             }
 
@@ -444,17 +609,34 @@ namespace OIC
              *
              * @see WIFI_MODE
              */
-            vector<WIFI_MODE> getWiFiModes()
+            vector<WIFI_MODE> getWiFiModes() const
             {
                 vector<WIFI_MODE> modes;
                 modes.clear();
 
-                if(m_WiFiRep.hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIMODE))
+                std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+                for(auto child = children.begin(); child != children.end(); ++child)
                 {
-                    for(auto it : m_WiFiRep.getValue
-                                        <std::vector<int>>(OC_RSRVD_ES_SUPPORTEDWIFIMODE))
+                    if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos)
                     {
-                        modes.push_back(static_cast<WIFI_MODE>(it));
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return modes;
+                        }
+
+                        if(rep.hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIMODE))
+                        {
+                            for(auto it : rep.getValue
+                                        <std::vector<int>>(OC_RSRVD_ES_SUPPORTEDWIFIMODE))
+                            {
+                                modes.push_back(static_cast<WIFI_MODE>(it));
+                            }
+                        }
                     }
                 }
                 return modes;
@@ -467,24 +649,100 @@ namespace OIC
              *
              * @see WIFI_FREQ
              */
-            WIFI_FREQ getWiFiFreq()
+            WIFI_FREQ getWiFiFreq() const
             {
-                if(m_WiFiRep.hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIFREQ))
-                    return static_cast<WIFI_FREQ>(
-                                        m_WiFiRep.getValue<int>(OC_RSRVD_ES_SUPPORTEDWIFIFREQ));
+                std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+                for(auto child = children.begin(); child != children.end(); ++child)
+                {
+                    if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos)
+                    {
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return WIFI_FREQ_NONE;
+                        }
+
+                        if(rep.hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIFREQ))
+                        {
+                            return static_cast<WIFI_FREQ>(
+                                        rep.getValue<int>(OC_RSRVD_ES_SUPPORTEDWIFIFREQ));
+                        }
+                    }
+                }
                 return WIFI_FREQ_NONE;
             }
 
             /**
+             * Get a provisioning status property of Enrollee.
+             *
+             * @return a provisioning status property of Enrollee
+             */
+            ProvStatus getProvStatus() const
+            {
+                OCRepresentation rep;
+                if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION))
+                {
+                    rep = m_EasySetupRep.getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                }
+                else
+                {
+                    return ES_STATE_INIT;
+                }
+
+                if(rep.hasAttribute(OC_RSRVD_ES_PROVSTATUS))
+                {
+                    return static_cast<ProvStatus>(
+                                        rep.getValue<int>(OC_RSRVD_ES_PROVSTATUS));
+                }
+                return ES_STATE_INIT;
+            }
+
+            /**
+             * Get a last error code property of Enrollee.
+             *
+             * @return a last error code property of Enrollee.
+             */
+            ESErrorCode getLastErrCode() const
+            {
+                OCRepresentation rep;
+                if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION))
+                {
+                    rep = m_EasySetupRep.getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                }
+                else
+                {
+                    return ES_ERRCODE_NO_ERROR;
+                }
+
+                if(rep.hasAttribute(OC_RSRVD_ES_LAST_ERRORCODE))
+                {
+                    return static_cast<ESErrorCode>(
+                                        rep.getValue<int>(OC_RSRVD_ES_LAST_ERRORCODE));
+                }
+                return ES_ERRCODE_NO_ERROR;
+            }
+
+            /**
              * Get an accessibility to cloud server of an Enrollee
              *
              * @return an accessibility to cloud server of an Enrollee
              */
-            bool isCloudAccessible()
+            bool isCloudAccessible() const
             {
-                if(m_CloudRep.getUri().find(OC_RSRVD_ES_URI_CLOUDSERVER) != std::string::npos)
+                std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+                for(auto child = children.begin(); child != children.end(); ++child)
                 {
-                    return true;
+                    for(auto rt : child->getResourceTypes())
+                    {
+                        if(0 == rt.compare(OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF))
+                        {
+                            return true;
+                        }
+                    }
                 }
                 return false;
             }
@@ -494,13 +752,13 @@ namespace OIC
              *
              * @return OCRepresentation object
              */
-            const OCRepresentation& getProvResRep()
+            const OCRepresentation& getEasySetupRep() const
             {
-                return m_ProvRep;
+                return m_EasySetupRep;
             }
 
         protected:
-            OCRepresentation m_ProvRep, m_WiFiRep, m_DevConfRep, m_CloudRep;
+            OCRepresentation m_EasySetupRep;
         };
 
         /**
@@ -514,16 +772,34 @@ namespace OIC
         class GetEnrolleeStatus
         {
         public:
+            /**
+             * Constructor
+             */
             GetEnrolleeStatus(ESResult result, const EnrolleeStatus& status) :
                 m_result(result), m_enrolleeStatus(status)
             {
             }
 
+            /**
+             * Get a result of getting provisioning status and last error code of Enrollee
+             *
+             * @return ::ES_OK\n
+             *         ::ES_COMMUNICATION_ERROR\n
+             *         ::ES_ERROR\n
+             * @see ESResult
+             */
             ESResult getESResult()
             {
                 return m_result;
             }
 
+            /**
+             * Get Enrollee's status and last error code properties
+             *
+             * @return Enrollee's status and last error code properties
+             *
+             * @see EnrolleeStatus
+             */
             const EnrolleeStatus& getEnrolleeStatus()
             {
                 return m_enrolleeStatus;
@@ -545,17 +821,36 @@ namespace OIC
         class GetConfigurationStatus
         {
         public:
+            /**
+             * Constructor
+             */
             GetConfigurationStatus(ESResult result, const EnrolleeConf& conf) :
                     m_result(result), m_enrolleeConf(conf)
             {
             }
 
+            /**
+             * Get a result of getting preconfiguration of Enrollee
+             *
+             * @return ::ES_OK\n
+             *         ::ES_COMMUNICATION_ERROR\n
+             *         ::ES_ERROR\n
+             *
+             * @see ESResult
+             */
             ESResult getESResult()
             {
                 return m_result;
             }
 
-            const EnrolleeConf& getEnrolleeConf()
+            /**
+             * Get Enrollee's pre-configuration properties
+             *
+             * @return Enrollee's pre-configuration properties
+             *
+             * @see EnrolleeConf
+             */
+            EnrolleeConf& getEnrolleeConf()
             {
                 return m_enrolleeConf;
             }
@@ -573,17 +868,28 @@ namespace OIC
         class DevicePropProvisioningStatus
         {
         public:
+            /**
+             * Constructor
+             */
             DevicePropProvisioningStatus(ESResult result) :
                     m_result(result)
             {
             }
 
+            /**
+             * Get a result of Device property provisioning
+             *
+             * @return ::ES_OK\n
+             *         ::ES_COMMUNICATION_ERROR\n
+             *         ::ES_ERROR\n
+             *
+             * @see ESResult
+             */
             ESResult getESResult()
             {
                 return m_result;
             }
 
-
         private:
             ESResult m_result;
         };
@@ -598,24 +904,134 @@ namespace OIC
         class CloudPropProvisioningStatus
         {
         public:
-            CloudPropProvisioningStatus(ESResult result, ESCloudProvState state) :
-                    m_result(result), m_esCloudState(state)
+            /**
+             * Constructor
+             */
+            CloudPropProvisioningStatus(ESResult result) :
+                    m_result(result)
             {
             }
 
+            /**
+             * Get a result of Cloud property provisioning
+             *
+             * @return ::ES_OK\n
+             *         ::ES_ENROLLEE_DISCOVERY_FAILURE\n
+             *         ::ES_SECURE_RESOURCE_DISCOVERY_FAILURE\n
+             *         ::ES_ACL_PROVISIONING_FAILURE\n
+             *         ::ES_CERT_PROVISIONING_FAILURE\n
+             *         ::ES_COMMUNICATION_ERROR\n
+             *         ::ES_ERROR\n
+             *
+             * @see ESResult
+             */
             ESResult getESResult()
             {
                 return m_result;
             }
 
-            ESCloudProvState getESCloudState()
+        private:
+            ESResult m_result;
+        };
+
+        /**
+         * Status object for connect API. This object is given to application
+         * when a response for 'Connect' request from Enrollee is arrived.
+         */
+        class ConnectRequestStatus
+        {
+        public:
+            /**
+             * Constructor
+             */
+            ConnectRequestStatus(ESResult result) :
+                    m_result(result)
+            {
+            }
+
+            /**
+             * Get a result of Connect request
+             *
+             * @return ::ES_OK\n
+             *         ::ES_COMMUNICATION_ERROR\n
+             *         ::ES_ERROR\n
+             *
+             * @see ESResult
+             */
+            ESResult getESResult()
             {
-                return m_esCloudState;
+                return m_result;
             }
 
         private:
             ESResult m_result;
-            ESCloudProvState m_esCloudState;
+        };
+
+        class ESOwnershipTransferData
+        {
+        public:
+#ifdef __WITH_DTLS__
+            ESOwnershipTransferData() :
+                m_MOTMethod(OIC_OXM_COUNT), m_preconfiguredPin("")
+            {
+            }
+
+            ESOwnershipTransferData(const ESOwnershipTransferData& data) :
+                m_MOTMethod(data.getMOTMethod()),
+                m_preconfiguredPin(data.getPreConfiguredPin())
+            {
+            }
+
+            ESResult setMOTMethod(OicSecOxm_t method)
+            {
+#ifdef MULTIPLE_OWNER
+                if(OIC_RANDOM_DEVICE_PIN != method)
+                {
+                    return ES_ERROR;
+                }
+
+                m_MOTMethod = method;
+                return ES_OK;
+#else
+                (void) method;
+
+                return ES_ERROR;
+#endif
+            }
+
+            ESResult setMOTMethod(OicSecOxm_t method, const std::string& pin)
+            {
+#ifdef MULTIPLE_OWNER
+                if(OIC_PRECONFIG_PIN != method || pin.empty())
+                {
+                    return ES_ERROR;
+                }
+
+                m_preconfiguredPin = pin;
+                m_MOTMethod = method;
+                return ES_OK;
+#else
+                (void) method;
+                (void) pin;
+
+                return ES_ERROR;
+#endif
+            }
+
+            OicSecOxm_t getMOTMethod() const
+            {
+                return m_MOTMethod;
+            }
+
+            std::string getPreConfiguredPin() const
+            {
+                return m_preconfiguredPin;
+            }
+
+        private:
+            OicSecOxm_t m_MOTMethod;
+            std::string m_preconfiguredPin;
+#endif
         };
 
         /**
@@ -639,11 +1055,25 @@ namespace OIC
         typedef function< void(shared_ptr< CloudPropProvisioningStatus >) > CloudPropProvStatusCb;
 
         /**
+         * Callback function definition for providing 'Connect' request status
+         */
+        typedef function< void(shared_ptr< ConnectRequestStatus >) > ConnectRequestStatusCb;
+
+
+        /**
          * Callback function definition for providing Enrollee security provisioning status
          */
         typedef function< void(shared_ptr<SecProvisioningStatus>) > SecurityProvStatusCb;
 
         /**
+         * Callback function definition for providing Enrollee security provisioning status.
+         * This callback is an overloaded version of SecurityProvStatusCb, which has
+         * ESOwnershipTransferData as a return value.
+         */
+        typedef function< ESOwnershipTransferData(shared_ptr<SecProvisioningStatus>) >
+                                                                    SecurityProvStatusCbWithOption;
+
+        /**
          * Callback definition to be invoked when the security stack expects a pin from application
          */
         typedef function< void(string&) > SecurityPinCb;