Merge remote-tracking branch 'origin/master' into jetty-8
This commit is contained in:
commit
cdbec2c78b
|
@ -1,6 +1,8 @@
|
|||
jetty-8.1.6-SNAPSHOT
|
||||
+ 385925: make SslContextFactory.setProtocols and
|
||||
SslContextFactory.setCipherSuites preserve the order of the given parameters
|
||||
|
||||
jetty-8.1.5.v20120716 - 16 July 2012
|
||||
jetty-7.6.6-SNAPSHOT
|
||||
+ 376717 Balancer Servlet with round robin support, contribution, added
|
||||
missing license
|
||||
+ 379250 Server is added to shutdown hook twice
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
|
||||
<Set name="useStandardBindings">false</Set>
|
||||
<Set name="lifeCycleBindings">
|
||||
<Array type="org.eclipse.jetty.deploy.AppLifeCycle.Binding">
|
||||
<Array type="org.eclipse.jetty.deploy.AppLifeCycle$Binding">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.osgi.boot.OSGiDeployer"/>
|
||||
</Item>
|
||||
|
@ -47,7 +47,7 @@
|
|||
<!-- comma separated list of bundle symbolic names that contain custom tag libraries (*.tld files) -->
|
||||
<!-- if those bundles don't exist or can't be loaded no errors or warning will be issued! -->
|
||||
<!-- This default value plugs in the tld files of the reference implementation of JSF -->
|
||||
<!--
|
||||
<!--
|
||||
<Set name="tldBundles"><Property name="org.eclipse.jetty.osgi.tldbundles" default="javax.faces.jsf-impl" /></Set>
|
||||
</New>
|
||||
</Arg>
|
||||
|
|
|
@ -66,6 +66,9 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
* <li><b>exposeHeaders</b>, a comma separated list of HTTP headers that
|
||||
* are allowed to be exposed on the client. Default value is the
|
||||
* <b>empty list</b></li>
|
||||
* <li><b>chainPreflight</b>, if true preflight requests are chained to their
|
||||
* target resource for normal handling (as an OPTION request). Otherwise the
|
||||
* filter will response to the preflight. Default is true.</li>
|
||||
* </ul></p>
|
||||
* <p>A typical configuration could be:
|
||||
* <pre>
|
||||
|
@ -105,7 +108,8 @@ public class CrossOriginFilter implements Filter
|
|||
public static final String PREFLIGHT_MAX_AGE_PARAM = "preflightMaxAge";
|
||||
public static final String ALLOW_CREDENTIALS_PARAM = "allowCredentials";
|
||||
public static final String EXPOSED_HEADERS_PARAM = "exposedHeaders";
|
||||
public static final String FORWARD_PREFLIGHT_PARAM = "forwardPreflight";
|
||||
public static final String OLD_CHAIN_PREFLIGHT_PARAM = "forwardPreflight";
|
||||
public static final String CHAIN_PREFLIGHT_PARAM = "chainPreflight";
|
||||
private static final String ANY_ORIGIN = "*";
|
||||
private static final List<String> SIMPLE_HTTP_METHODS = Arrays.asList("GET", "POST", "HEAD");
|
||||
|
||||
|
@ -116,7 +120,7 @@ public class CrossOriginFilter implements Filter
|
|||
private List<String> exposedHeaders = new ArrayList<String>();
|
||||
private int preflightMaxAge;
|
||||
private boolean allowCredentials;
|
||||
private boolean forwardPreflight;
|
||||
private boolean chainPreflight;
|
||||
|
||||
public void init(FilterConfig config) throws ServletException
|
||||
{
|
||||
|
@ -174,10 +178,14 @@ public class CrossOriginFilter implements Filter
|
|||
exposedHeadersConfig = "";
|
||||
exposedHeaders.addAll(Arrays.asList(exposedHeadersConfig.split(",")));
|
||||
|
||||
String forwardPreflightConfig = config.getInitParameter(FORWARD_PREFLIGHT_PARAM);
|
||||
if (forwardPreflightConfig == null)
|
||||
forwardPreflightConfig = "true";
|
||||
forwardPreflight = Boolean.parseBoolean(forwardPreflightConfig);
|
||||
String chainPreflightConfig = config.getInitParameter(OLD_CHAIN_PREFLIGHT_PARAM);
|
||||
if (chainPreflightConfig!=null) // TODO remove this
|
||||
LOG.warn("DEPRECATED CONFIGURATION: Use "+CHAIN_PREFLIGHT_PARAM+ " instead of "+OLD_CHAIN_PREFLIGHT_PARAM);
|
||||
else
|
||||
chainPreflightConfig = config.getInitParameter(CHAIN_PREFLIGHT_PARAM);
|
||||
if (chainPreflightConfig == null)
|
||||
chainPreflightConfig = "true";
|
||||
chainPreflight = Boolean.parseBoolean(chainPreflightConfig);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
|
@ -188,7 +196,7 @@ public class CrossOriginFilter implements Filter
|
|||
PREFLIGHT_MAX_AGE_PARAM + " = " + preflightMaxAgeConfig + ", " +
|
||||
ALLOW_CREDENTIALS_PARAM + " = " + allowedCredentialsConfig + "," +
|
||||
EXPOSED_HEADERS_PARAM + " = " + exposedHeadersConfig + "," +
|
||||
FORWARD_PREFLIGHT_PARAM + " = " + forwardPreflightConfig
|
||||
CHAIN_PREFLIGHT_PARAM + " = " + chainPreflightConfig
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +223,7 @@ public class CrossOriginFilter implements Filter
|
|||
{
|
||||
LOG.debug("Cross-origin request to {} is a preflight cross-origin request", request.getRequestURI());
|
||||
handlePreflightResponse(request, response, origin);
|
||||
if (forwardPreflight)
|
||||
if (chainPreflight)
|
||||
LOG.debug("Preflight cross-origin request to {} forwarded to application", request.getRequestURI());
|
||||
else
|
||||
return;
|
||||
|
|
|
@ -409,11 +409,11 @@ public class CrossOriginFilterTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testForwardPreflightRequest() throws Exception
|
||||
public void testChainPreflightRequest() throws Exception
|
||||
{
|
||||
FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter());
|
||||
filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "PUT");
|
||||
filterHolder.setInitParameter(CrossOriginFilter.FORWARD_PREFLIGHT_PARAM, "false");
|
||||
filterHolder.setInitParameter(CrossOriginFilter.CHAIN_PREFLIGHT_PARAM, "false");
|
||||
tester.getContext().addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
|
|
|
@ -1215,8 +1215,8 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
if (_includeProtocols!=null)
|
||||
{
|
||||
// Use only the supported included protocols
|
||||
for (String protocol : supportedProtocols)
|
||||
if (_includeProtocols.contains(protocol))
|
||||
for (String protocol : _includeProtocols)
|
||||
if(Arrays.asList(supportedProtocols).contains(protocol))
|
||||
selected_protocols.add(protocol);
|
||||
}
|
||||
else
|
||||
|
@ -1247,8 +1247,8 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
if (_includeCipherSuites!=null)
|
||||
{
|
||||
// Use only the supported included ciphers
|
||||
for (String cipherSuite : supportedCipherSuites)
|
||||
if (_includeCipherSuites.contains(cipherSuite))
|
||||
for (String cipherSuite : _includeCipherSuites)
|
||||
if(Arrays.asList(supportedCipherSuites).contains(cipherSuite))
|
||||
selected_ciphers.add(cipherSuite);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -12,10 +12,8 @@ package org.eclipse.jetty.util.ssl;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
|
@ -23,16 +21,30 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
public class SslContextFactoryTest
|
||||
{
|
||||
|
||||
private SslContextFactory cf;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
cf = new SslContextFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoTsFileKs() throws Exception
|
||||
{
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = new SslContextFactory(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
|
@ -44,11 +56,9 @@ public class SslContextFactoryTest
|
|||
@Test
|
||||
public void testNoTsStreamKs() throws Exception
|
||||
{
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
|
||||
cf.setKeyStoreInputStream(new FileInputStream(keystorePath));
|
||||
InputStream keystoreInputStream = this.getClass().getResourceAsStream("keystore");
|
||||
|
||||
cf.setKeyStoreInputStream(keystoreInputStream);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
|
@ -60,12 +70,11 @@ public class SslContextFactoryTest
|
|||
@Test
|
||||
public void testNoTsSetKs() throws Exception
|
||||
{
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
|
||||
InputStream keystoreInputStream = this.getClass().getResourceAsStream("keystore");
|
||||
|
||||
KeyStore ks = KeyStore.getInstance("JKS");
|
||||
ks.load(new FileInputStream(keystorePath),"storepwd".toCharArray());
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
ks.load(keystoreInputStream, "storepwd".toCharArray());
|
||||
|
||||
cf.setKeyStore(ks);
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
|
@ -77,7 +86,6 @@ public class SslContextFactoryTest
|
|||
@Test
|
||||
public void testNoTsNoKs() throws Exception
|
||||
{
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.start();
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
}
|
||||
|
@ -85,7 +93,6 @@ public class SslContextFactoryTest
|
|||
@Test
|
||||
public void testTrustAll() throws Exception
|
||||
{
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.start();
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
}
|
||||
|
@ -95,7 +102,6 @@ public class SslContextFactoryTest
|
|||
{
|
||||
Resource keystoreResource = Resource.newSystemResource("keystore");
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.setKeyStoreResource(keystoreResource);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
@ -103,7 +109,6 @@ public class SslContextFactoryTest
|
|||
cf.start();
|
||||
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -112,7 +117,6 @@ public class SslContextFactoryTest
|
|||
Resource keystoreResource = Resource.newSystemResource("keystore");
|
||||
Resource truststoreResource = Resource.newSystemResource("keystore");
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.setKeyStoreResource(keystoreResource);
|
||||
cf.setTrustStoreResource(truststoreResource);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
|
@ -130,7 +134,6 @@ public class SslContextFactoryTest
|
|||
Resource keystoreResource = Resource.newSystemResource("keystore");
|
||||
Resource truststoreResource = Resource.newSystemResource("keystore");
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.setKeyStoreResource(keystoreResource);
|
||||
cf.setTrustStoreResource(truststoreResource);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
|
@ -154,7 +157,6 @@ public class SslContextFactoryTest
|
|||
Resource keystoreResource = Resource.newSystemResource("keystore");
|
||||
Resource truststoreResource = Resource.newSystemResource("keystore");
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.setKeyStoreResource(keystoreResource);
|
||||
cf.setTrustStoreResource(truststoreResource);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
|
@ -175,7 +177,6 @@ public class SslContextFactoryTest
|
|||
@Test
|
||||
public void testNoKeyConfig() throws Exception
|
||||
{
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
try
|
||||
{
|
||||
((StdErrLog)Log.getLogger(AbstractLifeCycle.class)).setHideStacks(true);
|
||||
|
@ -192,4 +193,36 @@ public class SslContextFactoryTest
|
|||
Assert.fail("Unexpected exception");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetIncludeCipherSuitesPreservesOrder()
|
||||
{
|
||||
String[] supportedCipherSuites = new String[]{"cipher4", "cipher2", "cipher1", "cipher3"};
|
||||
String[] includeCipherSuites = {"cipher1", "cipher3", "cipher4"};
|
||||
|
||||
cf.setIncludeCipherSuites(includeCipherSuites);
|
||||
String[] selectedCipherSuites = cf.selectCipherSuites(null, supportedCipherSuites);
|
||||
|
||||
assertSelectedMatchesIncluded(includeCipherSuites, selectedCipherSuites);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetIncludeProtocolsPreservesOrder()
|
||||
{
|
||||
String[] supportedProtocol = new String[]{"cipher4", "cipher2", "cipher1", "cipher3"};
|
||||
String[] includeProtocol = {"cipher1", "cipher3", "cipher4"};
|
||||
|
||||
cf.setIncludeProtocols(includeProtocol);
|
||||
String[] selectedProtocol = cf.selectProtocols(null, supportedProtocol);
|
||||
|
||||
assertSelectedMatchesIncluded(includeProtocol, selectedProtocol);
|
||||
}
|
||||
|
||||
private void assertSelectedMatchesIncluded(String[] includeStrings, String[] selectedStrings)
|
||||
{
|
||||
assertThat(includeStrings.length + " strings are selected", selectedStrings.length, is(includeStrings.length));
|
||||
assertThat("order from includeStrings is preserved", selectedStrings[0], equalTo(includeStrings[0]));
|
||||
assertThat("order from includeStrings is preserved", selectedStrings[1], equalTo(includeStrings[1]));
|
||||
assertThat("order from includeStrings is preserved", selectedStrings[2], equalTo(includeStrings[2]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue