Changing the length of access token
[platform/upstream/iotivity.git] / service / easy-setup / inc / escommon.h
old mode 100755 (executable)
new mode 100644 (file)
index f31e3d5..d2e16f6
@@ -30,9 +30,17 @@ extern "C"
 #endif
 
 // Defines
-#define OIC_STRING_MAX_VALUE    64
-#define MAX_WEBLINKLEN          3
-#define NUM_WIFIMODE            5
+#define OC_RSRVD_ES_RES_TYPE_COL          "oic.wk.col"
+#define OC_RSRVD_ES_INTERFACE             "if"
+#define OC_RSRVD_ES_RES_TYPE              "rt"
+
+
+
+#define OIC_STRING_MAX_VALUE                  256
+#define OIC_STRING_ACCESS_TOKEN_MAX_VALUE     1024
+#define MAX_WEBLINKLEN                        3
+#define NUM_WIFIMODE                          10
+#define NUM_CONNECT_TYPE                      3
 
 /**
  * Attributes used to form a proper easysetup conforming JSON message.
@@ -47,27 +55,26 @@ extern "C"
 #define OC_RSRVD_ES_AUTHTYPE               "wat"
 #define OC_RSRVD_ES_ENCTYPE                "wet"
 #define OC_RSRVD_ES_AUTHCODE               "ac"
+#define OC_RSRVD_ES_ACCESSTOKEN            "at"
+#define OC_RSRVD_ES_ACCESSTOKEN_TYPE       "att"
 #define OC_RSRVD_ES_AUTHPROVIDER           "apn"
 #define OC_RSRVD_ES_CISERVER               "cis"
 #define OC_RSRVD_ES_SERVERID               "sid"
 #define OC_RSRVD_ES_DEVNAME                "dn"
-#define OC_RSRVD_ES_LANGUAGE               "lang"
-#define OC_RSRVD_ES_COUNTRY                "ctry"
-#define OC_RSRVD_ES_MODELNUMBER            "mnmo"
-#define OC_RSRVD_ES_LOCATION               "loc"
 #define OC_RSRVD_ES_HREF                   "href"
+#define OC_RSRVD_ES_CONNECT                "cn"
 
 /**
  * Easysetup defined resoruce types and uris.
  */
-#define OC_RSRVD_ES_RES_TYPE_PROV         "oic.wk.prov"
-#define OC_RSRVD_ES_URI_PROV              "/ProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_WIFI         "oic.wk.wifi"
-#define OC_RSRVD_ES_URI_WIFI              "/WiFiProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER  "oic.wk.cloudserver"
-#define OC_RSRVD_ES_URI_CLOUDSERVER       "/CloudServerProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_DEVCONF      "oic.wk.devconf"
-#define OC_RSRVD_ES_URI_DEVCONF           "/DevConfProvisioningResURI"
+#define OC_RSRVD_ES_RES_TYPE_EASYSETUP          "oic.r.easysetup"
+#define OC_RSRVD_ES_URI_EASYSETUP               "/EasySetupResURI"
+#define OC_RSRVD_ES_RES_TYPE_WIFICONF           "oic.r.wificonf"
+#define OC_RSRVD_ES_URI_WIFICONF                "/WiFiConfResURI"
+#define OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF      "oic.r.coapcloudconf"
+#define OC_RSRVD_ES_URI_COAPCLOUDCONF           "/CoapCloudConfResURI"
+#define OC_RSRVD_ES_RES_TYPE_DEVCONF            "oic.r.devconf"
+#define OC_RSRVD_ES_URI_DEVCONF                 "/DevConfResURI"
 
 
 /**
@@ -103,7 +110,8 @@ typedef enum
     NONE_AUTH = 0,      /**< NO authentication **/
     WEP,                /**< WEP **/
     WPA_PSK,            /**< WPA-PSK **/
-    WPA2_PSK            /**< WPA2-PSK **/
+    WPA2_PSK,           /**< WPA2-PSK **/
+    FT_PSK              /**< FT-PSK **/
 } WIFI_AUTHTYPE;
 
 /**
@@ -120,6 +128,26 @@ typedef enum
 } WIFI_ENCTYPE;
 
 /**
+ * @brief OAuth Access Token Types. "bearer" and "mac" types are supported.
+ */
+typedef enum
+{
+    NONE_OAUTH_TOKENTYPE = 0,
+    OAUTH_TOKENTYPE_BEARER,
+    OAUTH_TOKENTYPE_MAC
+} OAUTH_TOKENTYPE;
+
+/**
+ * @brief  A target configuration type to be connected (or executed)
+ */
+typedef enum
+{
+    ES_CONNECT_NONE = 0,        /**< Init value **/
+    ES_CONNECT_WIFI = 1,        /**< WiFi Conf resource **/
+    ES_CONNECT_COAPCLOUD = 2    /**< Coap Cloud Conf resource **/
+} ES_CONNECT_TYPE;
+
+/**
  * @brief A result of Easy Setup
  */
 typedef enum
@@ -130,37 +158,120 @@ typedef enum
     ES_OK = 0,
 
     /**
-     * Successfully found Enrollee in a given network. This will be given in Cloud provisioning step.
+     * Secure resource is discovered.
+     */
+    ES_SECURE_RESOURCE_IS_DISCOVERED = 1,
+
+    /**
+     * Enrollee discovery fails in cloud provisioning
+     */
+    ES_ENROLLEE_DISCOVERY_FAILURE = 11,
+
+    /**
+     * Valid GET or POST request fails for some reason.
+     * This failure may happen when it failed to receive any response from Enrollee by a timeout threshold
+     */
+    ES_COMMUNICATION_ERROR,
+
+    /**
+     * Security opertion is not supported because Mediator is built as unsecured mode.
+     */
+    ES_SEC_OPERATION_IS_NOT_SUPPORTED,
+
+    /**
+     * Security resource discovery fails due to loss of discovery packet or absence of the resource in a network
      */
-    ES_FOUND_ENROLLEE = 1,
+    ES_SECURE_RESOURCE_DISCOVERY_FAILURE,
 
     /**
-     * Not found Enrollee in a give network. This will be given in Cloud provisioning step.
+     * Ownership transfer fails due to one of unexpected reasons.
+     * E.g. A packet loss even with retransmission happens during ownership transfer.
+     * E.g. Mediator's owned status is 'unowned'
+     * E.g. A user confirmation for random pin-based or certificate-based OT fails
      */
-    ES_NOT_FOUND_ENROLLEE = 11,
+    ES_OWNERSHIP_TRANSFER_FAILURE = 20,
 
     /**
-     * Security opertion is not supported because it is built as unsecured mode.
+     * Ownership transfer which is cert-based method fails due to user confirmation is denied.
      */
-    ES_SEC_OPERATION_IS_NOT_SUPPORTED = 20,
+    ES_USER_DENIED_CONFIRMATION_REQ,
 
     /**
-     * A previous request is denied due to its unauthority. It means, Mediator is not unauthroized
-     * to Enrollee for some reaons.
+     * Ownership transfer which is cert-based method fails due to wrong certificate.
      */
-    ES_UNAUTHORIZED_REQ = 21,
+    ES_AUTHENTICATION_FAILURE_WITH_WRONG_CERT,
 
     /**
-     * Security provisioning fails. The reasons would be: a packet loss for unowned/owned device
-     * discovery request or ownership transfer request, or a denial to ownership transfer by Enrollee
-     * for some reason.
+     * Ownership transfer which is random-pin method fails due to wrong pin.
      */
-    ES_SEC_PROVISION_FAILS = 22,
+    ES_AUTHENTICATION_FAILURE_WITH_WRONG_PIN,
+
+    /**
+     * Ownership information is not synchronized between Mediator and Enrollee.
+     * e.g. A mediator's PDM DB has an ownership information to the found enrollee
+     *      but it is actually owned by other mediator.
+     *      That can happen where the found enrollee is reset and performed in easy setup without any inform to the first mediator.
+     * e.g. A list of owned devices managed in mediator's PMD db has no element for the found enrollee.
+     *      That can happen where only mediator is reset without any inform to the enrollee.
+     * To proceed an ownership transfer to the enrollee, it needs to reset the enrollee's SVR DB for its owner, i.e. the mediator
+     */
+    ES_OWNERSHIP_IS_NOT_SYNCHRONIZED,
+
+    /**
+     * MOT is not supported at the target Enrollee device.
+     *
+     * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+     * @note If the mediator gets this values, it means OT has been successfully done
+     * (or already took an ownership, before), but failed MOT configuration.
+     */
+    ES_MOT_NOT_SUPPORTED = 30,
+
+    /**
+     * MOT enabling is failed.
+     *
+     * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+     * @note If the mediator gets this values, it means OT has been successfully done
+     * (or already took an ownership, before), but failed MOT configuration.
+     */
+    ES_MOT_ENABLING_FAILURE,
+
+    /**
+     * MOT method selection is failed
+     *
+     * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+     * @note If the mediator gets this values, it means OT has been successfully done
+     * (or already took an ownership, before), but failed MOT configuration.
+     */
+    ES_MOT_METHOD_SELECTION_FAILURE,
+
+    /**
+     * A provisioning of Pre-configured pin number for MOT is failed
+     *
+     * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+     * @note If the mediator gets this values, it means OT has been successfully done
+     * (or already took an ownership, before), but failed MOT configuration.
+     */
+    ES_PRE_CONFIG_PIN_PROVISIONING_FAILURE,
+
+    /**
+     * ACL provisioning fails in cloud provisioning.
+     * It could be that UUID format of cloud server is wrong.
+     * Or any response for the provisioning request is not arrived at Mediator
+     */
+    ES_ACL_PROVISIONING_FAILURE = 40,
+
+    /**
+     * Cert. provisioning fails in cloud provisioning.
+     * It could be that you put a wrong cred ID of which the corresponding certificate does not exist in SVR DB.
+     * Or any response for the provisioning request is not arrived at Mediator
+     */
+    ES_CERT_PROVISIONING_FAILURE,
 
     /**
      * Provisioning fails for some reason.
      */
-    ES_ERROR = 255,
+
+    ES_ERROR = 255
 } ESResult;
 
 /**
@@ -168,14 +279,14 @@ typedef enum
  */
 typedef enum
 {
-    ES_WIFI_RESOURCE = 0x01,
-    ES_CLOUD_RESOURCE = 0x02,
+    ES_WIFICONF_RESOURCE = 0x01,
+    ES_COAPCLOUDCONF_RESOURCE = 0x02,
     ES_DEVCONF_RESOURCE = 0x04
 } ESResourceMask;
 
 /**
  * @brief Indicate enrollee and provisioning status. Provisioning status is shown in "provisioning
- *        status" property in provisioning resource.
+ *        status" property in easysetup resource.
  */
 typedef enum
 {
@@ -185,29 +296,59 @@ typedef enum
     ES_STATE_INIT = 0,
 
     /**
-    * Status indicating being cnnecting to target network
-    */
+     * Status indicating being connecting to target network
+     */
     ES_STATE_CONNECTING_TO_ENROLLER,
 
     /**
-    * Status indicating successful conection to target network
-    */
+     * Status indicating successful conection to target network
+     */
     ES_STATE_CONNECTED_TO_ENROLLER,
 
     /**
-    * Status indicating failure connection to target network
-    */
-    ES_STATE_CONNECTED_FAIL_TO_ENROLLER,
+     * Status indicating connection failure to target network
+     */
+    ES_STATE_FAILED_TO_CONNECT_TO_ENROLLER,
+
+    /**
+     * Status indicating being registering to cloud
+     */
+    ES_STATE_REGISTERING_TO_CLOUD,
 
     /**
-    * Status indicating successful registration to cloud
-    */
+     * Status indicating successful registration to cloud
+     */
     ES_STATE_REGISTERED_TO_CLOUD,
 
     /**
-    * Status indicating failure registeration to cloud
-    */
-    ES_STATE_REGISTRRED_FAIL_TO_CLOUD
+     * Status indicating registeration failure to cloud
+     */
+    ES_STATE_FAILED_TO_REGISTER_TO_CLOUD,
+
+    /**
+     * Status indicating being publishing resources to cloud
+     */
+    ES_STATE_PUBLISHING_RESOURCES_TO_CLOUD,
+
+    /**
+     * Status indicating successful resource publish to cloud
+     */
+    ES_STATE_PUBLISHED_RESOURCES_TO_CLOUD,
+
+    /**
+     * Status indicating resource publish failure to cloud
+     */
+    ES_STATE_FAILED_TO_PUBLISH_RESOURCES_TO_CLOUD,
+
+    /**
+     * Status indicating aborted provisioning by enrollee
+     */
+    ES_STATE_ABORTED_PROVISIONING_BY_ENROLLEE,
+
+    /**
+     * End of Easy setup status
+     */
+    ES_STATE_EOF = 255
 } ESEnrolleeState, ProvStatus;
 
 /**
@@ -221,34 +362,75 @@ typedef enum
     ES_ERRCODE_NO_ERROR = 0,
 
     /**
-    * Error Code that given WiFi's SSID is not found
-    */
+     * Error Code that given WiFi's SSID is not found
+     */
     ES_ERRCODE_SSID_NOT_FOUND,
 
     /**
-    * Error Code that given WiFi's Password is wrong
-    */
+     * Error Code that given WiFi's Password is wrong
+     */
     ES_ERRCODE_PW_WRONG,
 
     /**
-    * Error Code that IP address is not allocated
-    */
+     * Error Code that IP address is not allocated
+     */
     ES_ERRCODE_IP_NOT_ALLOCATED,
 
     /**
-    * Error Code that there is no Internet connection
-    */
+     * Error Code that there is no Internet connection
+     */
     ES_ERRCODE_NO_INTERNETCONNECTION,
 
     /**
-    * Error Code that Timeout occured
-    */
+     * Error Code that Timeout occured
+     */
     ES_ERRCODE_TIMEOUT,
 
     /**
-    * Error Code that Unknown error occured
-    */
-    ES_ERRCODE_UNKNOWN
+     * Error Code that cloud server is not reachable due to wrong URL of cloud server, for example.
+     */
+    ES_ERRCODE_FAILED_TO_ACCESS_CLOUD_SERVER,
+
+    /**
+     * Error Code that no response is arrived from cloud server
+     */
+    ES_ERRCODE_NO_RESPONSE_FROM_CLOUD_SERVER,
+
+    /**
+     * Error Code that a delivered authcode is not valid.
+     */
+    ES_ERRCODE_INVALID_AUTHCODE,
+
+    /**
+     * Error Code that a given access token is not valid due to its expiration, for example.
+     */
+    ES_ERRCODE_INVALID_ACCESSTOKEN,
+
+    /**
+     * Error Code that a refresh of expired access token is failed due to some reasons.
+     */
+    ES_ERRCODE_FAILED_TO_REFRESH_ACCESSTOKEN,
+
+    /**
+     * Error Code that a target device is not discovered in cloud server
+     */
+    ES_ERRCODE_FAILED_TO_FIND_REGISTERED_DEVICE_IN_CLOUD,
+
+    /**
+     * Error Code that a target user does not exist in cloud server.
+     */
+    ES_ERRCODE_FAILED_TO_FIND_REGISTERED_USER_IN_CLOUD,
+
+    /**
+     * Error Code that an enrollee can not connect to a target WiFi AP because the AP resides in
+     * an unsupported WiFi frequency.
+     */
+    ES_ERRCODE_UNSUPPORTED_WIFI_FREQUENCY,
+
+    /**
+     * Error Code that Unknown error occured
+     */
+    ES_ERRCODE_UNKNOWN = 255
 } ESErrorCode;
 
 #ifdef __cplusplus