ElasticDataStoreFactory implements DataStoreFactorySpi { @Override public DataStore createDataStore(Map<String, Serializable> params) throws IOException { final String user = getValue(USER, params); final String passwd = getValue(PASSWD, params); final String proxyUser = getValue(PROXY_USER, params); final String proxyPasswd = getValue(PROXY_PASSWD, params); final RestClient client = createRestClient(params, user, passwd); final RestClient proxyClient = proxyUser != null ? createRestClient(params, proxyUser, proxyPasswd) : null; return createDataStore(client, proxyClient, params); }  @Override String getDisplayName(); @Override String getDescription(); @Override Param[] getParametersInfo(); @Override boolean canProcess(Map<String, Serializable> params); @Override boolean isAvailable(); @Override Map<Key, ?> getImplementationHints(); @Override DataStore createDataStore(Map<String, Serializable> params); DataStore createDataStore(RestClient client, RestClient proxyClient, Map<String, Serializable> params); RestClient createRestClient(Map<String, Serializable> params); @Override DataStore createNewDataStore(Map<String, Serializable> params); RestClientBuilder createClientBuilder(HttpHost[] hosts); static final String DISPLAY_NAME; static final String DESCRIPTION; static final Param HOSTNAME; static final Param HOSTPORT; static final Param INDEX_NAME; static final Param USER; static final Param PASSWD; static final Param RUNAS_GEOSERVER_USER; static final Param PROXY_USER; static final Param PROXY_PASSWD; static final Param SSL_REJECT_UNAUTHORIZED; static final Param SOURCE_FILTERING_ENABLED; static final Param SCROLL_ENABLED; static final Param SCROLL_SIZE; static final Param SCROLL_TIME_SECONDS; static final Param DEFAULT_MAX_FEATURES; static final Param ARRAY_ENCODING; static final Param GRID_SIZE; static final Param GRID_THRESHOLD; static final Param[] PARAMS; }
@Test public void testBuildClientWithSslRejectUnauthorizedDisabled() throws IOException { params.put(ElasticDataStoreFactory.SSL_REJECT_UNAUTHORIZED.key, false); assertNotNull(dataStoreFactory.createDataStore(params)); assertTrue(configCallbackCaptor.getAllValues().size() > 0); configCallbackCaptor.getAllValues().get(0).customizeHttpClient(httpClientBuilder); verify(httpClientBuilder, times(1)).setSSLContext(any()); }
@Test(expected=UncheckedIOException.class) public void testBuildClientWithSslRejectUnauthorizedDisabledAndInvalidSSLContext() throws IOException { params.put(ElasticDataStoreFactory.SSL_REJECT_UNAUTHORIZED.key, false); assertNotNull(dataStoreFactory.createDataStore(params)); assertTrue(configCallbackCaptor.getAllValues().size() > 0); when(httpClientBuilder.setSSLContext(any())).thenThrow(KeyStoreException.class); configCallbackCaptor.getAllValues().get(0).customizeHttpClient(httpClientBuilder); }
@Test(expected=IOException.class) public void testBuildClientWithInvalidHost() throws IOException { params = getParams(":", 9200, null, null); dataStoreFactory.createDataStore(params); }