Search in sources :

Example 1 with SSLConfiguration

use of org.teiid.transport.SSLConfiguration in project teiid by teiid.

the class TestJDBCSocketPerformance method oneTimeSetup.

@BeforeClass
public static void oneTimeSetup() throws Exception {
    SocketConfiguration config = new SocketConfiguration();
    config.setSSLConfiguration(new SSLConfiguration());
    addr = new InetSocketAddress(0);
    config.setBindAddress(addr.getHostName());
    config.setPortNumber(0);
    EmbeddedConfiguration dqpConfig = new EmbeddedConfiguration();
    dqpConfig.setMaxActivePlans(2);
    server = new FakeServer(false);
    server.start(dqpConfig);
    ModelMetaData mmd = new ModelMetaData();
    mmd.setName("x");
    mmd.setModelType(Type.PHYSICAL);
    mmd.addSourceMapping("x", "hc", null);
    mmd.setSchemaSourceType("ddl");
    StringBuffer ddl = new StringBuffer("create foreign table x (col0 string");
    for (int i = 1; i < 10; i++) {
        ddl.append(",").append(" col").append(i).append(" string");
    }
    ddl.append(");");
    mmd.setSchemaText(ddl.toString());
    server.addTranslator("hc", new HardCodedExecutionFactory() {

        @Override
        protected List<? extends List<?>> getData(QueryExpression command) {
            List<List<String>> result = new ArrayList<List<String>>();
            int size = command.getProjectedQuery().getDerivedColumns().size();
            for (int i = 0; i < 64; i++) {
                List<String> row = new ArrayList<String>(size);
                for (int j = 0; j < size; j++) {
                    row.add("abcdefghi" + j);
                }
                result.add(row);
            }
            return result;
        }
    });
    server.deployVDB("x", mmd);
    jdbcTransport = new SocketListener(addr, config, server.getClientServiceRegistry(), BufferManagerFactory.getStandaloneBufferManager());
}
Also used : FakeServer(org.teiid.jdbc.FakeServer) InetSocketAddress(java.net.InetSocketAddress) SocketConfiguration(org.teiid.transport.SocketConfiguration) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) SSLConfiguration(org.teiid.transport.SSLConfiguration) SocketListener(org.teiid.transport.SocketListener) HardCodedExecutionFactory(org.teiid.runtime.HardCodedExecutionFactory) ArrayList(java.util.ArrayList) List(java.util.List) QueryExpression(org.teiid.language.QueryExpression) BeforeClass(org.junit.BeforeClass)

Example 2 with SSLConfiguration

use of org.teiid.transport.SSLConfiguration in project teiid by teiid.

the class TransportAdd method buildSocketConfiguration.

private SocketConfiguration buildSocketConfiguration(final OperationContext context, ModelNode node) throws OperationFailedException {
    SocketConfiguration socket = new SocketConfiguration();
    if (isDefined(TRANSPORT_PROTOCOL_ATTRIBUTE, node, context)) {
        socket.setProtocol(asString(TRANSPORT_PROTOCOL_ATTRIBUTE, node, context));
    } else {
        // $NON-NLS-1$
        socket.setProtocol("teiid");
    }
    if (isDefined(TRANSPORT_MAX_SOCKET_THREADS_ATTRIBUTE, node, context)) {
        socket.setMaxSocketThreads(asInt(TRANSPORT_MAX_SOCKET_THREADS_ATTRIBUTE, node, context));
    }
    if (isDefined(TRANSPORT_IN_BUFFER_SIZE_ATTRIBUTE, node, context)) {
        socket.setInputBufferSize(asInt(TRANSPORT_IN_BUFFER_SIZE_ATTRIBUTE, node, context));
    }
    if (isDefined(TRANSPORT_OUT_BUFFER_SIZE_ATTRIBUTE, node, context)) {
        socket.setOutputBufferSize(asInt(TRANSPORT_OUT_BUFFER_SIZE_ATTRIBUTE, node, context));
    }
    SSLConfiguration ssl = new SSLConfiguration();
    if (isDefined(SSL_MODE_ATTRIBUTE, node, context)) {
        ssl.setMode(asString(SSL_MODE_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_SSL_PROTOCOL_ATTRIBUTE, node, context)) {
        ssl.setSslProtocol(asString(SSL_SSL_PROTOCOL_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_KEY_MANAGEMENT_ALG_ATTRIBUTE, node, context)) {
        ssl.setKeymanagementAlgorithm(asString(SSL_KEY_MANAGEMENT_ALG_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_AUTH_MODE_ATTRIBUTE, node, context)) {
        ssl.setAuthenticationMode(asString(SSL_AUTH_MODE_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_KETSTORE_NAME_ATTRIBUTE, node, context)) {
        ssl.setKeystoreFilename(asString(SSL_KETSTORE_NAME_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_KETSTORE_ALIAS_ATTRIBUTE, node, context)) {
        ssl.setKeystoreKeyAlias(asString(SSL_KETSTORE_ALIAS_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_KETSTORE_KEY_PASSWORD_ATTRIBUTE, node, context)) {
        ssl.setKeystoreKeyPassword(asString(SSL_KETSTORE_KEY_PASSWORD_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_ENABLED_CIPHER_SUITES_ATTRIBUTE, node, context)) {
        ssl.setEnabledCipherSuites(asString(SSL_ENABLED_CIPHER_SUITES_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_KETSTORE_PASSWORD_ATTRIBUTE, node, context)) {
        ssl.setKeystorePassword(asString(SSL_KETSTORE_PASSWORD_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_KETSTORE_TYPE_ATTRIBUTE, node, context)) {
        ssl.setKeystoreType(asString(SSL_KETSTORE_TYPE_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_TRUSTSTORE_NAME_ATTRIBUTE, node, context)) {
        ssl.setTruststoreFilename(asString(SSL_TRUSTSTORE_NAME_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_TRUSTSTORE_PASSWORD_ATTRIBUTE, node, context)) {
        ssl.setTruststorePassword(asString(SSL_TRUSTSTORE_PASSWORD_ATTRIBUTE, node, context));
    }
    if (isDefined(SSL_TRUSTSTORE_CHECK_EXPIRED_ATTRIBUTE, node, context)) {
        ssl.setTruststoreCheckExpired(asBoolean(SSL_TRUSTSTORE_CHECK_EXPIRED_ATTRIBUTE, node, context));
    }
    socket.setSSLConfiguration(ssl);
    return socket;
}
Also used : SSLConfiguration(org.teiid.transport.SSLConfiguration) SocketConfiguration(org.teiid.transport.SocketConfiguration)

Example 3 with SSLConfiguration

use of org.teiid.transport.SSLConfiguration in project teiid by teiid.

the class TestEmbeddedServer method testRemoteTrasportSSLFail.

@Test(expected = TeiidRuntimeException.class)
public void testRemoteTrasportSSLFail() throws Exception {
    SocketConfiguration s = new SocketConfiguration();
    InetSocketAddress addr = new InetSocketAddress(0);
    s.setBindAddress(addr.getHostName());
    s.setPortNumber(addr.getPort());
    s.setProtocol(WireProtocol.teiid);
    SSLConfiguration sslConfiguration = new SSLConfiguration();
    sslConfiguration.setSslProtocol("x");
    sslConfiguration.setMode("enabled");
    s.setSSLConfiguration(sslConfiguration);
    EmbeddedConfiguration config = new EmbeddedConfiguration();
    config.addTransport(s);
    es.start(config);
}
Also used : SSLConfiguration(org.teiid.transport.SSLConfiguration) InetSocketAddress(java.net.InetSocketAddress) SocketConfiguration(org.teiid.transport.SocketConfiguration) Test(org.junit.Test)

Aggregations

SSLConfiguration (org.teiid.transport.SSLConfiguration)3 SocketConfiguration (org.teiid.transport.SocketConfiguration)3 InetSocketAddress (java.net.InetSocketAddress)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)1 FakeServer (org.teiid.jdbc.FakeServer)1 QueryExpression (org.teiid.language.QueryExpression)1 EmbeddedConfiguration (org.teiid.runtime.EmbeddedConfiguration)1 HardCodedExecutionFactory (org.teiid.runtime.HardCodedExecutionFactory)1 SocketListener (org.teiid.transport.SocketListener)1