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 int (*createTask)(int32_t *, const CJson *in, CJson *out); 29 int (*processTask)(int32_t, const CJson *in, CJson *out, int32_t *status); 30 void (*destroyTask)(int); 31 void (*destroyModule)(struct AuthModuleBaseT *module); 32 } AuthModuleBase; 33 34 typedef struct { 35 const char *pkgName; 36 const char *serviceType; 37 Uint8Buff *authId; 38 int userType; 39 } AuthModuleParams; 40 41 int32_t InitModules(void); 42 void DestroyModules(void); 43 44 int32_t CreateTask(int32_t *taskId, const CJson *in, CJson *out, int moduleType); 45 int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int32_t *status, int moduleType); 46 void DestroyTask(int taskId, int moduleType); 47 int32_t CheckMsgRepeatability(const CJson *in, int moduleType); 48 49 // for DAS 50 int32_t RegisterLocalIdentity(const char *pkgName, const char *serviceType, Uint8Buff *authId, int userType, 51 int moduleType); 52 int32_t UnregisterLocalIdentity(const char *pkgName, const char *serviceType, Uint8Buff *authId, int userType, 53 int moduleType); 54 int32_t DeletePeerAuthInfo(const char *pkgName, const char *serviceType, Uint8Buff *authId, int userType, 55 int moduleType); 56 int32_t GetPublicKey(int moduleType, AuthModuleParams *params, Uint8Buff *returnPk); 57 58 // for ACCOUNT 59 int32_t GetRegisterInfo(const char *reqJsonStr, char **returnRegisterInfo); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 #endif 65