1 /* 2 * Copyright (c) 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 CONSTANT_H 17 #define CONSTANT_H 18 19 #include <algorithm> 20 #include <string> 21 22 namespace OHOS { 23 namespace Security { 24 namespace AccessToken { 25 class Constant { 26 public: 27 /** 28 * Indicates message format version, should be compatible. 29 */ 30 const static int32_t DISTRIBUTED_ACCESS_TOKEN_SERVICE_VERSION = 2; 31 32 /** 33 * Status code, indicates general success. 34 */ 35 const static int32_t SUCCESS = 0; 36 37 /** 38 * Status code, indicates general failure. 39 */ 40 const static int32_t FAILURE = -1; 41 42 /** 43 * Status code, indicates failure but can retry. 44 */ 45 const static int32_t FAILURE_BUT_CAN_RETRY = -2; 46 47 /** 48 * Status Code, indicates invalid command. 49 */ 50 const static int32_t INVALID_COMMAND = -14; 51 52 /** 53 * Session Id, indicates invalid session. 54 */ 55 const static int32_t INVALID_SESSION = -1; 56 57 /** 58 * Command status code, indicate a status of command before RPC call. 59 */ 60 const static int32_t STATUS_CODE_BEFORE_RPC = 100001; 61 62 /** 63 * Command result string, indicates success. 64 */ 65 static const std::string COMMAND_RESULT_SUCCESS; 66 67 /** 68 * Command result string, indicates failed. 69 */ 70 static const std::string COMMAND_RESULT_FAILED; 71 72 /** 73 * Device id length. 74 */ 75 const static int32_t DEVICE_UUID_LENGTH = 65; 76 77 /** 78 * Command status code, indicate a status of command before RPC call. 79 */ 80 const static int32_t DELAY_SYNC_TOKEN_MS = 3000; 81 82 static constexpr int32_t ENCRYPTLEN = 4; 83 static constexpr int32_t ENCRYPTBEGIN = 0; 84 static constexpr int32_t ENCRYPTEND = 3; 85 static std::string EncryptDevId(std::string deviceId); 86 87 /** 88 * GetLocalDeviceId 89 */ 90 static std::string GetLocalDeviceId(); 91 }; 92 } // namespace AccessToken 93 } // namespace Security 94 } // namespace OHOS 95 #endif // CONSTANT_H 96