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 ACCESSTOKENMANAGER_COMMAND_H 17 #define ACCESSTOKENMANAGER_COMMAND_H 18 19 #include "shell_command.h" 20 21 namespace OHOS { 22 namespace Security { 23 namespace AccessToken { 24 typedef enum TypeOptType { 25 DEFAULT = 0, 26 DUMP_TOKEN, 27 DUMP_RECORD, 28 PERM_GRANT, 29 PERM_REVOKE, 30 } OptType; 31 32 class AtmCommand : public OHOS::AAFwk::ShellCommand { 33 public: 34 AtmCommand(int argc, char *argv[]); ~AtmCommand()35 ~AtmCommand() override 36 {} 37 38 private: 39 ErrCode CreateCommandMap() override; 40 ErrCode CreateMessageMap() override; 41 ErrCode init() override; 42 43 ErrCode RunAsHelpCommand(); 44 ErrCode RunAsDumpCommand(); 45 ErrCode RunAsPermCommand(); 46 47 ErrCode RunAsCommandError(void); 48 ErrCode RunAsCommandExistentOptionArgument(const int& option, 49 OptType& type, uint32_t& tokenId, std::string& permissionName); 50 ErrCode RunCommandByOperationType(const OptType& type, 51 uint32_t& tokenId, std::string& permissionName); 52 53 ErrCode RunAsCommandMissingOptionArgument(void); 54 ErrCode ModifyPermission(const OptType& type, uint32_t& tokenId, std::string& permissionName); 55 56 std::string DumpRecordInfo(uint32_t tokenId, const std::string& permissionName); 57 }; 58 } // namespace AccessToken 59 } // namespace Security 60 } // namespace OHOS 61 62 #endif // ACCESSTOKENMANAGER_COMMAND_H 63