CommonsDataLoader implements DataLoader { @Override public byte[] get(final String urlString) throws DSSException { if (Protocol.isFileUrl(urlString)) { return fileGet(urlString); } else if (Protocol.isHttpUrl(urlString)) { return httpGet(urlString); } else if (Protocol.isFtpUrl(urlString)) { return ftpGet(urlString); } else if (Protocol.isLdapUrl(urlString)) { return ldapGet(urlString); } else { LOG.warn("DSS framework only supports FILE, HTTP, HTTPS, FTP and LDAP Urls."); } return httpGet(urlString); } CommonsDataLoader();  CommonsDataLoader(final String contentType); @Override byte[] get(final String urlString); @Override DataAndUrl get(final List<String> urlStrings); @Override byte[] get(final String url, final boolean refresh); @Override byte[] post(final String url, final byte[] content); int getTimeoutConnection(); void setTimeoutConnection(final int timeoutConnection); int getTimeoutSocket(); void setTimeoutSocket(final int timeoutSocket); int getConnectionsMaxTotal(); void setConnectionsMaxTotal(int connectionsMaxTotal); int getConnectionsMaxPerRoute(); void setConnectionsMaxPerRoute(int connectionsMaxPerRoute); boolean isRedirectsEnabled(); void setRedirectsEnabled(boolean redirectsEnabled); String getContentType(); @Override void setContentType(final String contentType); List<Integer> getAcceptedHttpStatus(); void setAcceptedHttpStatus(List<Integer> acceptedHttpStatus); ProxyConfig getProxyConfig(); void setProxyConfig(final ProxyConfig proxyConfig); void setSslProtocol(String sslProtocol); void setSslKeystore(DSSDocument sslKeyStore); void setKeyStoreAsTrustMaterial(boolean loadKeyStoreAsTrustMaterial); void setSslKeystoreType(String sslKeystoreType); void setSslKeystorePassword(String sslKeystorePassword); void setSslTruststore(DSSDocument sslTrustStore); void setSslTruststorePassword(final String sslTruststorePassword); void setSslTruststoreType(String sslTruststoreType); CommonsDataLoader addAuthentication(final String host, final int port, final String scheme, final String login, final String password); void propagateAuthentication(final CommonsDataLoader commonsDataLoader); void setRetryHandler(final HttpRequestRetryHandler retryHandler); void setServiceUnavailableRetryStrategy(final ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy); String[] getSupportedSSLProtocols(); void setSupportedSSLProtocols(String[] supportedSSLProtocols); String[] getSupportedSSLCipherSuites(); void setSupportedSSLCipherSuites(String[] supportedSSLCipherSuites); HostnameVerifier getHostnameVerifier(); void setHostnameVerifier(HostnameVerifier hostnameVerifier); TrustStrategy getTrustStrategy(); void setTrustStrategy(TrustStrategy trustStrategy);  }
@Test public void testGet() { byte[] bytesArray = dataLoader.get(URL_TO_LOAD); NativeHTTPDataLoader dataLoader2 = new NativeHTTPDataLoader(); byte[] bytesArrays2 = dataLoader2.get(URL_TO_LOAD); assertTrue(Arrays.equals(bytesArray, bytesArrays2)); CertificateToken certificate = DSSUtils.loadCertificate(bytesArray); assertNotNull(certificate); }
@Test public void dss1583WarningTest() { assertThrows(DSSException.class, () -> { String url = "ldap: dataLoader.get(url); }); assertThrows(DSSException.class, () -> { String url = "ldap: dataLoader.get(url); }); assertThrows(DSSException.class, () -> { String url = "ldap: dataLoader.get(url); }); assertThrows(DSSException.class, () -> { String url = "ldap: dataLoader.get(url); }); }
@Test public void multipleDataLoadTest() { byte[] firstUrlData = dataLoader.get(URL_TO_LOAD); DataAndUrl dataAndUrl = dataLoader.get(Arrays.asList(URL_TO_LOAD, "http: "http: assertEquals(URL_TO_LOAD, dataAndUrl.getUrlString()); assertTrue(Arrays.equals(firstUrlData, dataAndUrl.getData())); dataAndUrl = dataLoader.get(Arrays.asList("http: assertEquals(URL_TO_LOAD, dataAndUrl.getUrlString()); assertTrue(Arrays.equals(firstUrlData, dataAndUrl.getData())); }