removed all remaining deprecation warnings

pull/390/head
Michael Peter Christen 4 years ago
parent c0f6d6e11d
commit 7947baeb49

@ -48,17 +48,8 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SchemeRegistryFactory;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContextBuilder;
@ -121,7 +112,7 @@ public class RemoteInstance implements SolrInstance {
}
/** A custom scheme registry allowing https connections to servers using self-signed certificate */
private static final SchemeRegistry SCHEME_REGISTRY = buildTrustSelfSignedSchemeRegistry();
private static final org.apache.http.conn.scheme.SchemeRegistry SCHEME_REGISTRY = buildTrustSelfSignedSchemeRegistry();
/** Solr server URL */
private String solrurl;
@ -296,10 +287,10 @@ public class RemoteInstance implements SolrInstance {
this.client = HttpClientUtil.createClient(params, CONNECTION_MANAGER);
if(this.client instanceof DefaultHttpClient) {
if(this.client instanceof org.apache.http.impl.client.DefaultHttpClient) {
if(this.client.getParams() != null) {
/* Set the maximum time to get a connection from the shared connections pool */
HttpClientParams.setConnectionManagerTimeout(this.client.getParams(), timeout);
org.apache.http.client.params.HttpClientParams.setConnectionManagerTimeout(this.client.getParams(), timeout);
}
if (maxBytesPerResponse >= 0 && maxBytesPerResponse < Long.MAX_VALUE) {
@ -307,8 +298,8 @@ public class RemoteInstance implements SolrInstance {
* Add in last position the eventual interceptor limiting the response size, so
* that this is the decompressed amount of bytes that is considered
*/
((DefaultHttpClient)this.client).addResponseInterceptor(new StrictSizeLimitResponseInterceptor(maxBytesPerResponse),
((DefaultHttpClient)this.client).getResponseInterceptorCount());
((org.apache.http.impl.client.DefaultHttpClient)this.client).addResponseInterceptor(new StrictSizeLimitResponseInterceptor(maxBytesPerResponse),
((org.apache.http.impl.client.DefaultHttpClient)this.client).getResponseInterceptorCount());
}
}
}
@ -348,7 +339,7 @@ public class RemoteInstance implements SolrInstance {
* Upgrade only when Solr implementation will become compatible */
final org.apache.http.impl.conn.PoolingClientConnectionManager cm = new org.apache.http.impl.conn.PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault(), DEFAULT_POOLED_CONNECTION_TIME_TO_LIVE, TimeUnit.SECONDS);
org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(), DEFAULT_POOLED_CONNECTION_TIME_TO_LIVE, TimeUnit.SECONDS);
initPoolMaxConnections(cm, DEFAULT_POOL_MAX_TOTAL);
return cm;
}
@ -357,17 +348,17 @@ public class RemoteInstance implements SolrInstance {
* @return a custom scheme registry allowing https connections to servers using
* a self-signed certificate
*/
private static SchemeRegistry buildTrustSelfSignedSchemeRegistry() {
private static org.apache.http.conn.scheme.SchemeRegistry buildTrustSelfSignedSchemeRegistry() {
/* Important note : use of deprecated Apache classes is required because SolrJ still use them internally (see HttpClientUtil).
* Upgrade only when Solr implementation will become compatible */
SchemeRegistry registry = null;
org.apache.http.conn.scheme.SchemeRegistry registry = null;
SSLContext sslContext;
try {
sslContext = SSLContextBuilder.create().loadTrustMaterial(TrustSelfSignedStrategy.INSTANCE).build();
registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
registry = new org.apache.http.conn.scheme.SchemeRegistry();
registry.register(new org.apache.http.conn.scheme.Scheme("http", 80, org.apache.http.conn.scheme.PlainSocketFactory.getSocketFactory()));
registry.register(
new Scheme("https", 443, new SSLSocketFactory(sslContext, AllowAllHostnameVerifier.INSTANCE) {
new org.apache.http.conn.scheme.Scheme("https", 443, new org.apache.http.conn.ssl.SSLSocketFactory(sslContext, org.apache.http.conn.ssl.AllowAllHostnameVerifier.INSTANCE) {
@Override
protected void prepareSocket(SSLSocket socket) throws IOException {
if(!ENABLE_SNI_EXTENSION.get()) {
@ -415,7 +406,7 @@ public class RemoteInstance implements SolrInstance {
authCache.put(targetHost, basicAuth);
context.setAttribute(org.apache.http.client.protocol.HttpClientContext.AUTH_CACHE, authCache);
if (trustSelfSignedCertificates && SCHEME_REGISTRY != null) {
context.setAttribute(ClientContext.SCHEME_REGISTRY, SCHEME_REGISTRY);
context.setAttribute(org.apache.http.client.protocol.ClientContext.SCHEME_REGISTRY, SCHEME_REGISTRY);
}
this.setHttpRequestRetryHandler(new org.apache.http.impl.client.DefaultHttpRequestRetryHandler(0, false)); // no retries needed; we expect connections to fail; therefore we should not retry
return context;
@ -427,7 +418,7 @@ public class RemoteInstance implements SolrInstance {
/* Set the maximum time between data packets reception one a connection has been established */
org.apache.http.params.HttpConnectionParams.setSoTimeout(params, timeout);
/* Set the maximum time to get a connection from the shared connections pool */
HttpClientParams.setConnectionManagerTimeout(params, timeout);
org.apache.http.client.params.HttpClientParams.setConnectionManagerTimeout(params, timeout);
result.addRequestInterceptor(new HttpRequestInterceptor() {
@Override
public void process(final HttpRequest request, final HttpContext context) throws IOException {

@ -23,6 +23,7 @@ package net.yacy.cora.protocol.http.auth;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.ArrayList;
@ -41,7 +42,6 @@ import org.apache.http.HttpRequest;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.params.AuthPNames;
import org.apache.http.impl.auth.DigestScheme;
import org.apache.http.impl.auth.UnsupportedDigestAlgorithmException;
import org.apache.http.message.BasicHeaderValueFormatter;
@ -134,21 +134,12 @@ public class YaCyDigestScheme extends DigestScheme {
// Add method name and request-URI to the parameter map
getParameters().put("methodname", request.getRequestLine().getMethod());
getParameters().put("uri", request.getRequestLine().getUri());
final String charset = getParameter("charset");
if (charset == null) {
getParameters().put("charset", getCredentialsCharset(request));
if (getParameter("charset") == null) {
getParameters().put("charset", StandardCharsets.US_ASCII.name()); // default according to https://hc.apache.org/httpcomponents-client-4.2.x/tutorial/html/authentication.html
}
return createDigestHeader(credentials, request);
}
String getCredentialsCharset(final HttpRequest request) {
String charset = (String) request.getParams().getParameter(AuthPNames.CREDENTIAL_CHARSET);
if (charset == null) {
charset = getCredentialsCharset().name();
}
return charset;
}
private static MessageDigest createMessageDigest(
final String digAlg) throws UnsupportedDigestAlgorithmException {
try {

@ -26,9 +26,7 @@ import java.nio.charset.Charset;
import org.apache.http.annotation.Contract;
import org.apache.http.annotation.ThreadingBehavior;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeFactory;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
/**
@ -37,7 +35,7 @@ import org.apache.http.protocol.HttpContext;
* instead of clear-text password.
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class YaCyDigestSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider {
public class YaCyDigestSchemeFactory implements AuthSchemeProvider {
private final Charset charset;
@ -53,11 +51,6 @@ public class YaCyDigestSchemeFactory implements AuthSchemeFactory, AuthSchemePro
this(null);
}
@Override
public AuthScheme newInstance(final HttpParams params) {
return new YaCyDigestScheme();
}
@Override
public AuthScheme create(final HttpContext context) {
return new YaCyDigestScheme(this.charset);

@ -457,7 +457,7 @@ public class YaCyDefaultServlet extends HttpServlet {
String base = URIUtil.addPaths(request.getRequestURI(), URIUtil.SLASH);
String dir = resource.getListHTML(base, pathInContext.length() > 1);
String dir = resource.getListHTML(base, pathInContext.length() > 1, null);
if (dir == null) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "No directory");
return;

Loading…
Cancel
Save