update to netty 4.1.47
This commit is contained in:
parent
ac72abeca9
commit
2040c56315
9 changed files with 68 additions and 12 deletions
|
@ -1,10 +1,10 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = netty-http
|
name = netty-http
|
||||||
version = 4.1.45.0
|
version = 4.1.47.0
|
||||||
|
|
||||||
# netty
|
# netty
|
||||||
netty.version = 4.1.45.Final
|
netty.version = 4.1.47.Final
|
||||||
tcnative.version = 2.0.28.Final
|
tcnative.version = 2.0.29.Final
|
||||||
tcnative-legacy-macosx.version = 2.0.26.Final
|
tcnative-legacy-macosx.version = 2.0.26.Final
|
||||||
|
|
||||||
# for netty-http-common
|
# for netty-http-common
|
||||||
|
@ -28,7 +28,6 @@ junit4.version = 4.12
|
||||||
conscrypt.version = 2.2.1
|
conscrypt.version = 2.2.1
|
||||||
jackson.version = 2.9.10
|
jackson.version = 2.9.10
|
||||||
hamcrest.version = 2.1
|
hamcrest.version = 2.1
|
||||||
#mockito.version = 1.10.19
|
|
||||||
mockito.version = 3.1.0
|
mockito.version = 3.1.0
|
||||||
|
|
||||||
# doc
|
# doc
|
||||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
#Sun Aug 18 22:06:23 CEST 2019
|
#Mon Mar 09 11:04:01 CET 2020
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package org.xbib.netty.http.bouncycastle;
|
package org.xbib.netty.http.bouncycastle;
|
||||||
|
|
||||||
|
import org.bouncycastle.operator.OperatorCreationException;
|
||||||
import org.xbib.netty.http.common.ServerCertificateProvider;
|
import org.xbib.netty.http.common.ServerCertificateProvider;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.NoSuchProviderException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
public class BouncyCastleSelfSignedCertificateProvider implements ServerCertificateProvider {
|
public class BouncyCastleSelfSignedCertificateProvider implements ServerCertificateProvider {
|
||||||
|
@ -13,8 +18,12 @@ public class BouncyCastleSelfSignedCertificateProvider implements ServerCertific
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(String fqdn) throws Exception {
|
public void prepare(String fqdn) {
|
||||||
selfSignedCertificate.generate(fqdn, new SecureRandom(), 2048);
|
try {
|
||||||
|
selfSignedCertificate.generate(fqdn, new SecureRandom(), 2048);
|
||||||
|
} catch (IOException | NoSuchProviderException | NoSuchAlgorithmException | OperatorCreationException e) {
|
||||||
|
throw new UncheckedIOException(new IOException(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.time.ZoneOffset;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -478,6 +479,12 @@ public final class Request {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addBasicAuthorization(String name, String password) {
|
||||||
|
String encoding = Base64.getEncoder().encodeToString((name + ":" + password).getBytes(StandardCharsets.UTF_8));
|
||||||
|
this.headers.add(HttpHeaderNames.AUTHORIZATION, "Basic " + encoding);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addBodyData(InterfaceHttpData data) {
|
public Builder addBodyData(InterfaceHttpData data) {
|
||||||
bodyData.add(data);
|
bodyData.add(data);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -79,6 +79,7 @@ public final class Client implements AutoCloseable {
|
||||||
System.setProperty("io.netty.noKeySetOptimization", Boolean.toString(true));
|
System.setProperty("io.netty.noKeySetOptimization", Boolean.toString(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AtomicLong requestCounter;
|
private final AtomicLong requestCounter;
|
||||||
|
|
||||||
private final AtomicLong responseCounter;
|
private final AtomicLong responseCounter;
|
||||||
|
@ -219,7 +220,6 @@ public final class Client implements AutoCloseable {
|
||||||
logger.log(level, () -> "JDK ciphers: " + SecurityUtil.Defaults.JDK_CIPHERS);
|
logger.log(level, () -> "JDK ciphers: " + SecurityUtil.Defaults.JDK_CIPHERS);
|
||||||
logger.log(level, () -> "OpenSSL ciphers: " + SecurityUtil.Defaults.OPENSSL_CIPHERS);
|
logger.log(level, () -> "OpenSSL ciphers: " + SecurityUtil.Defaults.OPENSSL_CIPHERS);
|
||||||
logger.log(level, () -> "OpenSSL available: " + OpenSsl.isAvailable());
|
logger.log(level, () -> "OpenSSL available: " + OpenSsl.isAvailable());
|
||||||
logger.log(level, () -> "OpenSSL ALPN support: " + OpenSsl.isAlpnSupported());
|
|
||||||
logger.log(level, () -> "Candidate ciphers on client: " + clientConfig.getCiphers());
|
logger.log(level, () -> "Candidate ciphers on client: " + clientConfig.getCiphers());
|
||||||
logger.log(level, () -> "Local host name: " + NetworkUtils.getLocalHostName("localhost"));
|
logger.log(level, () -> "Local host name: " + NetworkUtils.getLocalHostName("localhost"));
|
||||||
logger.log(level, () -> "Event loop group: " + eventLoopGroup + " threads=" + clientConfig.getThreadCount());
|
logger.log(level, () -> "Event loop group: " + eventLoopGroup + " threads=" + clientConfig.getThreadCount());
|
||||||
|
|
|
@ -9,7 +9,7 @@ public interface ServerCertificateProvider {
|
||||||
*
|
*
|
||||||
* @param fqdn the full qualified domain name.
|
* @param fqdn the full qualified domain name.
|
||||||
*/
|
*/
|
||||||
void prepare(String fqdn) throws Exception;
|
void prepare(String fqdn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the generated RSA private key file in PEM format.
|
* Returns the generated RSA private key file in PEM format.
|
||||||
|
|
|
@ -263,7 +263,7 @@ public class Domain {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setSelfCert() throws Exception {
|
public Builder setSelfCert() {
|
||||||
ServiceLoader<ServerCertificateProvider> serverCertificateProviders = ServiceLoader.load(ServerCertificateProvider.class);
|
ServiceLoader<ServerCertificateProvider> serverCertificateProviders = ServiceLoader.load(ServerCertificateProvider.class);
|
||||||
for (ServerCertificateProvider serverCertificateProvider : serverCertificateProviders) {
|
for (ServerCertificateProvider serverCertificateProvider : serverCertificateProviders) {
|
||||||
if ("org.xbib.netty.http.bouncycastle.BouncyCastleSelfSignedCertificateProvider".equals(serverCertificateProvider.getClass().getName())) {
|
if ("org.xbib.netty.http.bouncycastle.BouncyCastleSelfSignedCertificateProvider".equals(serverCertificateProvider.getClass().getName())) {
|
||||||
|
|
|
@ -233,7 +233,6 @@ public final class Server implements AutoCloseable {
|
||||||
logger.log(level, () -> "JDK ciphers: " + SecurityUtil.Defaults.JDK_CIPHERS);
|
logger.log(level, () -> "JDK ciphers: " + SecurityUtil.Defaults.JDK_CIPHERS);
|
||||||
logger.log(level, () -> "OpenSSL ciphers: " + SecurityUtil.Defaults.OPENSSL_CIPHERS);
|
logger.log(level, () -> "OpenSSL ciphers: " + SecurityUtil.Defaults.OPENSSL_CIPHERS);
|
||||||
logger.log(level, () -> "OpenSSL available: " + OpenSsl.isAvailable());
|
logger.log(level, () -> "OpenSSL available: " + OpenSsl.isAvailable());
|
||||||
logger.log(level, () -> "OpenSSL ALPN support: " + OpenSsl.isAlpnSupported());
|
|
||||||
logger.log(level, () -> "Installed ciphers on default server: " +
|
logger.log(level, () -> "Installed ciphers on default server: " +
|
||||||
(serverConfig.getAddress().isSecure() ? serverConfig.getDefaultDomain().getSslContext().cipherSuites() : ""));
|
(serverConfig.getAddress().isSecure() ? serverConfig.getDefaultDomain().getSslContext().cipherSuites() : ""));
|
||||||
logger.log(level, () -> "Local host name: " + NetworkUtils.getLocalHostName("localhost"));
|
logger.log(level, () -> "Local host name: " + NetworkUtils.getLocalHostName("localhost"));
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.xbib.netty.http.server.test.http1;
|
||||||
|
|
||||||
|
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||||
|
import io.netty.handler.codec.http.HttpVersion;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.xbib.net.URL;
|
||||||
|
import org.xbib.netty.http.client.Client;
|
||||||
|
import org.xbib.netty.http.client.api.Request;
|
||||||
|
import org.xbib.netty.http.client.api.ResponseListener;
|
||||||
|
import org.xbib.netty.http.common.HttpResponse;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class BasicAuthTest {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(PostTest.class.getName());
|
||||||
|
|
||||||
|
@Disabled
|
||||||
|
void testBasicAuth() throws Exception {
|
||||||
|
Client client = Client.builder()
|
||||||
|
.build();
|
||||||
|
try {
|
||||||
|
ResponseListener<HttpResponse> responseListener = (resp) -> {
|
||||||
|
if (resp.getStatus().getCode() == HttpResponseStatus.OK.code()) {
|
||||||
|
logger.log(Level.INFO, "got response " + resp.getBodyAsString(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
URL serverUrl = URL.from("");
|
||||||
|
Request postRequest = Request.post().setVersion(HttpVersion.HTTP_1_1)
|
||||||
|
.url(serverUrl)
|
||||||
|
.addBasicAuthorization("", "")
|
||||||
|
.setResponseListener(responseListener)
|
||||||
|
.build();
|
||||||
|
client.execute(postRequest).get();
|
||||||
|
} finally {
|
||||||
|
client.shutdownGracefully();
|
||||||
|
logger.log(Level.INFO, "server and client shut down");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue