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 userId 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& userId,
98 const std::string& accessToken,
99 PostCallback cloudConnectHandler);
102 * Function for sign-out to account server
104 * @param userId Identifier of the user obtained by account registration.
105 * @param accessToken Identifier of the resource obtained by account registration.
106 * @param cloudConnectHandler Callback function that will get the result of the operation.
108 * @return Returns ::OC_STACK_OK if success
110 OCStackResult signOut(const std::string& userId,
111 const std::string& accessToken,
112 PostCallback cloudConnectHandler);
115 * Function for refresh access token to account server
117 * @param userId Identifier of the user obtained by account registration.
118 * @param refreshToken Refresh token used for access token refresh.
119 * @param cloudConnectHandler Callback function that will get the result of the operation.
121 * @return Returns ::OC_STACK_OK if success
123 OCStackResult refreshAccessToken(const std::string& userId,
124 const std::string& refreshToken,
125 PostCallback cloudConnectHandler);
128 std::weak_ptr<IClientWrapper> m_clientWrapper;
129 std::string m_deviceID;
131 OCConnectivityType m_connType;
132 QualityOfService m_defaultQos;
135 OCAccountManager(std::weak_ptr<IClientWrapper> clientWrapper,
136 const std::string& host,
137 OCConnectivityType connectivityType);
139 OCStackResult signInOut(const std::string& userId,
140 const std::string& accessToken,
142 PostCallback cloudConnectHandler);
146 #endif // OC_ACCOUNT_MANAGER_H_