1 /* 2 * Copyright (c) 2021 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 PARAM_CHECK_UTILS_H 17 #define PARAM_CHECK_UTILS_H 18 19 #include <string> 20 21 #include "db_types.h" 22 #include "auto_launch_export.h" 23 #include "schema_object.h" 24 25 namespace DistributedDB { 26 class ParamCheckUtils final { 27 public: 28 29 static bool CheckDataDir(const std::string &dir, std::string &canonicalDir); 30 31 // Check if the storeID is a safe arg. 32 static bool IsStoreIdSafe(const std::string &storeId); 33 34 // check appId, userId, storeId. 35 static bool CheckStoreParameter(const std::string &storeId, const std::string &appId, const std::string &userId, 36 bool isIgnoreUserIdCheck = false); 37 38 // check encrypted args for KvStore. 39 static bool CheckEncryptedParameter(CipherType cipher, const CipherPassword &passwd); 40 41 static bool CheckConflictNotifierType(int conflictType); 42 43 static bool CheckSecOption(const SecurityOption &secOption); 44 45 static bool CheckObserver(const Key &key, unsigned int mode); 46 47 static bool IsS3SECEOpt(const SecurityOption &secOpt); 48 49 static int CheckAndTransferAutoLaunchParam(const AutoLaunchParam ¶m, bool checkDir, 50 SchemaObject &schemaObject, std::string &canonicalDir); 51 52 static uint8_t GetValidCompressionRate(uint8_t compressionRate); 53 54 static bool CheckRelationalTableName(const std::string &tableName); 55 }; 56 } // namespace DistributedDB 57 58 #endif // DISTRIBUTEDDB_PARAM_CHECK_UTILS_H 59