@Override
    public void execute(CommandLine commandLine, Options options,
        RPCHook rpcHook) throws SubCommandException {

        DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
        defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

        try {
            PlainAccessConfig accessConfig = new PlainAccessConfig();
            accessConfig.setAccessKey(commandLine.getOptionValue('a').trim());
            // Secretkey
            if (commandLine.hasOption('s')) {
                accessConfig.setSecretKey(commandLine.getOptionValue('s').trim());
            }

            // Admin
            if (commandLine.hasOption('m')) {
                accessConfig.setAdmin(Boolean.parseBoolean(commandLine.getOptionValue('m').trim()));
            }

            // DefaultTopicPerm
            if (commandLine.hasOption('i')) {
                accessConfig.setDefaultTopicPerm(commandLine.getOptionValue('i').trim());
            }

            // DefaultGroupPerm
            if (commandLine.hasOption('u')) {
                accessConfig.setDefaultGroupPerm(commandLine.getOptionValue('u').trim());
            }

            // WhiteRemoteAddress
            if (commandLine.hasOption('w')) {
                accessConfig.setWhiteRemoteAddress(commandLine.getOptionValue('w').trim());
            }

            // TopicPerms list value
            if (commandLine.hasOption('t')) {
                String[] topicPerms = commandLine.getOptionValue('t').trim().split(",");
                List<String> topicPermList = new ArrayList<>();
                if (topicPerms != null) {
                    for (String topicPerm : topicPerms) {
                        topicPermList.add(topicPerm);
                    }
                }
                accessConfig.setTopicPerms(topicPermList);
            }

            // GroupPerms list value
            if (commandLine.hasOption('g')) {
                String[] groupPerms = commandLine.getOptionValue('g').trim().split(",");
                List<String> groupPermList = new ArrayList<>();
                if (groupPerms != null) {
                    for (String groupPerm : groupPerms) {
                        groupPermList.add(groupPerm);
                    }
                }
                accessConfig.setGroupPerms(groupPermList);
            }

            if (commandLine.hasOption('b')) {
                String addr = commandLine.getOptionValue('b').trim();

                defaultMQAdminExt.start();
                defaultMQAdminExt.createAndUpdatePlainAccessConfig(addr, accessConfig);

                System.out.printf("create or update plain access config to %s success.%n", addr);
                System.out.printf("%s", accessConfig);
                return;

            } else if (commandLine.hasOption('c')) {
                String clusterName = commandLine.getOptionValue('c').trim();

                defaultMQAdminExt.start();
                Set<String> brokerAddrSet =
                    CommandUtil.fetchMasterAndSlaveAddrByClusterName(defaultMQAdminExt, clusterName);
                for (String addr : brokerAddrSet) {
                    defaultMQAdminExt.createAndUpdatePlainAccessConfig(addr, accessConfig);
                    System.out.printf("create or update plain access config to %s success.%n", addr);
                }

                System.out.printf("%s", accessConfig);
                return;
            }

            ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options);
        } catch (Exception e) {
            throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
        } finally {
            defaultMQAdminExt.shutdown();
        }
    }
@Test
    public void testExecute() {
        UpdateAccessConfigSubCommand cmd = new UpdateAccessConfigSubCommand();
        Options options = ServerUtil.buildCommandlineOptions(new Options());
        String[] subargs = new String[] {
            "-b","127.0.0.1:10911",
            "-a","RocketMQ",
            "-s","12345678",
            "-w","192.168.0.*",
            "-i","DENY",
            "-u","SUB",
            "-t","topicA=DENY;topicB=PUB|SUB",
            "-g","groupA=DENY;groupB=SUB",
            "-m","true"
        };
        // Note: Posix parser is capable of handling values that contains '='.
        final CommandLine commandLine =
            ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs,
                cmd.buildCommandlineOptions(options), new DefaultParser());
        assertThat(commandLine.getOptionValue('b').trim()).isEqualTo("127.0.0.1:10911");
        assertThat(commandLine.getOptionValue('a').trim()).isEqualTo("RocketMQ");
        assertThat(commandLine.getOptionValue('s').trim()).isEqualTo("12345678");
        assertThat(commandLine.getOptionValue('w').trim()).isEqualTo("192.168.0.*");
        assertThat(commandLine.getOptionValue('i').trim()).isEqualTo("DENY");
        assertThat(commandLine.getOptionValue('u').trim()).isEqualTo("SUB");
        assertThat(commandLine.getOptionValue('t').trim()).isEqualTo("topicA=DENY;topicB=PUB|SUB");
        assertThat(commandLine.getOptionValue('g').trim()).isEqualTo("groupA=DENY;groupB=SUB");
        assertThat(commandLine.getOptionValue('m').trim()).isEqualTo("true");

        PlainAccessConfig accessConfig = new PlainAccessConfig();

        // topicPerms list value
        if (commandLine.hasOption('t')) {
            String[] topicPerms = commandLine.getOptionValue('t').trim().split(";");
            List<String> topicPermList = new ArrayList<>(Arrays.asList(topicPerms));
            accessConfig.setTopicPerms(topicPermList);
        }

        // groupPerms list value
        if (commandLine.hasOption('g')) {
            String[] groupPerms = commandLine.getOptionValue('g').trim().split(";");
            List<String> groupPermList = new ArrayList<>();
            Collections.addAll(groupPermList, groupPerms);
            accessConfig.setGroupPerms(groupPermList);
        }

        Assert.assertTrue(accessConfig.getTopicPerms().contains("topicB=PUB|SUB"));
        Assert.assertTrue(accessConfig.getGroupPerms().contains("groupB=SUB"));

    }