--- /dev/null
+*.config
+*.creator
+*.user
+*.files
+*.includes
#define __OAUTH2_DOC_H__
/**
- * @defgroup CAPI_OAUTH2_MODULE oauth2
+ * @defgroup CAPI_OAUTH2_MODULE OAuth 2.0
* @ingroup CAPI_ACCOUNT_FRAMEWORK
- * @brief The oauth2 APIs provide easy way to gain access token between server and client.
+ * @brief The OAuth 2.0 APIs provide easy way to gain access token between server and client.
*
* @section CAPI_OAUTH2_HEADER Required Header
* \#include <oauth2.h>
* @section CAPI_OAUTH2_MODULE_OVERVIEW Overview
* The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, or by allowing the third-party application to obtain access on its own behalf.
*
+ * @if WEARABLE
+ * @section CAPI_OAUTH2_MODULE_FEATURE Related Features
+ * This API is related with the following features:
+ * - http://tizen.org/feature/network.internet
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * @endif
+ *
*/
#endif /* __OAUTH2_DOC_H__ */
/**
* Tizen OAuth 2.0 Authorization Framework.
- * Refer to http://tools.ietf.org/html/rfc6749 about oauth 2.0. Also service provider document needs to be referred for using end points and additional parameters.
+ * Refer to http://tools.ietf.org/html/rfc6749 about OAuth 2.0. Also service provider document needs to be referred for using end points and additional parameters.
*/
/**
* @{
*/
-/* End of oauth2 APIs */
+/* End of OAuth 2.0 APIs */
/**
* @}
*/
-#endif /* _OAUTH2_H_ */
+#endif // _OAUTH2_H_
/**
* @file oauth2_error.h
- * @brief The oauth 2.0 error APIs are used to get error fields received from server.
+ * @brief The OAuth 2.0 error APIs are used to get error fields received from server.
* Refer to service provider documentation about the allowed and additional fields.
*/
*/
/**
- * @brief The structure type for OAuth2 Error handle.
+ * @brief The structure type for OAuth 2.0 Error handle.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- * @privlevel public
+
*/
typedef struct oauth2_error_s *oauth2_error_h;
*/
OAUTH2_API int oauth2_error_get_custom_data(oauth2_error_h handle, const char *custom_key, char **custom_value);
-/* End of oauth2 APIs */
+/* End of OAuth 2.0 APIs */
/**
* @}
*/
/**
* @file oauth2_manager.h
- * @brief The main oauth 2.0 handler APIs.
+ * @brief The main OAuth 2.0 handler APIs.
* @details The Application must use either:
* oauth2_manager_request_token
* or
*/
/**
- * @brief The structure type for OAuth2 Manager handle.
+ * @brief The structure type for OAuth 2.0 Manager handle.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*/
typedef struct oauth2_manager_s *oauth2_manager_h;
* "internet" privilege is required to call this API. Note, only one pending request is allowed.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
* @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
*
* @param[in] handle The oauth2_manager_handle.
* @param[in] request The request handle.
* @retval #OAUTH2_ERROR_INVALID_PARAMETER Invalid input parameter(s) passed.
* @retval #OAUTH2_ERROR_ALREADY_IN_PROGRESS The previous request is already in progress.
* @retval #OAUTH2_ERROR_PERMISSION_DENIED Permission denied.
+ * @retval #OAUTH2_ERROR_NOT_SUPPORTED Not supported.
* @retval #OAUTH2_ERROR_PARSE_FAILED Parsing failed.
* @retval #OAUTH2_ERROR_NETWORK_ERROR Network Error.
* @retval #OAUTH2_ERROR_UNKNOWN Unknown system error.
* "internet" privilege is required to call this API. Note, only one pending request is allowed at a time.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
* @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
*
* @param[in] handle The oauth2_manager handle.
* @param[in] request The request handle.
* @retval #OAUTH2_ERROR_INVALID_PARAMETER Invalid input parameter(s) passed.
* @retval #OAUTH2_ERROR_ALREADY_IN_PROGRESS The previous request is already in progress.
* @retval #OAUTH2_ERROR_PERMISSION_DENIED Permission denied.
+ * @retval #OAUTH2_ERROR_NOT_SUPPORTED Not supported.
* @retval #OAUTH2_ERROR_PARSE_FAILED Parsing failed.
* @retval #OAUTH2_ERROR_NETWORK_ERROR Network Error.
* @retval #OAUTH2_ERROR_UNKNOWN Unknown system error.
* "internet" privilege is required to call this API. Note, only one pending request is allowed at a time.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
* @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
*
* @param[in] handle The oauth2_manager handle.
* @param[in] request The request handle.
* @retval #OAUTH2_ERROR_INVALID_PARAMETER Invalid input parameter(s) passed.
* @retval #OAUTH2_ERROR_ALREADY_IN_PROGRESS The previous request is already in progress.
* @retval #OAUTH2_ERROR_PERMISSION_DENIED Permission denied.
+ * @retval #OAUTH2_ERROR_NOT_SUPPORTED Not supported.
* @retval #OAUTH2_ERROR_PARSE_FAILED Parsing failed.
* @retval #OAUTH2_ERROR_NETWORK_ERROR Network Error.
* @retval #OAUTH2_ERROR_UNKNOWN Unknown system error.
* "internet" privilege is required to call this API. Note, only one pending request is allowed at a time.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
* @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
*
* @param[in] handle The oauth2_manager handle.
* @param[in] request The request handle.
* @retval #OAUTH2_ERROR_INVALID_PARAMETER Invalid input parameter(s) passed.
* @retval #OAUTH2_ERROR_ALREADY_IN_PROGRESS The previous request is already in progress.
* @retval #OAUTH2_ERROR_PERMISSION_DENIED Permission denied.
+ * @retval #OAUTH2_ERROR_NOT_SUPPORTED Not supported.
* @retval #OAUTH2_ERROR_PARSE_FAILED Parsing failed.
* @retval #OAUTH2_ERROR_NETWORK_ERROR Network Error.
* @retval #OAUTH2_ERROR_UNKNOWN Unknown system error.
* @brief Clears the cookies.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
* @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
*
* @param[in] handle The oauth2_manager handle.
*
* @retval #OAUTH2_ERROR_NONE Successful
* @retval #OAUTH2_ERROR_OUT_OF_MEMORY Out of Memory
* @retval #OAUTH2_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #OAUTH2_ERROR_PERMISSION_DENIED Permission denied.
+ * @retval #OAUTH2_ERROR_NOT_SUPPORTED Not supported.
*/
OAUTH2_API int oauth2_manager_clear_cookies(oauth2_manager_h handle);
* @brief Clears the cache.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
* @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
*
* @param[in] handle The oauth2_manager handle.
*
* @retval #OAUTH2_ERROR_NONE Successful
* @retval #OAUTH2_ERROR_OUT_OF_MEMORY Out of Memory
* @retval #OAUTH2_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #OAUTH2_ERROR_PERMISSION_DENIED Permission denied.
+ * @retval #OAUTH2_ERROR_NOT_SUPPORTED Not supported.
*/
OAUTH2_API int oauth2_manager_clear_cache(oauth2_manager_h handle);
-/* End of oauth2 APIs */
+/* End of OAuth 2.0 APIs */
/**
* @}
*/
/**
* @file oauth2_request.h
- * @brief The oauth 2.0 request APIs are used to set various parameters to send for oauth 2.0.
+ * @brief The OAuth 2.0 request APIs are used to set various parameters to send for OAuth 2.0.
* Refer to service provider documentation about the allowed and additional fields.
*/
*/
/**
- * @brief The structure type for OAuth2 Request handle.
+ * @brief The structure type for OAuth 2.0 Request handle.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*/
typedef struct oauth2_request_s *oauth2_request_h;
*/
OAUTH2_API int oauth2_request_get_custom_data(oauth2_request_h handle, const char *custom_key, char **custom_value);
-/* End of oauth2 APIs */
+/* End of OAuth 2.0 APIs */
/**
* @}
*/
/**
* @file oauth2_response.h
- * @brief The oauth 2.0 response APIs are used to get various parameters received from server.
+ * @brief The OAuth 2.0 response APIs are used to get various parameters received from server.
* Refer to service provider documentation about the allowed and additional fields.
*/
*/
/**
- * @brief The structure type for OAuth2 Response handle.
+ * @brief The structure type for OAuth 2.0 Response handle.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*/
typedef struct oauth2_response_s *oauth2_response_h;
*/
OAUTH2_API int oauth2_response_get_custom_data(oauth2_response_h handle, const char *custom_key, char **custom_value);
-/* End of oauth2 APIs */
+/* End of OAuth 2.0 APIs */
/**
* @}
*/
/**
* @file oauth2_types.h
- * @brief This file defines common types and enums of oauth2.
+ * @brief This file defines common types and enums of OAuth 2.0.
*/
/**
* @see oauth2_request_set_client_authentication_type()
*/
typedef enum {
- OAUTH2_CLIENT_AUTHENTICATION_TYPE_MIN = -1,/**< @internal**/
OAUTH2_CLIENT_AUTHENTICATION_TYPE_BASIC,/**< HTTP Basic Authentication for client authentication.**/
OAUTH2_CLIENT_AUTHENTICATION_TYPE_DIGEST,/**< HTTP Digest Authentication for client authentication.**/
- OAUTH2_CLIENT_AUTHENTICATION_TYPE_REQUEST_BODY,/**< Client credentials are sent via request body**/
- OAUTH2_CLIENT_AUTHENTICATION_TYPE_MAX,/**< @internal**/
-} oauth2_client_authentication_type_e;
+ OAUTH2_CLIENT_AUTHENTICATION_TYPE_REQUEST_BODY/**< Client credentials are sent via request body**/
+}oauth2_client_authentication_type_e;
/**
* @brief Enumerations to set grant_type.
* @see oauth2_request_set_grant_type()
*/
typedef enum {
- OAUTH2_GRANT_TYPE_MIN = -1, /**< @internal**/
OAUTH2_GRANT_TYPE_AUTH_CODE, /**< Access Token Request for Authorization Code Grant type.**/
OAUTH2_GRANT_TYPE_PASSWORD, /**< Access Token Request for Resource Owner Password Credentials Grant type.**/
OAUTH2_GRANT_TYPE_CLIENT_CREDENTIALS, /**< Access Token Request for Client Credentials Grant type.**/
- OAUTH2_GRANT_TYPE_REFRESH, /**< Refresh Token Request.**/
- OAUTH2_GRANT_TYPE_MAX, /**< @internal**/
-} oauth2_grant_type_e;
+ OAUTH2_GRANT_TYPE_REFRESH /**< Refresh Token Request.**/
+}oauth2_grant_type_e;
/**
* @brief Enumerations to set response_type.
* @see oauth2_request_set_response_type()
*/
typedef enum {
- OAUTH2_RESPONSE_TYPE_MIN = -1, /**< @internal**/
OAUTH2_RESPONSE_TYPE_CODE,/**< Requesting an authorization code as response type.**/
- OAUTH2_RESPONSE_TYPE_TOKEN,/**< Requesting an access token(implicit grant) as response type.**/
- OAUTH2_RESPONSE_TYPE_MAX, /**< @internal**/
-} oauth2_response_type_e;
+ OAUTH2_RESPONSE_TYPE_TOKEN/**< Requesting an access token(implicit grant) as response type.**/
+}oauth2_response_type_e;
/**
* @brief Enumerations of error codes for oauth2 APIs.
- * @since_tizen 3.0
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*/
typedef enum {
- OAUTH2_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- OAUTH2_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- OAUTH2_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ OAUTH2_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ OAUTH2_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ OAUTH2_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- OAUTH2_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */
- OAUTH2_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Operation not supported */
- OAUTH2_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
- OAUTH2_ERROR_PARSE_FAILED = TIZEN_ERROR_ACCOUNT_OAUTH | 0x01, /**< Response parse failed */
- OAUTH2_ERROR_NETWORK_ERROR = TIZEN_ERROR_ACCOUNT_OAUTH | 0x02, /**< Network error */
- OAUTH2_ERROR_SERVER = TIZEN_ERROR_ACCOUNT_OAUTH | 0x03, /**< Server error */
- OAUTH2_ERROR_USER_CANCELLED = TIZEN_ERROR_ACCOUNT_OAUTH | 0x04, /**< User cancelled the operation */
+ OAUTH2_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */
+ OAUTH2_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Operation not supported */
+ OAUTH2_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ OAUTH2_ERROR_PARSE_FAILED = TIZEN_ERROR_ACCOUNT_OAUTH | 0x01, /**< Response parse failed */
+ OAUTH2_ERROR_NETWORK_ERROR = TIZEN_ERROR_ACCOUNT_OAUTH | 0x02, /**< Network error */
+ OAUTH2_ERROR_SERVER = TIZEN_ERROR_ACCOUNT_OAUTH | 0x03, /**< Server error */
+ OAUTH2_ERROR_USER_CANCELLED = TIZEN_ERROR_ACCOUNT_OAUTH | 0x04, /**< User cancelled the operation */
- OAUTH2_ERROR_VALUE_NOT_FOUND = TIZEN_ERROR_ACCOUNT_OAUTH | 0x05, /**< Value not found */
- OAUTH2_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN /**< Unknown error */
-} oauth2_error_e;
+ OAUTH2_ERROR_VALUE_NOT_FOUND = TIZEN_ERROR_ACCOUNT_OAUTH | 0x05, /**< Value not found */
+ OAUTH2_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN /**< Unknown error */
+}oauth2_error_e;
-/* End of oauth2 APIs */
+/* End of OAuth 2.0 APIs */
/**
* @}
*/
BuildRequires: pkgconfig(json-glib-1.0)
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(tpkp-curl)
+BuildRequires: pkgconfig(cynara-client)
+BuildRequires: pkgconfig(capi-system-info)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
if(USE_CHROMIUM_EFL)
add_definitions(-DWITH_CHROMIUM)
- pkg_check_modules(clientpkgs REQUIRED dlog glib-2.0 gio-2.0 gio-unix-2.0 capi-base-common libcurl efl-extension ecore evas chromium-efl json-glib-1.0 elementary tpkp-curl)
+ pkg_check_modules(clientpkgs REQUIRED dlog glib-2.0 gio-2.0 gio-unix-2.0 capi-base-common libcurl efl-extension ecore evas chromium-efl json-glib-1.0 elementary tpkp-curl cynara-client capi-system-info)
else()
- pkg_check_modules(clientpkgs REQUIRED dlog glib-2.0 gio-2.0 gio-unix-2.0 capi-base-common libcurl efl-extension ecore evas ewebkit2 json-glib-1.0 elementary tpkp-curl)
+ pkg_check_modules(clientpkgs REQUIRED dlog glib-2.0 gio-2.0 gio-unix-2.0 capi-base-common libcurl efl-extension ecore evas ewebkit2 json-glib-1.0 elementary tpkp-curl cynara-client capi-system-info)
endif()
FOREACH(flag ${clientpkgs_CFLAGS})
#include <efl_extension.h>
#include <tpkp_curl.h>
+#include <cynara-client.h>
+#include <cynara-error.h>
+#include <system_info.h>
#include "oauth2_manager.h"
#include "oauth2_util.h"
#include "oauth2_private.h"
+#define NETWORK_FEATURE "tizen.org/feature/network.internet"
+#define INTERNET_PRIVILEGE "http://tizen.org/privilege/internet"
+#define SMACK_LABEL_LEN 255
+
static void __send_response_to_caller(oauth2_manager_s *mgr_handle);
static void __convert_tizen_error_to_oauth_error(int tizen_error,
char *error_desc, oauth2_response_s **response_handle);
"Null Input");
OAUTH2_FREE(handle);
+
+ ewk_shutdown();
return OAUTH2_ERROR_NONE;
}
/*LCOV_EXCL_START*/
+static bool
+__is_feature_supported(void)
+{
+ bool supported = FALSE;
+ int ret = system_info_get_platform_bool(NETWORK_FEATURE, &supported);
+ OAUTH2_RETURN_VAL(ret == SYSTEM_INFO_ERROR_NONE, {}, false, "network feature support check failed");
+
+ return supported;
+}
+
+static bool
+__check_permission(void)
+{
+ static int has_internet_permission = -1;
+
+ if (-1 == has_internet_permission) {
+ int ret;
+ char smack_label[SMACK_LABEL_LEN + 1] = {0};
+ char uid[10];
+ FILE *fd;
+ cynara *cynara_h;
+
+ ret = cynara_initialize(&cynara_h, NULL);
+ if (CYNARA_API_SUCCESS != ret) {
+ OAUTH2_LOG_E("cynara_initialize() Fail(%d)", ret);
+ return false;
+ }
+
+ fd = fopen("/proc/self/attr/current", "r");
+ if (NULL == fd) {
+ OAUTH2_LOG_E("fopen() Fail(%d)", errno);
+ return false;
+ }
+
+ ret = fread(smack_label, sizeof(smack_label), 1, fd);
+ fclose(fd);
+ if (ret < 0) {
+ OAUTH2_LOG_E("fread() Fail(%d)", ret);
+ return 0;
+ }
+
+ snprintf(uid, sizeof(uid), "%d", getuid());
+
+ ret = cynara_check(cynara_h, smack_label, "", uid, INTERNET_PRIVILEGE);
+ if (CYNARA_API_ACCESS_ALLOWED == ret)
+ has_internet_permission = 1;
+ else
+ has_internet_permission = 0;
+
+ cynara_finish(cynara_h);
+ }
+
+ if (has_internet_permission == 0) {
+ OAUTH2_LOG_E("Privilege denied");
+ return false;
+ }
+
+ OAUTH2_LOG_I("Privilege granted");
+ return true;
+}
+
static void
__hide_web_view(oauth2_manager_s *mgr_handle)
{
return NULL;
char *str_val = NULL;
- int grant_type = OAUTH2_GRANT_TYPE_MIN;
+ int grant_type = OAUTH2_GRANT_TYPE_AUTH_CODE;
sscanf(grant_type_str, "%d", &grant_type);
- if (grant_type <= OAUTH2_GRANT_TYPE_MIN
- || grant_type >= OAUTH2_GRANT_TYPE_MAX) {
+ if (grant_type < OAUTH2_GRANT_TYPE_AUTH_CODE
+ || grant_type > OAUTH2_GRANT_TYPE_REFRESH) {
OAUTH2_LOG_E("Invalid grant_type [%d]", grant_type);
return NULL;
} else if (grant_type == OAUTH2_GRANT_TYPE_AUTH_CODE)
return NULL;
char *str_val = NULL;
- int response_type = OAUTH2_RESPONSE_TYPE_MIN;
+ int response_type = OAUTH2_RESPONSE_TYPE_CODE;
sscanf(response_type_str, "%d", &response_type);
- if (response_type <= OAUTH2_RESPONSE_TYPE_MIN
- || response_type >= OAUTH2_RESPONSE_TYPE_MAX) {
+ if (response_type < OAUTH2_RESPONSE_TYPE_CODE
+ || response_type > OAUTH2_RESPONSE_TYPE_TOKEN) {
OAUTH2_LOG_E("Invalid response_type [%d]", response_type);
return NULL;
} else if (response_type == OAUTH2_RESPONSE_TYPE_CODE)
OAUTH2_LOG_I("__append_to_post_data start");
char *encoded_key = curl_easy_escape(curl_handle, key, 0);
+ if (encoded_key == NULL) {
+ OAUTH2_LOG_I("curl encoded key null");
+ return;
+ }
+
char *encoded_val = curl_easy_escape(curl_handle, value, 0);
+ if (encoded_val == NULL) {
+ OAUTH2_LOG_I("curl encoded value null");
+ return;
+ }
strncat(post_data, encoded_key, strlen(encoded_key));
strncat(post_data, "=", 1);
oauth2_response_s *response_temp = (oauth2_response_s *)calloc(1,
sizeof(oauth2_response_s));
+ if (response_temp == NULL) {
+ OAUTH2_LOG_E("Out of memory");
+ return;
+ }
/*
* First find if error key is there, if present only fillup
* oauth2_error_s else fillup oauth2_response_s without
int ret = oauth2_util_get_params(response_json, ¶ms);
if (ret != OAUTH2_ERROR_NONE && params == NULL) {
OAUTH2_LOG_E("Server response parse failed");
+
goto CATCH;
}
response_temp->response_data = params;
root_node = json_parser_get_root(parser);
if (root_node == NULL) {
OAUTH2_LOG_E("json_parser_get_root() failed");
+
goto CATCH;
}
root_obj = json_node_get_object((JsonNode *) root_node);
if (root_obj == NULL) {
OAUTH2_LOG_E("json_node_get_object() failed");
+
goto CATCH;
}
OAUTH2_LOG_I("__parse_acc_token_response parse finished");
*response = response_temp;
+ response_temp = NULL;
CATCH:
g_object_unref(parser);
+ if (response_temp != NULL)
+ oauth2_response_destroy((oauth2_response_h)response_temp);
+
OAUTH2_LOG_I("__parse_acc_token_response end");
}
== 0) {
char *query = NULL;
ret = oauth2_util_get_query(response_url, &query);
- if (ret != OAUTH2_ERROR_NONE && query != NULL) {
+ if (ret != OAUTH2_ERROR_NONE && query == NULL) {
__convert_tizen_error_to_oauth_error(
OAUTH2_ERROR_SERVER,
"Server response does not contain query",
&(mgr_handle->response));
__send_response_to_caller(mgr_handle);
+ bundle_free(params);
+
return;
}
ret = oauth2_util_get_params(query, ¶ms);
- if (ret != OAUTH2_ERROR_NONE && params != NULL) {
+ if (ret != OAUTH2_ERROR_NONE && params == NULL) {
__convert_tizen_error_to_oauth_error(
OAUTH2_ERROR_PARSE_FAILED,
"Server response parse failed",
&(mgr_handle->response));
__send_response_to_caller(mgr_handle);
OAUTH2_FREE(query);
+
return;
}
is_two_step = TRUE;
OAUTH2_FREE(query);
+
} else if (strcmp(response_type,
OAUTH2_PARAMETER_VAL_RESPONSE_TYPE_TOKEN) == 0) {
char *fragment = NULL;
ret = oauth2_util_get_fragment(response_url, &fragment);
- if (ret != OAUTH2_ERROR_NONE && fragment != NULL) {
+ if (ret != OAUTH2_ERROR_NONE && fragment == NULL) {
__convert_tizen_error_to_oauth_error(
OAUTH2_ERROR_SERVER,
"Server response does not contain fragment",
&(mgr_handle->response));
__send_response_to_caller(mgr_handle);
+
+ if (params)
+ bundle_free(params);
+
return;
}
"Server response parse failed",
&(mgr_handle->response));
__send_response_to_caller(mgr_handle);
+
OAUTH2_FREE(fragment);
+
return;
}
OAUTH2_FREE(fragment);
+
} else {
/* TODO: Handle custom response_type (for eg, Facebook,
* Soundcloud supports "token_and_code") */
return;
}
_request_access_token_by_code(mgr_handle, code_val);
+
+ if (params)
+ bundle_free(params);
+
} else {
mgr_handle->is_active = FALSE;
mgr_handle->response = (oauth2_response_s *)calloc(1,
elm_object_text_set(mgr_handle->loading_popup, OAUTH2_LOADING_POP_UP_TEXT);
elm_popup_orient_set(mgr_handle->loading_popup, ELM_POPUP_ORIENT_BOTTOM);
- /* ewk_init(); */
+ ewk_init();
Evas *canvas = NULL;
EEXT_CALLBACK_BACK, __handle_back_key, mgr_handle);
ewk_view_url_set(mgr_handle->ewk_view, authorization_url);
-
evas_object_size_hint_min_set(mgr_handle->ewk_view, 480, 800);
+
+ /*Ecore_X_Screen *screen = ecore_x_default_screen_get();
+ if (screen != NULL) {
+ int w = 0;
+ int h = 0;
+ ecore_x_screen_size_get (screen, &w, &h);
+ LOGI("Screen info = [%d][%d]", w, h);
+
+ evas_object_size_hint_min_set(mgr_handle->ewk_view, w, h);
+ }*/
+
evas_object_size_hint_weight_set(mgr_handle->ewk_view,
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(mgr_handle->ewk_view,
OAUTH2_RETURN_VAL(request, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"request is Null");
/*LCOV_EXCL_START*/
+ OAUTH2_RETURN_VAL(__is_feature_supported(), {}, OAUTH2_ERROR_NOT_SUPPORTED,
+ "network feature not supported");
+
+ OAUTH2_RETURN_VAL(__check_permission(), {}, OAUTH2_ERROR_PERMISSION_DENIED,
+ "permission denied, no internet privilege");
+
oauth2_manager_s *mgr_impl = (oauth2_manager_s *)handle;
OAUTH2_RETURN_VAL(!mgr_impl->is_active, {},
OAUTH2_ERROR_ALREADY_IN_PROGRESS, "Already in progress");
OAUTH2_RETURN_VAL(request, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"request is Null");
/*LCOV_EXCL_START*/
+ OAUTH2_RETURN_VAL(__is_feature_supported(), {}, OAUTH2_ERROR_NOT_SUPPORTED,
+ "network feature not supported");
+
+ OAUTH2_RETURN_VAL(__check_permission(), {}, OAUTH2_ERROR_PERMISSION_DENIED,
+ "permission denied, no internet privilege");
+
oauth2_manager_s *mgr_impl = (oauth2_manager_s *)handle;
OAUTH2_RETURN_VAL(!mgr_impl->is_active, {},
OAUTH2_ERROR_ALREADY_IN_PROGRESS, "Already in progress");
OAUTH2_RETURN_VAL(request, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"request is Null");
/*LCOV_EXCL_START*/
+ OAUTH2_RETURN_VAL(__is_feature_supported(), {}, OAUTH2_ERROR_NOT_SUPPORTED,
+ "network feature not supported");
+
+ OAUTH2_RETURN_VAL(__check_permission(), {}, OAUTH2_ERROR_PERMISSION_DENIED,
+ "permission denied, no internet privilege");
+
oauth2_manager_s *mgr_impl = (oauth2_manager_s *)handle;
OAUTH2_RETURN_VAL(!mgr_impl->is_active, {},
OAUTH2_ERROR_ALREADY_IN_PROGRESS, "Already in progress");
char *code = NULL;
bundle_get_str(mgr_impl->request->request_data,
OAUTH2_PARAMETER_KEY_CODE, &code);
- if (code)
+ if (code) {
_request_access_token_by_code(mgr_impl, code);
+ return OAUTH2_ERROR_NONE;
+ }
+
} else {
/*
* For resource owner pwd and client credentials, grant_type
OAUTH2_RETURN_VAL(request, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"request is Null");
/*LCOV_EXCL_START*/
+ OAUTH2_RETURN_VAL(__is_feature_supported(), {}, OAUTH2_ERROR_NOT_SUPPORTED,
+ "network feature not supported");
+
+ OAUTH2_RETURN_VAL(__check_permission(), {}, OAUTH2_ERROR_PERMISSION_DENIED,
+ "permission denied, no internet privilege");
+
oauth2_manager_s *mgr_impl = (oauth2_manager_s *)handle;
OAUTH2_RETURN_VAL(!mgr_impl->is_active, {},
OAUTH2_ERROR_ALREADY_IN_PROGRESS, "Already in progress");
OAUTH2_RETURN_VAL(handle, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"handle is Null");
/*LCOV_EXCL_START*/
+ OAUTH2_RETURN_VAL(__is_feature_supported(), {}, OAUTH2_ERROR_NOT_SUPPORTED,
+ "network feature not supported");
+
+ OAUTH2_RETURN_VAL(__check_permission(), {}, OAUTH2_ERROR_PERMISSION_DENIED,
+ "permission denied, no internet privilege");
+
oauth2_manager_s *mgr_impl = (oauth2_manager_s *)handle;
Evas_Object *web_view = mgr_impl->ewk_view;
OAUTH2_RETURN_VAL(handle, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"handle is Null");
/*LCOV_EXCL_START*/
+ OAUTH2_RETURN_VAL(__is_feature_supported(), {}, OAUTH2_ERROR_NOT_SUPPORTED,
+ "network feature not supported");
+
+ OAUTH2_RETURN_VAL(__check_permission(), {}, OAUTH2_ERROR_PERMISSION_DENIED,
+ "permission denied, no internet privilege");
+
oauth2_manager_s *mgr_impl = (oauth2_manager_s *)handle;
Evas_Object *web_view = mgr_impl->ewk_view;
OAUTH2_RETURN_VAL(handle, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"NULL handle");
- if (response_type <= OAUTH2_RESPONSE_TYPE_MIN
- || response_type >= OAUTH2_RESPONSE_TYPE_MAX) {
+ if (response_type < OAUTH2_RESPONSE_TYPE_CODE
+ || response_type > OAUTH2_RESPONSE_TYPE_TOKEN) {
OAUTH2_LOG_E("Invalid response_type [%d]", response_type);
return OAUTH2_ERROR_INVALID_PARAMETER;
}
OAUTH2_RETURN_VAL(handle, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"NULL handle");
- if (client_auth_type <= OAUTH2_CLIENT_AUTHENTICATION_TYPE_MIN
- || client_auth_type >= OAUTH2_CLIENT_AUTHENTICATION_TYPE_MAX) {
+ if (client_auth_type < OAUTH2_CLIENT_AUTHENTICATION_TYPE_BASIC
+ || client_auth_type > OAUTH2_CLIENT_AUTHENTICATION_TYPE_REQUEST_BODY) {
OAUTH2_LOG_E("Invalid client_auth_type [%d]", client_auth_type);
return OAUTH2_ERROR_INVALID_PARAMETER;
}
OAUTH2_RETURN_VAL(handle, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"NULL handle");
- if (grant_type <= OAUTH2_GRANT_TYPE_MIN
- || grant_type >= OAUTH2_GRANT_TYPE_MAX) {
+ if (grant_type < OAUTH2_GRANT_TYPE_AUTH_CODE
+ || grant_type > OAUTH2_GRANT_TYPE_REFRESH) {
OAUTH2_LOG_E("Invalid grant_type [%d]", grant_type);
return OAUTH2_ERROR_INVALID_PARAMETER;
}
OAUTH2_RETURN_VAL(handle, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"NULL handle");
+ int res;
oauth2_request_s *request_data_temp = (oauth2_request_s *)handle;
char *val = NULL;
if (!val)
return OAUTH2_ERROR_VALUE_NOT_FOUND;
- sscanf(val, "%d", response_type);
+ sscanf(val, "%d", &res);
+ *response_type = (oauth2_response_type_e) res;
+
return OAUTH2_ERROR_NONE;
}
OAUTH2_RETURN_VAL(handle, {}, OAUTH2_ERROR_INVALID_PARAMETER,
"NULL handle");
+ int res;
oauth2_request_s *request_data_temp = (oauth2_request_s *)handle;
char *val = NULL;
if (!val)
return OAUTH2_ERROR_VALUE_NOT_FOUND;
- sscanf(val, "%d", grant_type);
+ sscanf(val, "%d", &res);
+ *grant_type = (oauth2_grant_type_e) res;
+
return OAUTH2_ERROR_NONE;
}
memset(key, '\0', ((eq_ptr - tmp_start) + 1) * sizeof(char));
strncpy(key, tmp_start, (eq_ptr - tmp_start));
- eq_ptr++;
+ if (eq_ptr != NULL)
+ eq_ptr++;
key_size = (tmp_end - eq_ptr) + 1;
char *val = (char *) malloc((key_size) * sizeof(char));
if (val == NULL) {
+ OAUTH2_LOG_E("Out of memory");
OAUTH2_FREE(key);
return OAUTH2_ERROR_OUT_OF_MEMORY;
}