@@ -0,0 +1,3374 @@
+/*%0A * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0%0A * (the %22License%22). You may not use this work except in compliance with the License, which is%0A * available at www.apache.org/licenses/LICENSE-2.0%0A *%0A * This software is distributed on an %22AS IS%22 basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,%0A * either express or implied, as more fully set forth in the License.%0A *%0A * See the NOTICE file distributed with this work for information regarding copyright ownership.%0A */%0A%0Apackage alluxio.cli.validation;%0A%0Aimport alluxio.PropertyKey;%0A%0Aimport org.apache.hadoop.conf.Configuration;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0Aimport java.io.IOException;%0A%0A/**%0A * Task for validating security configurations.%0A */%0Apublic class SecurityValidationTask implements ValidationTask %7B%0A    private static final String ALLUXIO_BIN = %22./bin/alluxio%22;%0A    private static final String GETCONF_CMD = %22getConf%22;%0A%0A    public SecurityValidationTask()%7B%0A    %7D%0A    @Override%0A    public boolean validate() %7B%0A        String authType = getOutputFromProcess(new String%5B%5D %7BALLUXIO_BIN, GETCONF_CMD,%0A            PropertyKey.SECURITY_AUTHENTICATION_TYPE.getName()%7D);%0A        String masterPrinc = getOutputFromProcess(new String%5B%5D %7BALLUXIO_BIN, GETCONF_CMD,%0A            PropertyKey.MASTER_PRINCIPAL.getName()%7D);%0A        String masterKeytab = getOutputFromProcess(new String%5B%5D %7BALLUXIO_BIN, GETCONF_CMD,%0A            PropertyKey.MASTER_KEYTAB_KEY_FILE.getName()%7D);%0A        String workerPrinc = getOutputFromProcess(new String%5B%5D %7BALLUXIO_BIN, GETCONF_CMD,%0A            PropertyKey.WORKER_PRINCIPAL.getName()%7D);%0A        String workerKeytab = getOutputFromProcess(new String%5B%5D %7BALLUXIO_BIN, GETCONF_CMD,%0A            PropertyKey.WORKER_KEYTAB_FILE.getName()%7D);%0A        if (authType.equals(%22KERBEROS%22)) %7B%0A            System.err.format(%22Alluxio does not support KERBEROS authentication.%25n%22);%0A            return false;%0A        %7D%0A        if (masterPrinc.isEmpty() && workerPrinc.isEmpty()) %7B%0A            System.out.println(%22Alluxio is not using Kerberos authentication%22%0A                + %22 because both master and worker principals are empty.%22);%0A            return true;%0A        %7D else if (masterPrinc.isEmpty() && !workerPrinc.isEmpty()%0A            %7C%7C !masterPrinc.isEmpty() && workerPrinc.isEmpty()) %7B%0A            System.err.format(%22Master principal is %25s, but worker principal is %25s.%25n%22,%0A                masterPrinc, workerPrinc);%0A            return false;%0A        %7D else %7B%0A            // Login with master principal%0A        %7D%0A        return true;%0A    %7D%0A%0A    private String getOutputFromProcess(String%5B%5D args) %7B%0A        try %7B%0A            Process process = Runtime.getRuntime().exec(args);%0A            try (BufferedReader processOutputReader = new BufferedReader(%0A                new InputStreamReader(process.getInputStream()))) %7B%0A                String line = processOutputReader.readLine();%0A                if (line==null) %7B%0A                    return %22%22;%0A                %7D%0A                return line.trim();%0A            %7D%0A        %7D catch (IOException e) %7B%0A            StringBuilder sb = new StringBuilder();%0A            for (String s : args) %7B%0A                sb.append(s);%0A                sb.append(%22 %22);%0A            %7D%0A            System.err.format(%22Unable to run command %25s.%25n%22, sb.toString().trim());%0A            return null;%0A        %7D%0A    %7D%0A%7D%0A

Add class for new validation task.