/** * Returns the connection properties supported by this driver. */ protected Collection<ConnectionProperty> getConnectionProperties() { return Arrays.<ConnectionProperty>asList( BuiltInConnectionProperty.values()); }
public File kerberosKeytab() { String keytabPath = BuiltInConnectionProperty.KEYTAB.wrap(properties).getString(); if (null == keytabPath) { return null; } File keytab = new File(keytabPath); if (!keytab.exists() || !keytab.isFile()) { throw new RuntimeException("The " + BuiltInConnectionProperty.KEYTAB.name() + " does not " + " reference a normal, existent file: " + keytabPath); } return keytab; }
/** * Serializes the necessary properties into a Map. * * @param props The properties to serialize. * @return A representation of the Properties as a Map. */ public static Map<String, String> serializeProperties(Properties props) { Map<String, String> infoAsString = new HashMap<>(); for (Map.Entry<Object, Object> entry : props.entrySet()) { // Determine if this is a property we want to forward to the server if (!BuiltInConnectionProperty.isLocalProperty(entry.getKey())) { infoAsString.put(entry.getKey().toString(), entry.getValue().toString()); } } return infoAsString; }
public File keystore() { String filename = BuiltInConnectionProperty.KEYSTORE.wrap(properties).getString(); if (null == filename) { return null; } return new File(filename); }
/** * Serializes the necessary properties into a Map. * * @param props The properties to serialize. * @return A representation of the Properties as a Map. */ public static Map<String, String> serializeProperties(Properties props) { Map<String, String> infoAsString = new HashMap<>(); for (Map.Entry<Object, Object> entry : props.entrySet()) { // Determine if this is a property we want to forward to the server boolean localProperty = false; for (BuiltInConnectionProperty prop : BuiltInConnectionProperty.values()) { if (prop.camelName().equals(entry.getKey())) { localProperty = true; break; } } if (!localProperty) { infoAsString.put(entry.getKey().toString(), entry.getValue().toString()); } } return infoAsString; }
@Test public void testTrustStore() { final String trustStore = "/my/truststore.jks"; final String windowsTrustStore = "my\\truststore.jks"; final String pw = "supremelysecret"; Properties props = new Properties(); props.setProperty(BuiltInConnectionProperty.TRUSTSTORE.name(), trustStore); props.setProperty(BuiltInConnectionProperty.TRUSTSTORE_PASSWORD.name(), pw); ConnectionConfigImpl config = new ConnectionConfigImpl(props); assertThat(config.truststore().getAbsolutePath(), File.separatorChar == '/' ? is(trustStore) : is(Paths.get(".").toAbsolutePath().getRoot() + windowsTrustStore)); assertThat(config.truststorePassword(), is(pw)); }
public File truststore() { String filename = BuiltInConnectionProperty.TRUSTSTORE.wrap(properties).getString(); if (null == filename) { return null; } return new File(filename); }
@Test public void testTrustStore() { final String trustStore = "/my/truststore.jks"; final String windowsTrustStore = "my\\truststore.jks"; final String pw = "supremelysecret"; Properties props = new Properties(); props.setProperty(BuiltInConnectionProperty.TRUSTSTORE.name(), trustStore); props.setProperty(BuiltInConnectionProperty.TRUSTSTORE_PASSWORD.name(), pw); ConnectionConfigImpl config = new ConnectionConfigImpl(props); assertThat(config.truststore().getAbsolutePath(), File.separatorChar == '/' ? is(trustStore) : is(Paths.get(".").toAbsolutePath().getRoot() + windowsTrustStore)); assertThat(config.truststorePassword(), is(pw)); }
/** * Returns the connection properties supported by this driver. */ protected Collection<ConnectionProperty> getConnectionProperties() { return Arrays.<ConnectionProperty>asList( BuiltInConnectionProperty.values()); }
public AvaticaHttpClientFactory httpClientFactory() { return BuiltInConnectionProperty.HTTP_CLIENT_FACTORY.wrap(properties) .getPlugin(AvaticaHttpClientFactory.class, null); }
public File kerberosKeytab() { String keytabPath = BuiltInConnectionProperty.KEYTAB.wrap(properties).getString(); if (null == keytabPath) { return null; } File keytab = new File(keytabPath); if (!keytab.exists() || !keytab.isFile()) { throw new RuntimeException("The " + BuiltInConnectionProperty.KEYTAB.name() + " does not " + " reference a normal, existent file: " + keytabPath); } return keytab; }
@Test public void testOverridenHttpClient() throws Exception { Properties props = new Properties(); props.setProperty(BuiltInConnectionProperty.HTTP_CLIENT_IMPL.name(), AvaticaHttpClientImpl.class.getName()); URL url = new URL("http://localhost:8765"); ConnectionConfig config = new ConnectionConfigImpl(props); AvaticaHttpClientFactory httpClientFactory = new AvaticaHttpClientFactoryImpl(); AvaticaHttpClient client = httpClientFactory.getClient(url, config, null); assertTrue("Client was an instance of " + client.getClass(), client instanceof AvaticaHttpClientImpl); } }
/** * Serializes the necessary properties into a Map. * * @param props The properties to serialize. * @return A representation of the Properties as a Map. */ public static Map<String, String> serializeProperties(Properties props) { Map<String, String> infoAsString = new HashMap<>(); for (Map.Entry<Object, Object> entry : props.entrySet()) { // Determine if this is a property we want to forward to the server if (!BuiltInConnectionProperty.isLocalProperty(entry.getKey())) { infoAsString.put(entry.getKey().toString(), entry.getValue().toString()); } } return infoAsString; }
/** * Returns the connection properties supported by this driver. */ protected Collection<ConnectionProperty> getConnectionProperties() { return Arrays.<ConnectionProperty>asList( BuiltInConnectionProperty.values()); }
public Service.Factory factory() { return BuiltInConnectionProperty.FACTORY.wrap(properties) .getPlugin(Service.Factory.class, null); }
@Test public void testOverridenHttpClient() throws Exception { Properties props = new Properties(); props.setProperty(BuiltInConnectionProperty.HTTP_CLIENT_IMPL.name(), AvaticaHttpClientImpl.class.getName()); URL url = new URL("http://localhost:8765"); ConnectionConfig config = new ConnectionConfigImpl(props); AvaticaHttpClientFactory httpClientFactory = new AvaticaHttpClientFactoryImpl(); AvaticaHttpClient client = httpClientFactory.getClient(url, config, null); assertTrue("Client was an instance of " + client.getClass(), client instanceof AvaticaHttpClientImpl); } }
@Override protected Collection<ConnectionProperty> getConnectionProperties() { final List<ConnectionProperty> list = new ArrayList<>(); Collections.addAll(list, BuiltInConnectionProperty.values()); Collections.addAll(list, CalciteConnectionProperty.values()); return list; }
public File truststore() { String filename = BuiltInConnectionProperty.TRUSTSTORE.wrap(properties).getString(); if (null == filename) { return null; } return new File(filename); }
@Override protected Collection<ConnectionProperty> getConnectionProperties() { final List<ConnectionProperty> list = new ArrayList<>(); Collections.addAll(list, BuiltInConnectionProperty.values()); Collections.addAll(list, CalciteConnectionProperty.values()); return list; }
public File keystore() { String filename = BuiltInConnectionProperty.KEYSTORE.wrap(properties).getString(); if (null == filename) { return null; } return new File(filename); }