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 const char *pkgName; 38 const char *serviceType; 39 Uint8Buff *authId; 40 int userType; 41 } AuthModuleParams; 42 43 int32_t InitModules(void); 44 void DestroyModules(void); 45 46 int32_t AddAuthModulePlugin(const AuthModuleBase *plugin); 47 void DelAuthModulePlugin(int32_t moduleType); 48 49 int32_t CreateTask(int32_t *taskId, const CJson *in, CJson *out, int moduleType); 50 int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int32_t *status, int moduleType); 51 void DestroyTask(int taskId, int moduleType); 52 int32_t CheckMsgRepeatability(const CJson *in, int moduleType); 53 54 // for DAS 55 int32_t RegisterLocalIdentity(const char *pkgName, const char *serviceType, Uint8Buff *authId, int userType, 56 int moduleType); 57 int32_t UnregisterLocalIdentity(const char *pkgName, const char *serviceType, Uint8Buff *authId, int userType, 58 int moduleType); 59 int32_t DeletePeerAuthInfo(const char *pkgName, const char *serviceType, Uint8Buff *authId, int userType, 60 int moduleType); 61 int32_t GetPublicKey(int moduleType, AuthModuleParams *params, Uint8Buff *returnPk); 62 63 #ifdef __cplusplus 64 } 65 #endif 66 #endif 67