use of javax.net.ssl.SSLException in project geode by apache.
the class LauncherLifecycleCommands method doAutoConnect.
private boolean doAutoConnect(final String locatorHostname, final int locatorPort, final String gemfirePropertiesPathname, final String gemfireSecurityPropertiesPathname, final InfoResultData infoResultData) {
boolean connectSuccess = false;
boolean jmxManagerAuthEnabled = false;
boolean jmxManagerSslEnabled = false;
Map<String, String> configurationProperties = loadConfigurationProperties(gemfireSecurityPropertiesPathname, loadConfigurationProperties(gemfirePropertiesPathname));
Map<String, String> locatorConfigurationProperties = new HashMap<>(configurationProperties);
String responseFailureMessage = null;
for (int attempts = 0; (attempts < 10 && !connectSuccess); attempts++) {
try {
ConnectToLocatorResult connectToLocatorResult = ShellCommands.connectToLocator(locatorHostname, locatorPort, ShellCommands.getConnectLocatorTimeoutInMS() / 4, locatorConfigurationProperties);
ConnectionEndpoint memberEndpoint = connectToLocatorResult.getMemberEndpoint();
jmxManagerSslEnabled = connectToLocatorResult.isJmxManagerSslEnabled();
if (!jmxManagerSslEnabled) {
configurationProperties.clear();
}
getGfsh().setOperationInvoker(new JmxOperationInvoker(memberEndpoint.getHost(), memberEndpoint.getPort(), null, null, configurationProperties, null));
String shellAndLogMessage = CliStrings.format(CliStrings.CONNECT__MSG__SUCCESS, "JMX Manager " + memberEndpoint.toString(false));
infoResultData.addLine("\n");
infoResultData.addLine(shellAndLogMessage);
getGfsh().logToFile(shellAndLogMessage, null);
connectSuccess = true;
responseFailureMessage = null;
} catch (IllegalStateException unexpected) {
if (CauseFinder.indexOfCause(unexpected, ClassCastException.class, false) != -1) {
responseFailureMessage = "The Locator might require SSL Configuration.";
}
} catch (SecurityException ignore) {
getGfsh().logToFile(ignore.getMessage(), ignore);
jmxManagerAuthEnabled = true;
// no need to continue after SecurityException
break;
} catch (AuthenticationFailedException ignore) {
getGfsh().logToFile(ignore.getMessage(), ignore);
jmxManagerAuthEnabled = true;
// no need to continue after AuthenticationFailedException
break;
} catch (SSLException ignore) {
if (ignore instanceof SSLHandshakeException) {
// try to connect again without SSL since the SSL handshake failed implying a plain text
// connection...
locatorConfigurationProperties.clear();
} else {
// another type of SSL error occurred (possibly a configuration issue); pass the buck...
getGfsh().logToFile(ignore.getMessage(), ignore);
responseFailureMessage = "Check your SSL configuration and try again.";
break;
}
} catch (Exception ignore) {
getGfsh().logToFile(ignore.getMessage(), ignore);
responseFailureMessage = "Failed to connect; unknown cause: " + ignore.getMessage();
}
}
if (!connectSuccess) {
doOnConnectionFailure(locatorHostname, locatorPort, jmxManagerAuthEnabled, jmxManagerSslEnabled, infoResultData);
}
if (StringUtils.isNotBlank(responseFailureMessage)) {
infoResultData.addLine("\n");
infoResultData.addLine(responseFailureMessage);
}
return connectSuccess;
}
use of javax.net.ssl.SSLException in project robovm by robovm.
the class SSLEngineTest method test_unwrap_ByteBuffer$ByteBuffer_01.
/**
* javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts)
* SSLException should be thrown.
*/
public void test_unwrap_ByteBuffer$ByteBuffer_01() throws IOException, InterruptedException {
prepareEngines();
doHandshake();
ByteBuffer bbs = ByteBuffer.allocate(100);
ByteBuffer bbd = ByteBuffer.allocate(100);
try {
clientEngine.engine.unwrap(bbs, new ByteBuffer[] { bbd });
fail("SSLException wasn't thrown");
} catch (SSLException ex) {
//expected
}
}
use of javax.net.ssl.SSLException in project robovm by robovm.
the class SSLEngineTest method test_wrap_ByteBuffer$ByteBuffer_01.
/**
* @throws IOException
* @throws InterruptedException
* javax.net.ssl.SSLEngine#wrap(ByteBuffer[] srcs, ByteBuffer dst)
* SSLException should be thrown.
*/
public void test_wrap_ByteBuffer$ByteBuffer_01() throws IOException, InterruptedException {
prepareEngines();
doHandshake();
ByteBuffer bbs = ByteBuffer.allocate(100);
ByteBuffer bbd = ByteBuffer.allocate(20000);
try {
clientEngine.engine.wrap(new ByteBuffer[] { bbs }, bbd);
serverEngine.engine.wrap(new ByteBuffer[] { bbs }, bbd);
//fail("SSLException wasn't thrown");
} catch (SSLException ex) {
//expected
}
}
use of javax.net.ssl.SSLException in project robovm by robovm.
the class SSLEngineTest method test_unwrap_ByteBuffer_ByteBuffer_01.
/**
* javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer dst)
* SSLException should be thrown.
*/
public void test_unwrap_ByteBuffer_ByteBuffer_01() throws InterruptedException, IOException {
prepareEngines();
doHandshake();
ByteBuffer bbs = ByteBuffer.allocate(100);
ByteBuffer bbd = ByteBuffer.allocate(100);
try {
SSLEngineResult unwrap = clientEngine.engine.unwrap(bbs, bbd);
fail("SSLException wasn't thrown");
} catch (SSLException ex) {
//expected
}
}
use of javax.net.ssl.SSLException in project robovm by robovm.
the class SSLExceptionTest method testSSLException06.
/**
* Test for <code>SSLException(String, Throwable)</code> constructor
* Assertion: constructs SSLException when <code>cause</code> is null
* <code>msg</code> is not null
*/
public void testSSLException06() {
SSLException sE;
for (int i = 0; i < msgs.length; i++) {
sE = new SSLException(msgs[i], null);
assertEquals("getMessage() must return: ".concat(msgs[i]), sE.getMessage(), msgs[i]);
assertNull("getCause() must return null", sE.getCause());
}
}
Aggregations