Search in sources :

Example 1 with JdbcMeta

use of org.apache.calcite.avatica.jdbc.JdbcMeta in project calcite-avatica by apache.

the class DigestAuthHttpServerTest method startServer.

@BeforeClass
public static void startServer() throws Exception {
    final String userPropertiesFile = URLDecoder.decode(BasicAuthHttpServerTest.class.getResource("/auth-users.properties").getFile(), "UTF-8");
    assertNotNull("Could not find properties file for digest auth users", userPropertiesFile);
    // Create a LocalService around HSQLDB
    final JdbcMeta jdbcMeta = new JdbcMeta(CONNECTION_SPEC.url, CONNECTION_SPEC.username, CONNECTION_SPEC.password);
    LocalService service = new LocalService(jdbcMeta);
    server = new HttpServer.Builder().withDigestAuthentication(userPropertiesFile, new String[] { "users" }).withHandler(service, Driver.Serialization.PROTOBUF).withPort(0).build();
    server.start();
    url = "jdbc:avatica:remote:url=http://localhost:" + server.getPort() + ";authentication=DIGEST;serialization=PROTOBUF";
    // Create and grant permissions to our users
    createHsqldbUsers();
}
Also used : JdbcMeta(org.apache.calcite.avatica.jdbc.JdbcMeta) StringContains.containsString(org.hamcrest.core.StringContains.containsString) LocalService(org.apache.calcite.avatica.remote.LocalService) BeforeClass(org.junit.BeforeClass)

Example 2 with JdbcMeta

use of org.apache.calcite.avatica.jdbc.JdbcMeta in project calcite-avatica by apache.

the class AvaticaSpnegoTest method parameters.

@Parameters
public static List<Object[]> parameters() throws Exception {
    final ArrayList<Object[]> parameters = new ArrayList<>();
    // Start the KDC
    setupKdc();
    // Create a LocalService around HSQLDB
    final JdbcMeta jdbcMeta = new JdbcMeta(CONNECTION_SPEC.url, CONNECTION_SPEC.username, CONNECTION_SPEC.password);
    final LocalService localService = new LocalService(jdbcMeta);
    for (Driver.Serialization serialization : new Driver.Serialization[] { Driver.Serialization.JSON, Driver.Serialization.PROTOBUF }) {
        // Build and start the server
        HttpServer httpServer = new HttpServer.Builder().withPort(0).withAutomaticLogin(serverKeytab).withSpnego(SpnegoTestUtil.SERVER_PRINCIPAL, SpnegoTestUtil.REALM).withHandler(localService, serialization).build();
        httpServer.start();
        SERVERS_TO_STOP.add(httpServer);
        final String url = "jdbc:avatica:remote:url=http://" + SpnegoTestUtil.KDC_HOST + ":" + httpServer.getPort() + ";authentication=SPNEGO;serialization=" + serialization;
        LOG.info("JDBC URL {}", url);
        parameters.add(new Object[] { url });
    }
    return parameters;
}
Also used : ArrayList(java.util.ArrayList) JdbcMeta(org.apache.calcite.avatica.jdbc.JdbcMeta) HttpServer(org.apache.calcite.avatica.server.HttpServer) Driver(org.apache.calcite.avatica.remote.Driver) LocalService(org.apache.calcite.avatica.remote.LocalService) Parameters(org.junit.runners.Parameterized.Parameters)

Example 3 with JdbcMeta

use of org.apache.calcite.avatica.jdbc.JdbcMeta in project calcite-avatica by apache.

the class BasicAuthHttpServerTest method startServer.

@BeforeClass
public static void startServer() throws Exception {
    final String userPropertiesFile = URLDecoder.decode(BasicAuthHttpServerTest.class.getResource("/auth-users.properties").getFile(), "UTF-8");
    assertNotNull("Could not find properties file for basic auth users", userPropertiesFile);
    // Create a LocalService around HSQLDB
    final JdbcMeta jdbcMeta = new JdbcMeta(CONNECTION_SPEC.url, CONNECTION_SPEC.username, CONNECTION_SPEC.password);
    LocalService service = new LocalService(jdbcMeta);
    server = new HttpServer.Builder().withBasicAuthentication(userPropertiesFile, new String[] { "users" }).withHandler(service, Driver.Serialization.PROTOBUF).withPort(0).build();
    server.start();
    url = "jdbc:avatica:remote:url=http://localhost:" + server.getPort() + ";authentication=BASIC;serialization=PROTOBUF";
    // Create and grant permissions to our users
    createHsqldbUsers();
}
Also used : JdbcMeta(org.apache.calcite.avatica.jdbc.JdbcMeta) StringContains.containsString(org.hamcrest.core.StringContains.containsString) LocalService(org.apache.calcite.avatica.remote.LocalService) BeforeClass(org.junit.BeforeClass)

Example 4 with JdbcMeta

use of org.apache.calcite.avatica.jdbc.JdbcMeta in project calcite-avatica by apache.

the class SslDriverTest method parameters.

@Parameters
public static List<Object[]> parameters() throws Exception {
    final ArrayList<Object[]> parameters = new ArrayList<>();
    // Create a self-signed cert
    File target = new File(System.getProperty("user.dir"), "target");
    keystore = new File(target, "avatica-test.jks");
    if (keystore.isFile()) {
        assertTrue("Failed to delete keystore: " + keystore, keystore.delete());
    }
    new CertTool().createSelfSignedCert(keystore, "avatica", KEYSTORE_PASSWORD);
    // Create a LocalService around HSQLDB
    final JdbcMeta jdbcMeta = new JdbcMeta(CONNECTION_SPEC.url, CONNECTION_SPEC.username, CONNECTION_SPEC.password);
    final LocalService localService = new LocalService(jdbcMeta);
    for (Driver.Serialization serialization : new Driver.Serialization[] { Driver.Serialization.JSON, Driver.Serialization.PROTOBUF }) {
        // Build and start the server, using TLS
        HttpServer httpServer = new HttpServer.Builder().withPort(0).withTLS(keystore, KEYSTORE_PASSWORD, keystore, KEYSTORE_PASSWORD).withHandler(localService, serialization).build();
        httpServer.start();
        SERVERS_TO_STOP.add(httpServer);
        final String url = "jdbc:avatica:remote:url=https://localhost:" + httpServer.getPort() + ";serialization=" + serialization + ";truststore=" + keystore.getAbsolutePath() + ";truststore_password=" + KEYSTORE_PASSWORD;
        LOG.info("JDBC URL {}", url);
        parameters.add(new Object[] { url });
    }
    return parameters;
}
Also used : JcaContentSignerBuilder(org.bouncycastle.operator.jcajce.JcaContentSignerBuilder) JcaX509v3CertificateBuilder(org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder) ArrayList(java.util.ArrayList) JdbcMeta(org.apache.calcite.avatica.jdbc.JdbcMeta) HttpServer(org.apache.calcite.avatica.server.HttpServer) Driver(org.apache.calcite.avatica.remote.Driver) LocalService(org.apache.calcite.avatica.remote.LocalService) File(java.io.File) Parameters(org.junit.runners.Parameterized.Parameters)

Example 5 with JdbcMeta

use of org.apache.calcite.avatica.jdbc.JdbcMeta in project calcite-avatica by apache.

the class StandaloneServer method start.

public void start() {
    if (null != server) {
        LOG.error("The server was already started");
        Unsafe.systemExit(ExitCodes.ALREADY_STARTED.ordinal());
        return;
    }
    try {
        JdbcMeta meta = new JdbcMeta(url);
        LocalService service = new LocalService(meta);
        // Construct the server
        this.server = new HttpServer.Builder().withHandler(service, serialization).withPort(port).build();
        // Then start it
        server.start();
        LOG.info("Started Avatica server on port {} with serialization {}", server.getPort(), serialization);
    } catch (Exception e) {
        LOG.error("Failed to start Avatica server", e);
        Unsafe.systemExit(ExitCodes.START_FAILED.ordinal());
    }
}
Also used : JdbcMeta(org.apache.calcite.avatica.jdbc.JdbcMeta) LocalService(org.apache.calcite.avatica.remote.LocalService)

Aggregations

JdbcMeta (org.apache.calcite.avatica.jdbc.JdbcMeta)6 LocalService (org.apache.calcite.avatica.remote.LocalService)5 ArrayList (java.util.ArrayList)2 Driver (org.apache.calcite.avatica.remote.Driver)2 HttpServer (org.apache.calcite.avatica.server.HttpServer)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 BeforeClass (org.junit.BeforeClass)2 Parameters (org.junit.runners.Parameterized.Parameters)2 File (java.io.File)1 SQLException (java.sql.SQLException)1 Properties (java.util.Properties)1 Configuration (org.apache.hadoop.conf.Configuration)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 JcaX509v3CertificateBuilder (org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder)1 JcaContentSignerBuilder (org.bouncycastle.operator.jcajce.JcaContentSignerBuilder)1