• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DATA_VALIDATOR_H
17 #define DATA_VALIDATOR_H
18 
19 #include <string>
20 #include "access_token.h"
21 
22 namespace OHOS {
23 namespace Security {
24 namespace AccessToken {
25 class DataValidator final {
26 public:
27     static bool IsBundleNameValid(const std::string& bundleName);
28 
29     static bool IsPermissionNameValid(const std::string& permissionName);
30 
31     static bool IsUserIdValid(const int userId);
32 
33     static bool IsAppIDDescValid(const std::string& appIDDesc);
34 
35     static bool IsDomainValid(const std::string& domain);
36 
37     static bool IsAplNumValid(const int apl);
38 
39     static bool IsProcessNameValid(const std::string& processName);
40 
41     static bool IsDeviceIdValid(const std::string& deviceId);
42 
43     static bool IsLabelValid(const std::string& label);
44 
45     static bool IsDescValid(const std::string& desc);
46     static bool IsPermissionFlagValid(int flag);
47     static bool IsDcapValid(const std::string& dcap);
48     static bool IsTokenIDValid(AccessTokenID id);
49 
50 private:
51     const static int MAX_LENGTH = 256;
52     const static int MAX_APPIDDESC_LENGTH = 10240;
53     const static int MAX_DCAP_LENGTH = 1024;
54 };
55 } // namespace AccessToken
56 } // namespace Security
57 } // namespace OHOS
58 #endif // DATA_VALIDATOR_H
59