use of joptsimple.ArgumentAcceptingOptionSpec in project ambry by linkedin.
the class ToolUtils method validateSSLOptions.
public static void validateSSLOptions(OptionSet options, OptionParser parser, ArgumentAcceptingOptionSpec<String> sslEnabledDatacentersOpt, ArgumentAcceptingOptionSpec<String> sslKeystorePathOpt, ArgumentAcceptingOptionSpec<String> sslKeystoreTypeOpt, ArgumentAcceptingOptionSpec<String> sslTruststorePathOpt, ArgumentAcceptingOptionSpec<String> sslKeystorePasswordOpt, ArgumentAcceptingOptionSpec<String> sslKeyPasswordOpt, ArgumentAcceptingOptionSpec<String> sslTruststorePasswordOpt) throws Exception {
String sslEnabledDatacenters = options.valueOf(sslEnabledDatacentersOpt);
if (sslEnabledDatacenters.length() != 0) {
ArrayList<OptionSpec<?>> listOpt = new ArrayList<OptionSpec<?>>();
listOpt.add(sslKeystorePathOpt);
listOpt.add(sslKeystoreTypeOpt);
listOpt.add(sslKeystorePasswordOpt);
listOpt.add(sslKeyPasswordOpt);
listOpt.add(sslTruststorePathOpt);
listOpt.add(sslTruststorePasswordOpt);
for (OptionSpec opt : listOpt) {
if (!options.has(opt)) {
System.err.println("If sslEnabledDatacenters is not empty, missing required argument \"" + opt + "\"");
parser.printHelpOn(System.err);
throw new Exception("Lack of SSL arguments " + opt);
}
}
}
}
Aggregations