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();
}
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;
}
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();
}
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;
}
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());
}
}
Aggregations