in src/main/java/co/elastic/support/rest/ElasticRestClientInputs.java [139:228]
protected void runHttpInteractive(TextIOManager textIOManager){
if(runningInDocker){
host = textIOManager.textIO.newStringInputReader()
.withMinLength(1)
.withIgnoreCase()
.withInputTrimming(true)
.withValueChecker((String val, String propname) -> validateHost(val))
.read(SystemProperties.lineSeparator + hostDescription);
}
else {
host = textIOManager.textIO.newStringInputReader()
.withDefaultValue(host)
.withIgnoreCase()
.withInputTrimming(true)
.withValueChecker((String val, String propname) -> validateHost(val))
.read(SystemProperties.lineSeparator + hostDescription);
}
port = textIOManager.textIO.newIntInputReader()
.withDefaultValue(port)
.withValueChecker((Integer val, String propname) -> validatePort(val))
.read(SystemProperties.lineSeparator + "Listening port. Defaults to " + port + ":");
isSsl = textIOManager.textIO.newBooleanInputReader()
.withDefaultValue(true)
.read(SystemProperties.lineSeparator + sslDescription);
if(isSsl){
skipVerification = textIOManager.textIO.newBooleanInputReader()
.withDefaultValue(skipVerification)
.read(SystemProperties.lineSeparator + skipHostnameVerificationDescription);
}
else {
scheme = "http";
}
boolean isSecured = textIOManager.textIO.newBooleanInputReader()
.withDefaultValue(true)
.read(SystemProperties.lineSeparator + "Cluster secured?");
if(isSecured){
String authType = textIOManager.textIO.newStringInputReader()
.withNumberedPossibleValues(userLoginAuth, pkiLoginAuth)
.withDefaultValue(userLoginAuth)
.read(SystemProperties.lineSeparator + "Type of authentication to use:");
// SSL needs to be in place for PKI
if(authType.equals(pkiLoginAuth) && !isSsl){
textIOManager.textIO.getTextTerminal().println("TLS must be enabled to use PKI - defaulting to user/password authentication.");
authType = userLoginAuth;
}
if(authType.equals(userLoginAuth)){
user = textIOManager.standardStringReader
.read(SystemProperties.lineSeparator + userDescription);
password = textIOManager.standardPasswordReader
.read(SystemProperties.lineSeparator + passwordDescription);
}
else{
pkiKeystore = textIOManager.standardFileReader
.read(SystemProperties.lineSeparator + pkiKeystoreDescription);
pkiKeystorePass = textIOManager.standardPasswordReader
.read(SystemProperties.lineSeparator + pkiKeystorePasswordDescription);
}
}
boolean httpProxy = textIOManager.standardBooleanReader
.withDefaultValue(false)
.read(SystemProperties.lineSeparator + "Http Proxy Server present?");
if(httpProxy){
proxyHost = textIOManager.textIO.newStringInputReader()
.withIgnoreCase()
.withInputTrimming(true)
.withValueChecker((String val, String propname) -> validateProxyHost(val))
.read(SystemProperties.lineSeparator + proxyHostDescription);
proxyPort = textIOManager.textIO.newIntInputReader()
.withDefaultValue(proxyPort)
.withValueChecker((Integer val, String propname) -> validatePort(val))
.read(SystemProperties.lineSeparator + proxyPortDescription);
proxyPassword = textIOManager.standardPasswordReader
.read(SystemProperties.lineSeparator + proxyPasswordDescription);
}
}