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 typedef PluginBussnessError* (*UpdateAccountInfoFunc)(const PluginDomainAccountInfo *domainAccountInfo, 108 const PluginDomainAccountInfo *newDomainAccountInfo, const int32_t callerLocalId); 109 typedef PluginBussnessError* (*IsAccountTokenValidFunc)(const PluginDomainAccountInfo *domainAccountInfo, 110 const PluginUint8Vector *token, int32_t *isValid); 111 typedef PluginBussnessError* (*IsAuthenticationExpiredFunc)(const PluginDomainAccountInfo *domainAccountInfo, 112 const PluginUint8Vector *token, int32_t *isValid); 113 typedef PluginBussnessError* (*GetAccessTokenFunc)(const PluginGetDomainAccessTokenOptions *options, 114 PluginUint8Vector **accessToken); 115 typedef PluginBussnessError* (*GetAccountPolicyFunc)(const PluginDomainAccountInfo *domainAccountInfo, 116 const int32_t callerLocalId, PluginDomainAccountPolicy **domainAccountPolicy); 117 typedef PluginBussnessError* (*SetAccountPolicyFunc)(const PluginString *parameters, 118 const PluginDomainAccountInfo *domainAccountInfo, const int32_t callerLocalId); 119 120 enum PluginMethodEnum { 121 ADD_SERVER_CONFIG = 0, 122 REMOVE_SERVER_CONFIG, 123 UPDATE_SERVER_CONFIG, 124 GET_SERVER_CONFIG, 125 GET_ALL_SERVER_CONFIGS, 126 GET_ACCOUNT_SERVER_CONFIG, 127 AUTH, 128 AUTH_WITH_POPUP, 129 AUTH_WITH_TOKEN, 130 GET_ACCOUNT_INFO, 131 GET_AUTH_STATUS_INFO, 132 BIND_ACCOUNT, 133 UNBIND_ACCOUNT, 134 IS_ACCOUNT_TOKEN_VALID, 135 GET_ACCESS_TOKEN, 136 UPDATE_ACCOUNT_INFO, 137 IS_AUTHENTICATION_EXPIRED, 138 SET_ACCOUNT_POLICY, 139 GET_ACCOUNT_POLICY, 140 //this is last just for count enum 141 COUNT, 142 }; 143 144 #ifdef __cplusplus 145 } 146 #endif 147 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_LIB_H