fix simone review comments

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
olivier lamy 2019-03-13 16:29:21 +01:00
parent 9471eff332
commit a21dab222f
3 changed files with 24 additions and 43 deletions

View File

@ -62,10 +62,7 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
{
try
{
// with java 9+ we must use
//sslEngine.setHandshakeApplicationProtocolSelector(new ALPNCallback((ALPNServerConnection)connection));
Conscrypt.setApplicationProtocolSelector(sslEngine,
toApplicationProtocolSelector(new ALPNCallback((ALPNServerConnection)connection)));
Conscrypt.setApplicationProtocolSelector(sslEngine,new ALPNCallback((ALPNServerConnection)connection));
}
catch (RuntimeException x)
{
@ -77,14 +74,21 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
}
}
private static ApplicationProtocolSelector toApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String> selector)
private final class ALPNCallback extends ApplicationProtocolSelector implements BiFunction<SSLEngine,List<String>,String>, SslHandshakeListener
{
return new ApplicationProtocolSelector()
private final ALPNServerConnection alpnConnection;
private ALPNCallback(ALPNServerConnection connection)
{
alpnConnection = connection;
((DecryptedEndPoint)alpnConnection.getEndPoint()).getSslConnection().addHandshakeListener(this);
}
@Override
public String selectApplicationProtocol(SSLEngine engine, List<String> protocols)
{
return selector.apply(engine, protocols);
return apply(engine, protocols);
}
@Override
@ -92,18 +96,6 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
{
throw new UnsupportedOperationException();
}
};
}
private final class ALPNCallback implements BiFunction<SSLEngine,List<String>,String>, SslHandshakeListener
{
private final ALPNServerConnection alpnConnection;
private ALPNCallback(ALPNServerConnection connection)
{
alpnConnection = connection;
((DecryptedEndPoint)alpnConnection.getEndPoint()).getSslConnection().addHandshakeListener(this);
}
@Override
public String apply(SSLEngine engine, List<String> protocols)

View File

@ -63,12 +63,6 @@ public class ConscryptHTTP2ServerTest
Security.addProvider(new OpenSSLProvider());
}
public static void main(String[] args)
throws Exception
{
new ConscryptHTTP2ServerTest().startServer();
}
private SslContextFactory newSslContextFactory()
{
Path path = Paths.get("src", "test", "resources");
@ -81,17 +75,16 @@ public class ConscryptHTTP2ServerTest
sslContextFactory.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
sslContextFactory.setProvider("Conscrypt");
sslContextFactory.setEndpointIdentificationAlgorithm(null);
if (JavaVersion.VERSION.getPlatform() < 9)
if (JavaVersion.VERSION.getPlatform()<9)
{
// conscrypt enable TLSv1.3 per default but it's not supported in jdk8
sslContextFactory.addExcludeProtocols( "TLSv1.3" );
sslContextFactory.addExcludeProtocols("TLSv1.3");
}
return sslContextFactory;
}
@BeforeEach
public void startServer()
throws Exception
public void startServer() throws Exception
{
HttpConfiguration httpsConfig = new HttpConfiguration();
@ -114,9 +107,7 @@ public class ConscryptHTTP2ServerTest
server.setHandler(new AbstractHandler()
{
@Override
public void handle(String target,Request baseRequest,HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
response.setStatus(200);
baseRequest.setHandled(true);
@ -128,8 +119,7 @@ public class ConscryptHTTP2ServerTest
}
@AfterEach
public void stopServer()
throws Exception
public void stopServer() throws Exception
{
if (server != null)
{
@ -139,8 +129,7 @@ public class ConscryptHTTP2ServerTest
@Test
public void test_simple_query()
throws Exception
public void test_simple_query() throws Exception
{
HTTP2Client h2Client = new HTTP2Client();

View File

@ -146,10 +146,10 @@ public class TestJettyOSGiBootHTTP2Conscrypt
sslContextFactory.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
sslContextFactory.setProvider("Conscrypt");
sslContextFactory.setEndpointIdentificationAlgorithm(null);
if ( JavaVersion.VERSION.getPlatform() < 9)
if ( JavaVersion.VERSION.getPlatform()<9)
{
// conscrypt enable TLSv1.3 per default but it's not supported in jdk8
sslContextFactory.addExcludeProtocols( "TLSv1.3" );
sslContextFactory.addExcludeProtocols("TLSv1.3");
}
HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory);
Executor executor = new QueuedThreadPool();