1 /* ****************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #ifndef OC_ACCOUNT_MANAGER_H_
22 #define OC_ACCOUNT_MANAGER_H_
25 #include <IClientWrapper.h>
26 #include <InProcClientWrapper.h>
30 class OCAccountManager
32 friend class OCPlatform_impl;
35 typedef std::shared_ptr<OCAccountManager> Ptr;
37 OCAccountManager(OCAccountManager&&) = default;
38 OCAccountManager(const OCAccountManager&) = delete;
39 OCAccountManager& operator=(OCAccountManager&&) = delete;
40 OCAccountManager& operator=(const OCAccountManager&) = delete;
42 virtual ~OCAccountManager(void);
45 * Function to get the host address of account server
47 * @return std::string host address
49 std::string host() const;
52 * Function to get the connectivity type for account server
54 * @return enum connectivity type (flags and adapter)
56 OCConnectivityType connectivityType() const;
59 * Function for account registration to account server
61 * @param authProvider Provider name used for authentication.
62 * @param authCode The authorization code obtained by using an authorization server
63 * as an intermediary between the client and resource owner.
64 * @param cloudConnectHandler Callback function that will get the result of the operation.
66 * @return Returns ::OC_STACK_OK if success
68 OCStackResult signUp(const std::string& authProvider,
69 const std::string& authCode,
70 PostCallback cloudConnectHandler);
75 * @param authProvider Provider name used for authentication.
76 * @param authCode The authorization code obtained by using an authorization server
77 * as an intermediary between the client and resource owner.
78 * @param options The option values depends on auth provider.
79 * @param cloudConnectHandler Callback function that will get the result of the operation.
81 * @return Returns ::OC_STACK_OK if success
83 OCStackResult signUp(const std::string& authProvider,
84 const std::string& authCode,
85 const QueryParamsMap& options,
86 PostCallback cloudConnectHandler);
89 * Function for sign-in to account server
91 * @param userUuid Identifier of the user obtained by account registration.
92 * @param accessToken Identifier of the resource obtained by account registration.
93 * @param cloudConnectHandler Callback function that will get the result of the operation.
95 * @return Returns ::OC_STACK_OK if success
97 OCStackResult signIn(const std::string& userUuid,
98 const std::string& accessToken,
99 PostCallback cloudConnectHandler);
102 * Function for sign-out to account server
104 * @param cloudConnectHandler Callback function that will get the result of the operation.
106 * @return Returns ::OC_STACK_OK if success
108 OCStackResult signOut(PostCallback cloudConnectHandler);
111 * Function for refresh access token to account server
113 * @param userUuid Identifier of the user obtained by account registration.
114 * @param refreshToken Refresh token used for access token refresh.
115 * @param cloudConnectHandler Callback function that will get the result of the operation.
117 * @return Returns ::OC_STACK_OK if success
119 OCStackResult refreshAccessToken(const std::string& userUuid,
120 const std::string& refreshToken,
121 PostCallback cloudConnectHandler);
124 * Function to get information of the user to account server
126 * @param userUuid Identifier of the user to get information.
127 * @param cloudConnectHandler Callback function that will get the result of the operation.
129 * @return Returns ::OC_STACK_OK if success
131 OCStackResult searchUser(const std::string& userUuid,
132 GetCallback cloudConnectHandler);
137 * @param queryParams Map which can have the query key and value for specific users.
138 * account server can response information of more than one user.
139 * @param cloudConnectHandler Callback function that will get the result of the operation.
141 * @return Returns ::OC_STACK_OK if success
143 OCStackResult searchUser(const QueryParamsMap& queryParams,
144 GetCallback cloudConnectHandler);
147 * Function to delete the device registered on the account signed-in
149 * @param deviceId Device ID to delete.
150 * @param cloudConnectHandler Callback function that will get the result of the operation.
152 * @return Returns ::OC_STACK_OK if success
154 OCStackResult deleteDevice(const std::string& deviceId,
155 DeleteCallback cloudConnectHandler);
158 std::weak_ptr<IClientWrapper> m_clientWrapper;
159 std::string m_deviceID;
161 OCConnectivityType m_connType;
162 QualityOfService m_defaultQos;
165 OCAccountManager(std::weak_ptr<IClientWrapper> clientWrapper,
166 const std::string& host,
167 OCConnectivityType connectivityType);
169 OCStackResult signInOut(const std::string& userUuid,
170 const std::string& accessToken,
172 PostCallback cloudConnectHandler);
174 OCStackResult searchUser(const std::string& userUuid,
175 const QueryParamsMap& queryParams,
176 GetCallback cloudConnectHandler);
180 #endif // OC_ACCOUNT_MANAGER_H_