4 * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. 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.
25 #include "oauth2_service.h"
26 #include "auth_adaptor.h"
27 #include "service_adaptor_errors.h"
28 #include "service_adaptor_internal.h"
30 #include "sal_auth_provider.h"
32 //******************************************************************************
33 //* Global variables and defines
34 //******************************************************************************
36 typedef struct _app_control_user_data_s
40 } app_control_user_data_s;
41 typedef struct _app_control_user_data_s *app_control_user_data_h;
43 typedef int (*_get_access_token)(void *plugin, char **access_token, void *user_data);
44 typedef int (*_get_extra_data)(void *plugin, const char *key, char **value, void *user_data);
46 //******************************************************************************
48 //******************************************************************************
50 //******************************************************************************
51 //* Private interface definition
52 //******************************************************************************
54 static int _oauth2_get_access_token(auth_plugin_h plugin, char **access_token, void *user_data)
58 RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
60 return SERVICE_ADAPTOR_ERROR_NONE;
63 static int _oauth2_get_extra_data(auth_plugin_h plugin, const char *key, char **value, void *user_data)
67 RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
69 return SERVICE_ADAPTOR_ERROR_NONE;
72 //******************************************************************************
73 //* Public interface definition
74 //******************************************************************************
76 API int oauth2_register_service(oauth2_service_h oauth2, GHashTable *service)
80 RETV_IF(NULL == oauth2, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
82 int ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
84 gpointer iter_key, iter_value;
86 g_hash_table_iter_init(&iter, service);
87 while (g_hash_table_iter_next(&iter, &iter_key, &iter_value))
89 if (0 == strcmp(iter_key, OAUTH2_0_GET_ACCESS_TOKEN_URI))
91 oauth2->oauth2_get_access_token = (_get_access_token) _oauth2_get_access_token;
92 ret = SERVICE_ADAPTOR_ERROR_NONE;
94 else if (0 == strcmp(iter_key, OAUTH2_0_GET_EXTRA_DATA_URI))
96 oauth2->oauth2_get_extra_data = (_get_extra_data) _oauth2_get_extra_data;
97 ret = SERVICE_ADAPTOR_ERROR_NONE;
104 API int oauth2_unregister_service(oauth2_service_h oauth2)
108 RETV_IF(NULL == oauth2, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
110 oauth2->oauth2_get_access_token = NULL;
111 oauth2->oauth2_get_extra_data = NULL;
113 return SERVICE_ADAPTOR_ERROR_NONE;