broker/ServerIntegrationSSLClientAuthTest: code formatter used

This commit is contained in:
Andreas Mager
2017-02-01 17:13:42 +01:00
parent 4f810fc7fd
commit 667505b13a
@@ -13,10 +13,10 @@
* *
* You may elect to redistribute this code under either of these licenses. * You may elect to redistribute this code under either of these licenses.
*/ */
package io.moquette.server; package io.moquette.server;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -27,13 +27,11 @@ import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException; import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.util.Properties; import java.util.Properties;
import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import io.moquette.BrokerConstants; import io.moquette.BrokerConstants;
import org.eclipse.paho.client.mqttv3.IMqttClient; import org.eclipse.paho.client.mqttv3.IMqttClient;
import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttClient;
@@ -53,6 +51,7 @@ import org.slf4j.LoggerFactory;
* *
* <p> * <p>
* Create certificates needed for client authentication * Create certificates needed for client authentication
*
* <pre> * <pre>
* # generate server certificate chain (valid for 10000 days) * # generate server certificate chain (valid for 10000 days)
* keytool -genkeypair -alias signedtestserver -dname cn=moquette.eclipse.org -keyalg RSA -keysize 2048 -keystore signedserverkeystore.jks -keypass passw0rdsrv -storepass passw0rdsrv -validity 10000 * keytool -genkeypair -alias signedtestserver -dname cn=moquette.eclipse.org -keyalg RSA -keysize 2048 -keystore signedserverkeystore.jks -keypass passw0rdsrv -storepass passw0rdsrv -validity 10000
@@ -87,9 +86,11 @@ import org.slf4j.LoggerFactory;
* keytool -importcert -trustcacerts -noprompt -alias signedtestserver_sub -keystore unsignedclientkeystore.jks -keypass passw0rd -storepass passw0rd * keytool -importcert -trustcacerts -noprompt -alias signedtestserver_sub -keystore unsignedclientkeystore.jks -keypass passw0rd -storepass passw0rd
* </pre> * </pre>
* </p> * </p>
*
* @author andrea / konradm * @author andrea / konradm
*/ */
public class ServerIntegrationSSLClientAuthTest { public class ServerIntegrationSSLClientAuthTest {
private static final Logger LOG = LoggerFactory.getLogger(ServerIntegrationSSLClientAuthTest.class); private static final Logger LOG = LoggerFactory.getLogger(ServerIntegrationSSLClientAuthTest.class);
Server m_server; Server m_server;
@@ -173,14 +174,14 @@ public class ServerIntegrationSSLClientAuthTest {
// actual a "Broken pipe" is thrown, this is not very specific. // actual a "Broken pipe" is thrown, this is not very specific.
try { try {
m_client.connect(options); m_client.connect(options);
}catch(MqttException e) } catch (MqttException e) {
{
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} }
} }
private SSLSocketFactory configureSSLSocketFactory(String keystore) throws KeyManagementException, NoSuchAlgorithmException, UnrecoverableKeyException, IOException, CertificateException, KeyStoreException { private SSLSocketFactory configureSSLSocketFactory(String keystore) throws KeyManagementException,
NoSuchAlgorithmException, UnrecoverableKeyException, IOException, CertificateException, KeyStoreException {
KeyStore ks = KeyStore.getInstance("JKS"); KeyStore ks = KeyStore.getInstance("JKS");
InputStream jksInputStream = getClass().getClassLoader().getResourceAsStream(keystore); InputStream jksInputStream = getClass().getClassLoader().getResourceAsStream(keystore);
ks.load(jksInputStream, "passw0rd".toCharArray()); ks.load(jksInputStream, "passw0rd".toCharArray());