use of org.teiid.net.CommunicationException in project teiid by teiid.
the class TestCommSockets method testAnonSSLConnect.
@Test
public void testAnonSSLConnect() throws Exception {
SSLContext context = SSLContext.getDefault();
String[] ciphers = context.getServerSocketFactory().getSupportedCipherSuites();
if (!Arrays.asList(ciphers).contains(SocketUtil.ANON_CIPHER_SUITE)) {
// Cannot test anon if no cipher suite is available
return;
}
SSLConfiguration config = new SSLConfiguration();
config.setMode(SSLConfiguration.ENABLED);
// ensure that this cipher suite is not used
config.setEnabledCipherSuites("x");
config.setAuthenticationMode(SSLConfiguration.ANONYMOUS);
Properties p = new Properties();
helpEstablishConnection(true, config, p);
SocketServerConnection conn = helpEstablishConnection(true, config, p);
conn.close();
try {
helpEstablishConnection(false, config, p);
fail();
} catch (CommunicationException e) {
}
}
use of org.teiid.net.CommunicationException in project teiid by teiid.
the class TestCommSockets method testSSLConnectWithNonSSLServer.
@Test
public void testSSLConnectWithNonSSLServer() throws Exception {
// first make a non-ssl connection to ensure that it's not reused
SocketServerConnection conn = helpEstablishConnection(false);
conn.close();
try {
helpEstablishConnection(true);
// $NON-NLS-1$
fail("exception expected");
} catch (CommunicationException e) {
}
}
use of org.teiid.net.CommunicationException in project teiid by teiid.
the class SocketClientInstance method receivedHahdshake.
private void receivedHahdshake(Handshake handshake) throws CommunicationException {
String clientVersion = handshake.getVersion();
this.workContext.setClientVersion(Version.getVersion(clientVersion));
if (usingEncryption) {
byte[] returnedPublicKey = handshake.getPublicKey();
byte[] returnedPublicKeyLarge = handshake.getPublicKeyLarge();
boolean large = false;
// ensure the key information
if (returnedPublicKey == null) {
if (returnedPublicKeyLarge == null) {
throw new CommunicationException(RuntimePlugin.Event.TEIID40052, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40052));
}
large = true;
returnedPublicKey = returnedPublicKeyLarge;
}
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL)) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
LogManager.logDetail(LogConstants.CTX_TRANSPORT, large ? "2048" : "1024", "key exchange being used.");
}
boolean useCbc = handshake.isCbc();
try {
// $NON-NLS-1$
this.cryptor = keyGen.getSymmetricCryptor(returnedPublicKey, "08.03".compareTo(clientVersion) > 0, SocketClientInstance.class.getClassLoader(), large, useCbc);
} catch (CryptoException e) {
throw new CommunicationException(RuntimePlugin.Event.TEIID40053, e);
}
this.keyGen = null;
} else {
this.cryptor = new NullCryptor();
}
}
use of org.teiid.net.CommunicationException in project teiid by teiid.
the class SocketClientInstance method onConnection.
public void onConnection() throws CommunicationException {
Handshake handshake = new Handshake();
handshake.setAuthType(csr.getAuthenticationType());
if (usingEncryption) {
keyGen = new DhKeyGenerator();
byte[] publicKey;
try {
handshake.setPublicKeyLarge(keyGen.createPublicKey(true));
} catch (CryptoException e) {
// not supported on this platform
}
try {
publicKey = keyGen.createPublicKey(false);
} catch (CryptoException e) {
throw new CommunicationException(RuntimePlugin.Event.TEIID40051, e);
}
handshake.setPublicKey(publicKey);
}
this.objectSocket.write(handshake);
}
use of org.teiid.net.CommunicationException in project teiid by teiid.
the class TestJDBCSocketTransport method testSyncTimeout.
/**
* Tests to ensure that a SynchronousTtl/synchTimeout does
* not cause a cancel.
* TODO: had to increase the values since the test would fail on slow machine runs
* @throws Exception
*/
@Test
public void testSyncTimeout() throws Exception {
TeiidDriver td = new TeiidDriver();
td.setSocketProfile(new ConnectionProfile() {
@Override
public ConnectionImpl connect(String url, Properties info) throws TeiidSQLException {
SocketServerConnectionFactory sscf = new SocketServerConnectionFactory();
sscf.initialize(info);
try {
return new ConnectionImpl(sscf.getConnection(info), info, url);
} catch (CommunicationException e) {
throw TeiidSQLException.create(e);
} catch (ConnectionException e) {
throw TeiidSQLException.create(e);
}
}
});
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
ConnectorManagerRepository cmr = server.getConnectorManagerRepository();
AutoGenDataService agds = new AutoGenDataService() {
@Override
public Object getConnectionFactory() throws TranslatorException {
return null;
}
};
// wait longer than the synch ttl/soTimeout, we should still succeed
agds.setSleep(2000);
cmr.addConnectorManager("source", agds);
try {
conn = td.connect("jdbc:teiid:parts@mm://" + addr.getHostName() + ":" + jdbcTransport.getPort(), p);
Statement s = conn.createStatement();
assertTrue(s.execute("select * from parts"));
} finally {
server.setConnectorManagerRepository(cmr);
}
}
Aggregations