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, bool allowStoreIdWithDot = false); 33 34 // check appId, userId, storeId, subUser. 35 static bool CheckStoreParameter(const std::string &storeId, const std::string &appId, const std::string &userId, 36 bool isIgnoreUserIdCheck = false, const std::string &subUser = ""); 37 38 static bool CheckStoreParameter(const StoreInfo &info, bool isIgnoreUserIdCheck = false, 39 const std::string &subUser = "", bool allowStoreIdWithDot = false); 40 41 // check encrypted args for KvStore. 42 static bool CheckEncryptedParameter(CipherType cipher, const CipherPassword &passwd); 43 44 static bool CheckConflictNotifierType(int conflictType); 45 46 static bool CheckSecOption(const SecurityOption &secOption); 47 48 static bool CheckObserver(const Key &key, unsigned int mode); 49 50 static bool IsS3SECEOpt(const SecurityOption &secOpt); 51 52 static int CheckAndTransferAutoLaunchParam(const AutoLaunchParam ¶m, bool checkDir, 53 SchemaObject &schemaObject, std::string &canonicalDir); 54 55 static uint8_t GetValidCompressionRate(uint8_t compressionRate); 56 57 static bool CheckRelationalTableName(const std::string &tableName); 58 59 static bool CheckTableReference(const std::vector<TableReferenceProperty> &tableReferenceProperty); 60 61 static bool CheckSharedTableName(const DataBaseSchema &schema); 62 63 static void TransferSchemaToLower(DataBaseSchema &schema); 64 }; 65 } // namespace DistributedDB 66 #endif // PARAM_CHECK_UTILS_H 67