1 /* 2 * Copyright (C) 2021-2022 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 DEV_AUTH_MODULE_MANAGER_H 17 #define DEV_AUTH_MODULE_MANAGER_H 18 19 #include "json_utils.h" 20 #include "string_util.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 typedef struct AuthModuleBaseT { 27 int moduleType; 28 int32_t (*init)(void); 29 void (*destroy)(void); 30 bool (*isMsgNeedIgnore)(const CJson *in); 31 int (*createTask)(int32_t *, const CJson *in, CJson *out); 32 int (*processTask)(int32_t, const CJson *in, CJson *out, int32_t *status); 33 void (*destroyTask)(int); 34 } AuthModuleBase; 35 36 typedef struct { 37 int32_t osAccountId; 38 const char *pkgName; 39 const char *serviceType; 40 Uint8Buff *authId; 41 int userType; 42 } AuthModuleParams; 43 44 int32_t InitModules(void); 45 void DestroyModules(void); 46 47 int32_t AddAuthModulePlugin(const AuthModuleBase *plugin); 48 void DelAuthModulePlugin(int32_t moduleType); 49 50 int32_t CreateTask(int32_t *taskId, const CJson *in, CJson *out, int moduleType); 51 int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int32_t *status, int moduleType); 52 void DestroyTask(int taskId, int moduleType); 53 int32_t CheckMsgRepeatability(const CJson *in, int moduleType); 54 55 // for DAS 56 int32_t RegisterLocalIdentity(const AuthModuleParams *moduleParams, int moduleType); 57 int32_t UnregisterLocalIdentity(const AuthModuleParams *moduleParams, int moduleType); 58 int32_t DeletePeerAuthInfo(const AuthModuleParams *moduleParams, int moduleType); 59 int32_t GetPublicKey(int moduleType, AuthModuleParams *moduleParams, Uint8Buff *returnPk); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 #endif 65