Merge branch 'jetty-9.3.x' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-9.3.x
This commit is contained in:
commit
376269c131
|
@ -27,6 +27,7 @@ import java.net.Socket;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -36,6 +37,7 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Test;
|
||||
|
@ -58,8 +60,8 @@ public class SSLCloseTest
|
|||
server.addConnector(connector);
|
||||
server.setHandler(new WriteHandler());
|
||||
server.start();
|
||||
|
||||
SSLContext ctx=SSLContext.getInstance("SSLv3");
|
||||
|
||||
SSLContext ctx=SSLContext.getInstance("TLSv1.2");
|
||||
ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());
|
||||
|
||||
int port=connector.getLocalPort();
|
||||
|
|
|
@ -189,7 +189,7 @@ public class SSLEngineTest
|
|||
|
||||
Socket[] client=new Socket[numConns];
|
||||
|
||||
SSLContext ctx=SSLContext.getInstance("SSLv3");
|
||||
SSLContext ctx=SSLContext.getInstance("TLSv1.2");
|
||||
ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());
|
||||
|
||||
int port=connector.getLocalPort();
|
||||
|
|
|
@ -250,14 +250,10 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
setTrustAll(trustAll);
|
||||
addExcludeProtocols("SSL", "SSLv2", "SSLv2Hello", "SSLv3");
|
||||
setExcludeCipherSuites(
|
||||
"SSL_RSA_WITH_DES_CBC_SHA",
|
||||
"SSL_DHE_RSA_WITH_DES_CBC_SHA",
|
||||
"^.*_RSA_.*_(MD5|SHA|SHA1)$",
|
||||
"SSL_DHE_DSS_WITH_DES_CBC_SHA",
|
||||
"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
|
||||
"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
|
||||
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
|
||||
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of SslContextFactory
|
||||
|
|
|
@ -29,6 +29,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyStore;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
|
@ -56,6 +57,20 @@ public class SslContextFactoryTest
|
|||
cf = new SslContextFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSLOTH() throws Exception
|
||||
{
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
cf.start();
|
||||
|
||||
System.err.println(Arrays.asList(cf.getSelectedProtocols()));
|
||||
for (String cipher : cf.getSelectedCipherSuites())
|
||||
System.err.println(cipher);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoTsFileKs() throws Exception
|
||||
{
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.quickstart;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class AttributeNormalizerTest
|
||||
{
|
||||
@Parameters(name="{0} = {1}")
|
||||
public static List<String[]> data()
|
||||
{
|
||||
String[][] tests = {
|
||||
{ "WAR", "/opt/jetty-distro/demo.base/webapps/root" },
|
||||
{ "jetty.home", "/opt/jetty-distro" },
|
||||
{ "jetty.base", "/opt/jetty-distro/demo.base" },
|
||||
{ "user.home", "/home/user" },
|
||||
{ "user.dir", "/etc/init.d" },
|
||||
};
|
||||
|
||||
return Arrays.asList(tests);
|
||||
}
|
||||
|
||||
private static String origJettyBase;
|
||||
private static String origJettyHome;
|
||||
private static String origUserHome;
|
||||
private static String origUserDir;
|
||||
|
||||
@BeforeClass
|
||||
public static void initProperties()
|
||||
{
|
||||
origJettyBase = System.getProperty("jetty.base");
|
||||
origJettyHome = System.getProperty("jetty.home");
|
||||
origUserHome = System.getProperty("user.home");
|
||||
origUserDir = System.getProperty("user.dir");
|
||||
|
||||
System.setProperty("jetty.home","/opt/jetty-distro");
|
||||
System.setProperty("jetty.base","/opt/jetty-distro/demo.base");
|
||||
System.setProperty("user.home","/home/user");
|
||||
System.setProperty("user.dir","/etc/init.d");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void restoreProperties()
|
||||
{
|
||||
if(origJettyBase != null) System.setProperty("jetty.base",origJettyBase);
|
||||
if(origJettyHome != null) System.setProperty("jetty.home",origJettyHome);
|
||||
if(origUserHome != null) System.setProperty("user.home",origUserHome);
|
||||
if(origUserDir != null) System.setProperty("user.dir",origUserDir);
|
||||
}
|
||||
|
||||
@Parameter(0)
|
||||
public String key;
|
||||
|
||||
@Parameter(1)
|
||||
public String path;
|
||||
|
||||
private AttributeNormalizer normalizer;
|
||||
|
||||
public AttributeNormalizerTest() throws MalformedURLException
|
||||
{
|
||||
normalizer = new AttributeNormalizer(Resource.newResource("/opt/jetty-distro/demo.base/webapps/root"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqual()
|
||||
{
|
||||
assertEquals("file:${" + key + "}",normalizer.normalize("file:" + path));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsSlash()
|
||||
{
|
||||
assertEquals("file:${" + key + "}",normalizer.normalize("file:" + path + "/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsSlashFile()
|
||||
{
|
||||
assertEquals("file:${" + key + "}/file",normalizer.normalize("file:" + path + "/file"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testURIEquals() throws URISyntaxException
|
||||
{
|
||||
assertEquals("file:${" + key + "}",normalizer.normalize(new URI("file:" + path)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testURIEqualsSlash() throws URISyntaxException
|
||||
{
|
||||
assertEquals("file:${" + key + "}",normalizer.normalize(new URI("file:" + path + "/")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testURIEqualsSlashFile() throws URISyntaxException
|
||||
{
|
||||
assertEquals("file:${" + key + "}/file",normalizer.normalize(new URI("file:" + path + "/file")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testURLEquals() throws MalformedURLException
|
||||
{
|
||||
assertEquals("file:${" + key + "}",normalizer.normalize(new URL("file:" + path)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testURLEqualsSlash() throws MalformedURLException
|
||||
{
|
||||
assertEquals("file:${" + key + "}",normalizer.normalize(new URL("file:" + path + "/")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testURLEqualsSlashFile() throws MalformedURLException
|
||||
{
|
||||
assertEquals("file:${" + key + "}/file",normalizer.normalize(new URL("file:" + path + "/file")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_BangFile()
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize("jar:file:" + path + "!/file"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_SlashBangFile()
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize("jar:file:" + path + "/!/file"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_FileBangFile()
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}/file!/file",normalizer.normalize("jar:file:" + path + "/file!/file"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_URIBangFile() throws URISyntaxException
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URI("jar:file:" + path + "!/file")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_URISlashBangFile() throws URISyntaxException
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URI("jar:file:" + path + "/!/file")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_URIFileBangFile() throws URISyntaxException
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}/file!/file",normalizer.normalize(new URI("jar:file:" + path + "/file!/file")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_URLBangFile() throws MalformedURLException
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URL("jar:file:" + path + "!/file")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_URLSlashBangFile() throws MalformedURLException
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URL("jar:file:" + path + "/!/file")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarFileEquals_URLFileBangFile() throws MalformedURLException
|
||||
{
|
||||
assertEquals("jar:file:${" + key + "}/file!/file",normalizer.normalize(new URL("jar:file:" + path + "/file!/file")));
|
||||
}
|
||||
}
|
|
@ -21,10 +21,8 @@ package org.eclipse.jetty.quickstart;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
|
@ -35,7 +33,6 @@ import org.eclipse.jetty.webapp.WebDescriptor;
|
|||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
import org.eclipse.jetty.xml.XmlParser.Node;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class QuickStartTest
|
||||
|
@ -163,7 +160,7 @@ public class QuickStartTest
|
|||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURI().toURL());
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
|
@ -179,73 +176,4 @@ public class QuickStartTest
|
|||
|
||||
server.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNormalize() throws Exception
|
||||
{
|
||||
String jetty_base=System.getProperty("jetty.base");
|
||||
String jetty_home=System.getProperty("jetty.home");
|
||||
String user_home=System.getProperty("user.home");
|
||||
String user_dir=System.getProperty("user.dir");
|
||||
try
|
||||
{
|
||||
System.setProperty("jetty.home","/opt/jetty-distro");
|
||||
System.setProperty("jetty.base","/opt/jetty-distro/demo.base");
|
||||
System.setProperty("user.home","/home/user");
|
||||
System.setProperty("user.dir","/etc/init.d");
|
||||
AttributeNormalizer normalizer = new AttributeNormalizer(Resource.newResource("/opt/jetty-distro/demo.base/webapps/root"));
|
||||
|
||||
String[][] tests = {
|
||||
{ "WAR", "/opt/jetty-distro/demo.base/webapps/root" },
|
||||
{ "jetty.home", "/opt/jetty-distro" },
|
||||
{ "jetty.base", "/opt/jetty-distro/demo.base" },
|
||||
{ "user.home", "/home/user" },
|
||||
{ "user.dir", "/etc/init.d" },
|
||||
};
|
||||
|
||||
for (String[] test : tests)
|
||||
{
|
||||
Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize("file:"+test[1]));
|
||||
Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize("file:"+test[1]+"/"));
|
||||
Assert.assertEquals("file:${"+test[0]+"}/file",normalizer.normalize("file:"+test[1]+"/file"));
|
||||
Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URI("file:"+test[1])));
|
||||
Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URI("file:"+test[1]+"/")));
|
||||
Assert.assertEquals("file:${"+test[0]+"}/file",normalizer.normalize(new URI("file:"+test[1]+"/file")));
|
||||
Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URL("file:"+test[1])));
|
||||
Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URL("file:"+test[1]+"/")));
|
||||
Assert.assertEquals("file:${"+test[0]+"}/file",normalizer.normalize(new URL("file:"+test[1]+"/file")));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize("jar:file:"+test[1]+"!/file"));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize("jar:file:"+test[1]+"/!/file"));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}/file!/file",normalizer.normalize("jar:file:"+test[1]+"/file!/file"));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URI("jar:file:"+test[1]+"!/file")));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URI("jar:file:"+test[1]+"/!/file")));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}/file!/file",normalizer.normalize(new URI("jar:file:"+test[1]+"/file!/file")));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URL("jar:file:"+test[1]+"!/file")));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URL("jar:file:"+test[1]+"/!/file")));
|
||||
Assert.assertEquals("jar:file:${"+test[0]+"}/file!/file",normalizer.normalize(new URL("jar:file:"+test[1]+"/file!/file")));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (user_dir==null)
|
||||
System.clearProperty("user.dir");
|
||||
else
|
||||
System.setProperty("user.dir",user_dir);
|
||||
|
||||
if (user_home==null)
|
||||
System.clearProperty("user.home");
|
||||
else
|
||||
System.setProperty("user.home",user_home);
|
||||
|
||||
if (jetty_home==null)
|
||||
System.clearProperty("jetty.home");
|
||||
else
|
||||
System.setProperty("jetty.home",jetty_home);
|
||||
|
||||
if (jetty_base==null)
|
||||
System.clearProperty("jetty.base");
|
||||
else
|
||||
System.setProperty("jetty.base",jetty_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue