Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project

This commit is contained in:
Joakim Erdfelt 2015-05-01 09:43:20 -07:00
commit 3a0a85ebc9
18 changed files with 194 additions and 120 deletions

View File

@ -63,21 +63,25 @@
<!-- =========================================================== -->
<!-- jetty-jndi by default -->
<!-- =========================================================== -->
<Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault">
<Arg><Ref refid="Server" /></Arg>
<Call name="addAfter">
<Arg name="afterClass">org.eclipse.jetty.webapp.FragmentConfiguration</Arg>
<Arg>
<Array type="String">
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
</Array>
</Arg>
</Call>
<!-- Set up the list of default configuration classes -->
<!-- =========================================================== -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.webapp.configuration</Arg>
<Arg>
<New class="org.eclipse.jetty.webapp.Configuration$ClassList">
<Arg>
<Array type="String">
<Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
<Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
</Array>
</Arg>
</New>
</Arg>
</Call>
<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.initial</Arg>

View File

@ -23,7 +23,6 @@ import java.net.URL;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
@ -32,13 +31,13 @@ import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
import org.eclipse.jetty.osgi.boot.internal.webapp.OSGiWebappClassLoader;
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelperFactory;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.ArrayUtil;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.JarResource;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;
import org.osgi.framework.Bundle;
@ -56,40 +55,12 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
{
private static final Logger LOG = Log.getLogger(AbstractWebAppProvider.class);
public static String __defaultConfigurations[] = {
"org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration",
"org.eclipse.jetty.webapp.WebXmlConfiguration",
"org.eclipse.jetty.webapp.MetaInfConfiguration",
"org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
};
public static void setDefaultConfigurations (String[] defaultConfigs)
{
__defaultConfigurations = defaultConfigs;
}
public static String[] getDefaultConfigurations ()
{
List<String> configs = ArrayUtil.asMutableList(__defaultConfigurations);
if (annotationsAvailable())
{
//add before JettyWebXmlConfiguration
int i = configs.indexOf("org.eclipse.jetty.webapp.JettyWebXmlConfiguration");
configs.add(i, "org.eclipse.jetty.osgi.annotations.AnnotationConfiguration");
}
if (jndiAvailable())
{
//add in EnvConfiguration and PlusConfiguration just after FragmentConfiguration
int i = configs.indexOf("org.eclipse.jetty.webapp.FragmentConfiguration");
configs.add(++i, "org.eclipse.jetty.plus.webapp.EnvConfiguration");
configs.add(++i, "org.eclipse.jetty.plus.webapp.PlusConfiguration");
}
return configs.toArray(new String[configs.size()]);
}
/* ------------------------------------------------------------ */
/**
* Check if we should be enabling annotation processing
*
* @return true if the jetty-annotations.jar is present, false otherwise
*/
private static boolean annotationsAvailable()
{
boolean result = false;
@ -108,7 +79,12 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
return result;
}
/* ------------------------------------------------------------ */
/**
* Check if jndi is support is present.
*
* @return true if the jetty-jndi.jar is present, false otherwise
*/
private static boolean jndiAvailable()
{
try
@ -140,11 +116,13 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
private ServerInstanceWrapper _serverWrapper;
/* ------------------------------------------------------------ */
/**
* OSGiApp
*
*
* Represents a deployable webapp.
*/
public class OSGiApp extends AbstractOSGiApp
{
@ -310,10 +288,8 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
// Set up what has been configured on the provider
_webApp.setParentLoaderPriority(isParentLoaderPriority());
_webApp.setExtractWAR(isExtract());
if (getConfigurationClasses() != null)
_webApp.setConfigurationClasses(getConfigurationClasses());
else
_webApp.setConfigurationClasses(getDefaultConfigurations());
_webApp.setConfigurationClasses(getConfigurationClasses());
if (getDefaultsDescriptor() != null)
_webApp.setDefaultsDescriptor(getDefaultsDescriptor());
@ -601,8 +577,25 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
/* ------------------------------------------------------------ */
public String[] getConfigurationClasses()
{
return _configurationClasses;
if (_configurationClasses != null)
return _configurationClasses;
Configuration.ClassList defaults = Configuration.ClassList.serverDefault(_serverWrapper.getServer());
//add before JettyWebXmlConfiguration
if (annotationsAvailable())
defaults.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.osgi.annotations.AnnotationConfiguration");
//add in EnvConfiguration and PlusConfiguration just after FragmentConfiguration
if (jndiAvailable())
defaults.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.plus.webapp.EnvConfiguration",
"org.eclipse.jetty.plus.webapp.PlusConfiguration");
String[] asArray = new String[defaults.size()];
return defaults.toArray(asArray);
}
/* ------------------------------------------------------------ */
public void setServerInstanceWrapper(ServerInstanceWrapper wrapper)

View File

@ -15,11 +15,11 @@
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Get name="ThreadPool">
<!-- Default queued blocking threadpool -->
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
</Get>
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
@ -63,21 +63,25 @@
<!-- =========================================================== -->
<!-- jetty-jndi by default -->
<!-- =========================================================== -->
<Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault">
<Arg><Ref refid="Server" /></Arg>
<Call name="addAfter">
<Arg name="afterClass">org.eclipse.jetty.webapp.FragmentConfiguration</Arg>
<Arg>
<Array type="String">
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
</Array>
</Arg>
</Call>
<!-- Set up the list of default configuration classes -->
<!-- =========================================================== -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.webapp.configuration</Arg>
<Arg>
<New class="org.eclipse.jetty.webapp.Configuration$ClassList">
<Arg>
<Array type="String">
<Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
<Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
</Array>
</Arg>
</New>
</Arg>
</Call>
<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.initial</Arg>

Binary file not shown.

View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<!-- ============================================================= -->
<!-- SSL ContextFactory configuration -->
<!-- For java 8 and beyond the keystore is created in -->
<!-- jetty-ssl-extended-context.xml -->
<!-- ============================================================= -->
<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<Set name="KeyStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.sslContext.keyStorePath,jetty.keystore" default="etc/keystore"/></Set>
<Set name="KeyStorePassword"><Property name="jetty.sslContext.keyStorePassword,jetty.keystore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
<Set name="KeyManagerPassword"><Property name="jetty.sslContext.keyManagerPassword,jetty.keymanager.password" default="OBF:1u2u1wml1z7s1z7a1wnl1u2g"/></Set>
<Set name="TrustStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.sslContext.trustStorePath,jetty.truststore" default="etc/keystore"/></Set>
<Set name="TrustStorePassword"><Property name="jetty.sslContext.trustStorePassword,jetty.truststore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
<Set name="EndpointIdentificationAlgorithm"></Set>
<Set name="NeedClientAuth"><Property name="jetty.sslContext.needClientAuth,jetty.ssl.needClientAuth" default="false"/></Set>
<Set name="WantClientAuth"><Property name="jetty.sslContext.wantClientAuth,jetty.ssl.wantClientAuth" default="false"/></Set>
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item>
</Array>
</Set>
</Configure>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- ============================================================= -->
<!-- Create an extended SSL Context Factory for use in java 8 -->
<!-- and later. -->
<!-- Configuration is completed in jetty-ssl-context.xml -->
<!-- ============================================================= -->
<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.ExtendedSslContextFactory">
<Set name="useCipherSuitesOrder"><Property name="jetty.sslContext.useCipherSuitesOrder" default="true"/></Set>
</New>
</Configure>

View File

@ -36,31 +36,6 @@
</Arg>
</Call>
<!-- ============================================================= -->
<!-- Create a TLS (SSL) Context Factory for later reuse -->
<!-- ============================================================= -->
<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<Set name="KeyStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.sslConfig.keyStorePath,jetty.keystore" default="etc/keystore"/></Set>
<Set name="KeyStorePassword"><Property name="jetty.sslConfig.keyStorePassword,jetty.keystore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
<Set name="KeyManagerPassword"><Property name="jetty.sslConfig.keyManagerPassword,jetty.keymanager.password" default="OBF:1u2u1wml1z7s1z7a1wnl1u2g"/></Set>
<Set name="TrustStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.sslConfig.trustStorePath,jetty.truststore" default="etc/keystore"/></Set>
<Set name="TrustStorePassword"><Property name="jetty.sslConfig.trustStorePassword,jetty.truststore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
<Set name="EndpointIdentificationAlgorithm"></Set>
<Set name="NeedClientAuth"><Property name="jetty.sslConfig.needClientAuth,jetty.ssl.needClientAuth" default="false"/></Set>
<Set name="WantClientAuth"><Property name="jetty.sslConfig.wantClientAuth,jetty.ssl.wantClientAuth" default="false"/></Set>
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item>
</Array>
</Set>
</New>
<!-- =========================================================== -->
<!-- Create a TLS specific HttpConfiguration based on the -->
<!-- common HttpConfiguration defined in jetty.xml -->

View File

@ -0,0 +1,12 @@
#
# SSL java 7 Keystore module
#
[name]
ssl-context
[depend]
server
[xml]
etc/jetty-ssl-context.xml

View File

@ -0,0 +1,12 @@
#
# SSL java 8 Keystore module
#
[name]
ssl-context
[depend]
server
[xml]
etc/jetty-ssl-extended-context.xml

View File

@ -1,15 +1,18 @@
#
# SSL Keystore module
#
[name]
ssl
[depend]
server
ssl-impl/ssl-java${java.version.minor}
[xml]
etc/jetty-ssl.xml
etc/jetty-ssl-context.xml
[files]
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/plain/jetty-server/src/main/config/etc/keystore|etc/keystore
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/plain/jetty-server/src/main/config/etc/example-keystore|etc/keystore
[ini-template]
### TLS(SSL) Connector Configuration
@ -42,27 +45,30 @@ jetty.ssl.port=8443
# jetty.ssl.sniHostCheck=true
### SslContextFactory Configuration
## Keystore file path (relative to $jetty.base)
# jetty.sslConfig.keyStorePath=etc/keystore
## Truststore file path (relative to $jetty.base)
# jetty.sslConfig.trustStorePath=etc/keystore
## Note that OBF passwords are not secure, just protected from casual observation
## See http://www.eclipse.org/jetty/documentation/current/configuring-security-secure-passwords.html
## Keystore file path (relative to $jetty.base)
# jetty.sslContext.keyStorePath=etc/keystore
## Truststore file path (relative to $jetty.base)
# jetty.sslContext.trustStorePath=etc/keystore
## Keystore password
# jetty.sslConfig.keyStorePassword=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
# jetty.sslContext.keyStorePassword=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
## KeyManager password
# jetty.sslConfig.keyManagerPassword=OBF:1u2u1wml1z7s1z7a1wnl1u2g
# jetty.sslContext.keyManagerPassword=OBF:1u2u1wml1z7s1z7a1wnl1u2g
## Truststore password
# jetty.sslConfig.trustStorePassword=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
# jetty.sslContext.trustStorePassword=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
## whether client certificate authentication is required
# jetty.sslConfig.needClientAuth=false
# jetty.sslContext.needClientAuth=false
## Whether client certificate authentication is desired
# jetty.sslConfig.wantClientAuth=false
# jetty.sslContext.wantClientAuth=false
## Whether cipher order is significant (since java 8 only)
# jetty.sslContext.useCipherSuitesOrder=true

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -50,7 +51,8 @@ public class RequestLogHandler extends HandlerWrapper
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
baseRequest.getHttpChannel().setRequestLog(_requestLog);
if (baseRequest.getDispatcherType()==DispatcherType.REQUEST)
baseRequest.getHttpChannel().setRequestLog(_requestLog);
if (_handler!=null)
_handler.handle(target,baseRequest, request, response);
}

View File

@ -43,6 +43,16 @@ public class Modules extends Graph<Module>
this.args = args;
this.setSelectionTerm("enable");
this.setNodeTerm("module");
String java_version = System.getProperty("java.version");
if (java_version!=null)
{
String[] parts = java_version.split("\\.");
if (parts!=null && parts.length>0)
System.setProperty("java.version.major",parts[0]);
if (parts!=null && parts.length>1)
System.setProperty("java.version.minor",parts[1]);
}
}
public void dump()

View File

@ -34,10 +34,13 @@ import org.eclipse.jetty.start.graph.RegexNamePredicate;
import org.eclipse.jetty.start.graph.Selection;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@ -73,6 +76,11 @@ public class ModulesTest
Modules modules = new Modules(basehome,args);
modules.registerAll();
// Check versions
assertThat(System.getProperty("java.version.major"),equalTo("1"));
assertThat(System.getProperty("java.version.minor"),anyOf(equalTo("7"),Matchers.equalTo("8"),Matchers.equalTo("9")));
List<String> moduleNames = new ArrayList<>();
for (Module mod : modules)
{

View File

@ -30,6 +30,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -271,10 +274,11 @@ public class MultiPartInputStreamParser
{
//the part data is already written to a temporary file, just rename it
_temporary = false;
File f = new File(_tmpDir, fileName);
if (_file.renameTo(f))
_file = f;
Path src = _file.toPath();
Path target = src.resolveSibling(fileName);
Files.move(src, target, StandardCopyOption.REPLACE_EXISTING);
_file = target.toFile();
}
}

View File

@ -110,7 +110,8 @@ public class ExtendedSslContextFactory extends SslContextFactory
if (((Number)list.get(0)).intValue() == 2 )
{
String cn = list.get(1).toString();
LOG.info("Certificate san alias={} cn={} in {}",alias,cn,_factory);
if (LOG.isDebugEnabled())
LOG.debug("Certificate san alias={} cn={} in {}",alias,cn,_factory);
if (cn!=null)
{
named=true;
@ -129,7 +130,8 @@ public class ExtendedSslContextFactory extends SslContextFactory
if (rdn.getType().equalsIgnoreCase("cn"))
{
String cn = rdn.getValue().toString();
LOG.info("Certificate cn alias={} cn={} in {}",alias,cn,_factory);
if (LOG.isDebugEnabled())
LOG.debug("Certificate cn alias={} cn={} in {}",alias,cn,_factory);
if (cn!=null)
_aliases.put(cn,alias);
}
@ -145,7 +147,7 @@ public class ExtendedSslContextFactory extends SslContextFactory
if (name.startsWith("*."))
_wild.put(name.substring(1),_aliases.get(name));
LOG.info("aliases={} for {}",_aliases,this);
LOG.info("x509={} for {}",_aliases,this);
}
@Override

View File

@ -103,7 +103,7 @@ public class HttpInputIntegrationTest
// SSL Context Factory for HTTPS and HTTP/2
String jetty_distro = System.getProperty("jetty.distro","../../jetty-distribution/target/distribution");
__sslContextFactory = new SslContextFactory();
__sslContextFactory.setKeyStorePath(jetty_distro + "/etc/keystore");
__sslContextFactory.setKeyStorePath(jetty_distro + "/etc/example-keystore");
__sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
__sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");