• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_LIB_H
17 #define OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_LIB_H
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 typedef struct {
23     char* data;
24     size_t length;
25 } PluginString;
26 
27 typedef struct {
28     uint8_t* data;
29     size_t size;
30     size_t capcity;
31 } PluginUint8Vector;
32 
33 typedef struct {
34     int32_t code;
35     PluginString msg;
36 } PluginBussnessError;
37 
38 typedef struct {
39     PluginString id;
40     PluginString domain;
41     PluginString parameters;
42 } PluginServerConfigInfo;
43 
44 typedef struct {
45     PluginString serverConfigId;
46     PluginString domain;
47     PluginString accountName;
48     PluginString accountId;
49     int32_t isAuthenticated;
50 } PluginDomainAccountInfo;
51 
52 typedef struct {
53     PluginServerConfigInfo *items;
54     size_t size;
55 } PluginServerConfigInfoList;
56 
57 typedef struct {
58     PluginUint8Vector accountToken;
59     int32_t remainTimes;
60     int32_t freezingTime;
61 } PluginAuthResultInfo;
62 
63 typedef struct {
64     PluginDomainAccountInfo domainAccountInfo;
65     int32_t callerUid;
66 } PluginGetDomainAccountInfoOptions;
67 
68 typedef struct {
69     int32_t remainTimes;
70     int32_t freezingTime;
71 } PluginAuthStatusInfo;
72 
73 typedef struct {
74     PluginDomainAccountInfo domainAccountInfo;
75     PluginUint8Vector domainAccountToken;
76     PluginString bussinessParams;
77     int32_t callerUid;
78 } PluginGetDomainAccessTokenOptions;
79 
80 typedef struct {
81     PluginString parameters;
82 } PluginDomainAccountPolicy;
83 
84 typedef PluginBussnessError* (*AddServerConfigFunc)(const PluginString *parameters, const int32_t callerLocalId,
85     PluginServerConfigInfo **serverConfigInfo);
86 typedef PluginBussnessError* (*RemoveServerConfigFunc)(const PluginString *serverConfigId, const int32_t callerLocalId);
87 typedef PluginBussnessError* (*UpdateServerConfigFunc)(const PluginString *serverConfigId,
88     const PluginString *parameters, const int32_t callerLocalId, PluginServerConfigInfo **serverConfigInfo);
89 typedef PluginBussnessError* (*GetServerConfigFunc)(const PluginString *serverConfigId, const int32_t callerLocalId,
90     PluginServerConfigInfo **serverConfigInfo);
91 typedef PluginBussnessError* (*GetServerConfigListFunc)(PluginServerConfigInfoList **serverConfigInfoList);
92 typedef PluginBussnessError* (*GetAccountServerConfigFunc)(const PluginDomainAccountInfo *domainAccountInfo,
93     PluginServerConfigInfo **serverConfigInfo);
94 typedef PluginBussnessError* (*AuthFunc)(const PluginDomainAccountInfo *domainAccountInfo,
95     const PluginUint8Vector *credential, const int32_t callerLocalId, PluginAuthResultInfo **authResultInfo);
96 typedef PluginBussnessError* (*AuthWithPopupFunc)(const PluginDomainAccountInfo *domainAccountInfo,
97     PluginAuthResultInfo **authResultInfo);
98 typedef PluginBussnessError* (*AuthWithTokenFunc)(const PluginDomainAccountInfo *domainAccountInfo,
99     const PluginUint8Vector *token, PluginAuthResultInfo **authResultInfo);
100 typedef PluginBussnessError* (*GetAccountInfoFunc)(const PluginGetDomainAccountInfoOptions *options,
101     const int32_t callerLocalId, PluginDomainAccountInfo **domainAccountInfo);
102 typedef PluginBussnessError* (*GetAuthStatusInfoFunc)(const PluginDomainAccountInfo *domainAccountInfo,
103     PluginAuthStatusInfo **authStatusInfo);
104 typedef PluginBussnessError* (*BindAccountFunc)(const PluginDomainAccountInfo *domainAccountInfo, const int32_t localId,
105     const int32_t callerLocalId);
106 typedef PluginBussnessError* (*UnbindAccountFunc)(const PluginDomainAccountInfo *domainAccountInfo,
107     const int32_t localId);
108 typedef PluginBussnessError* (*UpdateAccountInfoFunc)(const PluginDomainAccountInfo *domainAccountInfo,
109     const PluginDomainAccountInfo *newDomainAccountInfo, const int32_t callerLocalId);
110 typedef PluginBussnessError* (*IsAccountTokenValidFunc)(const PluginDomainAccountInfo *domainAccountInfo,
111     const PluginUint8Vector *token, int32_t *isValid);
112 typedef PluginBussnessError* (*IsAuthenticationExpiredFunc)(const PluginDomainAccountInfo *domainAccountInfo,
113     const PluginUint8Vector *token, int32_t *isValid);
114 typedef PluginBussnessError* (*GetAccessTokenFunc)(const PluginGetDomainAccessTokenOptions *options,
115     PluginUint8Vector **accessToken);
116 typedef PluginBussnessError* (*GetAccountPolicyFunc)(const PluginDomainAccountInfo *domainAccountInfo,
117     const int32_t callerLocalId, PluginDomainAccountPolicy **domainAccountPolicy);
118 typedef PluginBussnessError* (*SetAccountPolicyFunc)(const PluginString *parameters,
119     const PluginDomainAccountInfo *domainAccountInfo, const int32_t callerLocalId);
120 
121 enum PluginMethodEnum {
122     ADD_SERVER_CONFIG = 0,
123     REMOVE_SERVER_CONFIG,
124     UPDATE_SERVER_CONFIG,
125     GET_SERVER_CONFIG,
126     GET_ALL_SERVER_CONFIGS,
127     GET_ACCOUNT_SERVER_CONFIG,
128     AUTH,
129     AUTH_WITH_POPUP,
130     AUTH_WITH_TOKEN,
131     GET_ACCOUNT_INFO,
132     GET_AUTH_STATUS_INFO,
133     BIND_ACCOUNT,
134     UNBIND_ACCOUNT,
135     IS_ACCOUNT_TOKEN_VALID,
136     GET_ACCESS_TOKEN,
137     UPDATE_ACCOUNT_INFO,
138     IS_AUTHENTICATION_EXPIRED,
139     SET_ACCOUNT_POLICY,
140     GET_ACCOUNT_POLICY,
141     //this is last just for count enum
142     COUNT,
143 };
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_LIB_H