Merge branch 'master' into release
This commit is contained in:
commit
b30ca0b99e
|
@ -1,5 +1,7 @@
|
||||||
package org.eclipse.jetty.client;
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -19,6 +21,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
|
@ -51,11 +54,6 @@ import org.junit.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
|
||||||
import static org.hamcrest.Matchers.lessThan;
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.hamcrest.Matchers.not;
|
|
||||||
|
|
||||||
public class SslBytesServerTest extends SslBytesTest
|
public class SslBytesServerTest extends SslBytesTest
|
||||||
{
|
{
|
||||||
private final AtomicInteger sslHandles = new AtomicInteger();
|
private final AtomicInteger sslHandles = new AtomicInteger();
|
||||||
|
@ -624,7 +622,9 @@ public class SslBytesServerTest extends SslBytesTest
|
||||||
TimeUnit.MILLISECONDS.sleep(1000);
|
TimeUnit.MILLISECONDS.sleep(1000);
|
||||||
Assert.assertThat(sslHandles.get(), lessThan(750));
|
Assert.assertThat(sslHandles.get(), lessThan(750));
|
||||||
Assert.assertThat(sslFlushes.get(), lessThan(750));
|
Assert.assertThat(sslFlushes.get(), lessThan(750));
|
||||||
Assert.assertThat(httpParses.get(), lessThan(1000));
|
// An average of 958 httpParses is seen in standard Oracle JDK's
|
||||||
|
// An average of 1183 httpParses is seen in OpenJDK JVMs.
|
||||||
|
Assert.assertThat(httpParses.get(), lessThan(1500));
|
||||||
|
|
||||||
client.close();
|
client.close();
|
||||||
|
|
||||||
|
|
|
@ -323,9 +323,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
_writable=false;
|
if (_dispatched)
|
||||||
if (!_dispatched)
|
_writable=false;
|
||||||
updateKey();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (l>0)
|
else if (l>0)
|
||||||
|
@ -349,9 +348,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
_writable=false;
|
if (_dispatched)
|
||||||
if (!_dispatched)
|
_writable=false;
|
||||||
updateKey();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (l>0)
|
else if (l>0)
|
||||||
|
|
|
@ -188,20 +188,6 @@ public class HttpServerTestFixture
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a trust manager that does not validate certificate chains
|
|
||||||
public final static TrustManager[] __trustAllCerts = new TrustManager[] {
|
|
||||||
new X509TrustManager(){
|
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public void checkClientTrusted(
|
|
||||||
java.security.cert.X509Certificate[] certs, String authType) {
|
|
||||||
}
|
|
||||||
public void checkServerTrusted(
|
|
||||||
java.security.cert.X509Certificate[] certs, String authType) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public final static HostnameVerifier __hostnameverifier = new HostnameVerifier()
|
public final static HostnameVerifier __hostnameverifier = new HostnameVerifier()
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,8 @@ package org.eclipse.jetty.server.ssl;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.greaterThan;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -37,8 +38,6 @@ import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLSession;
|
import javax.net.ssl.SSLSession;
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -81,25 +80,6 @@ public class SSLEngineTest
|
||||||
|
|
||||||
private static final int BODY_SIZE=300;
|
private static final int BODY_SIZE=300;
|
||||||
|
|
||||||
private static final TrustManager[] s_dummyTrustManagers=new TrustManager[]
|
|
||||||
{
|
|
||||||
new X509TrustManager()
|
|
||||||
{
|
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static Server server;
|
private static Server server;
|
||||||
private static SslSelectChannelConnector connector;
|
private static SslSelectChannelConnector connector;
|
||||||
|
|
||||||
|
@ -134,7 +114,7 @@ public class SSLEngineTest
|
||||||
public void testBigResponse() throws Exception
|
public void testBigResponse() throws Exception
|
||||||
{
|
{
|
||||||
SSLContext ctx=SSLContext.getInstance("TLS");
|
SSLContext ctx=SSLContext.getInstance("TLS");
|
||||||
ctx.init(null,s_dummyTrustManagers,new java.security.SecureRandom());
|
ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());
|
||||||
|
|
||||||
int port=connector.getLocalPort();
|
int port=connector.getLocalPort();
|
||||||
|
|
||||||
|
@ -152,7 +132,7 @@ public class SSLEngineTest
|
||||||
|
|
||||||
String response = IO.toString(client.getInputStream());
|
String response = IO.toString(client.getInputStream());
|
||||||
|
|
||||||
assertTrue(response.length()>102400);
|
assertThat(response.length(),greaterThan(102400));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -164,7 +144,7 @@ public class SSLEngineTest
|
||||||
Socket[] client=new Socket[numConns];
|
Socket[] client=new Socket[numConns];
|
||||||
|
|
||||||
SSLContext ctx=SSLContext.getInstance("SSLv3");
|
SSLContext ctx=SSLContext.getInstance("SSLv3");
|
||||||
ctx.init(null,s_dummyTrustManagers,new java.security.SecureRandom());
|
ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());
|
||||||
|
|
||||||
int port=connector.getLocalPort();
|
int port=connector.getLocalPort();
|
||||||
|
|
||||||
|
@ -231,7 +211,7 @@ public class SSLEngineTest
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
SSLContext context = SSLContext.getInstance("SSL");
|
SSLContext context = SSLContext.getInstance("SSL");
|
||||||
context.init(null,s_dummyTrustManagers,new java.security.SecureRandom());
|
context.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());
|
||||||
HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
|
HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
|
||||||
|
|
||||||
URL url = new URL("https://localhost:"+connector.getLocalPort()+"/test");
|
URL url = new URL("https://localhost:"+connector.getLocalPort()+"/test");
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
||||||
{
|
{
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(__hostnameverifier);
|
HttpsURLConnection.setDefaultHostnameVerifier(__hostnameverifier);
|
||||||
SSLContext sc = SSLContext.getInstance("TLS");
|
SSLContext sc = SSLContext.getInstance("TLS");
|
||||||
sc.init(null, __trustAllCerts, new java.security.SecureRandom());
|
sc.init(null, SslContextFactory.TRUST_ALL_CERTS, new java.security.SecureRandom());
|
||||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
|
|
|
@ -37,22 +37,6 @@ public class SslRenegotiateTest
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(SslRenegotiateTest.class);
|
private static final Logger LOG = Log.getLogger(SslRenegotiateTest.class);
|
||||||
|
|
||||||
private static final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager()
|
|
||||||
{
|
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
} };
|
|
||||||
|
|
||||||
private ByteBuffer _outAppB;
|
private ByteBuffer _outAppB;
|
||||||
private ByteBuffer _outPacketB;
|
private ByteBuffer _outPacketB;
|
||||||
private ByteBuffer _inAppB;
|
private ByteBuffer _inAppB;
|
||||||
|
@ -110,7 +94,7 @@ public class SslRenegotiateTest
|
||||||
_socket.configureBlocking(true);
|
_socket.configureBlocking(true);
|
||||||
|
|
||||||
SSLContext context=SSLContext.getInstance("SSL");
|
SSLContext context=SSLContext.getInstance("SSL");
|
||||||
context.init( null, trustAllCerts, new java.security.SecureRandom() );
|
context.init( null, SslContextFactory.TRUST_ALL_CERTS, new java.security.SecureRandom() );
|
||||||
|
|
||||||
_engine = context.createSSLEngine();
|
_engine = context.createSSLEngine();
|
||||||
_engine.setUseClientMode(true);
|
_engine.setUseClientMode(true);
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.eclipse.jetty.servlets;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -215,10 +216,18 @@ public class CrossOriginFilter implements Filter
|
||||||
{
|
{
|
||||||
// WebSocket clients such as Chrome 5 implement a version of the WebSocket
|
// WebSocket clients such as Chrome 5 implement a version of the WebSocket
|
||||||
// protocol that does not accept extra response headers on the upgrade response
|
// protocol that does not accept extra response headers on the upgrade response
|
||||||
if ("Upgrade".equalsIgnoreCase(request.getHeader("Connection")) &&
|
for (Enumeration connections = request.getHeaders("Connection"); connections.hasMoreElements();)
|
||||||
"WebSocket".equalsIgnoreCase(request.getHeader("Upgrade")))
|
|
||||||
{
|
{
|
||||||
return false;
|
String connection = (String)connections.nextElement();
|
||||||
|
if ("Upgrade".equalsIgnoreCase(connection))
|
||||||
|
{
|
||||||
|
for (Enumeration upgrades = request.getHeaders("Upgrade"); upgrades.hasMoreElements();)
|
||||||
|
{
|
||||||
|
String upgrade = (String)upgrades.nextElement();
|
||||||
|
if ("WebSocket".equalsIgnoreCase(upgrade))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>jetty-test-helper</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -663,18 +663,19 @@ public class Main
|
||||||
{
|
{
|
||||||
StringBuilder cmd = new StringBuilder();
|
StringBuilder cmd = new StringBuilder();
|
||||||
cmd.append(findJavaBin());
|
cmd.append(findJavaBin());
|
||||||
for (String x : _jvmArgs)
|
for (String x : _jvmArgs) {
|
||||||
cmd.append(' ').append(x);
|
cmd.append(x);
|
||||||
cmd.append(" -Djetty.home=").append(_jettyHome);
|
}
|
||||||
|
cmd.append(" -Djetty.home=").append(escapeSpaces(_jettyHome));
|
||||||
for (String p : _sysProps)
|
for (String p : _sysProps)
|
||||||
{
|
{
|
||||||
cmd.append(" -D").append(p);
|
cmd.append(" -D").append(p);
|
||||||
String v = System.getProperty(p);
|
String v = System.getProperty(p);
|
||||||
if (v != null && v.length() > 0)
|
if (v != null && v.length() > 0)
|
||||||
cmd.append('=').append(v);
|
cmd.append("=").append(escapeSpaces(v));
|
||||||
}
|
}
|
||||||
cmd.append(" -cp ").append(classpath.toString());
|
cmd.append(" -cp ").append(classpath.toString());
|
||||||
cmd.append(" ").append(_config.getMainClassname());
|
cmd.append(" ").append(_config.getMainClassname());
|
||||||
|
|
||||||
// Check if we need to pass properties as a file
|
// Check if we need to pass properties as a file
|
||||||
Properties properties = Config.getProperties();
|
Properties properties = Config.getProperties();
|
||||||
|
@ -684,17 +685,20 @@ public class Main
|
||||||
if (!_dryRun)
|
if (!_dryRun)
|
||||||
prop_file.deleteOnExit();
|
prop_file.deleteOnExit();
|
||||||
properties.store(new FileOutputStream(prop_file),"start.jar properties");
|
properties.store(new FileOutputStream(prop_file),"start.jar properties");
|
||||||
cmd.append(" ").append(prop_file.getAbsolutePath());
|
cmd.append(" ").append(escapeSpaces(prop_file.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String xml : xmls)
|
for (String xml : xmls)
|
||||||
{
|
cmd.append(" ").append(escapeSpaces(xml));
|
||||||
cmd.append(' ').append(xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd.toString();
|
return cmd.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String escapeSpaces(String s)
|
||||||
|
{
|
||||||
|
return s.replace(" ","\\ ");
|
||||||
|
}
|
||||||
|
|
||||||
private String findJavaBin()
|
private String findJavaBin()
|
||||||
{
|
{
|
||||||
File javaHome = new File(System.getProperty("java.home"));
|
File javaHome = new File(System.getProperty("java.home"));
|
||||||
|
|
|
@ -13,12 +13,13 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.start;
|
package org.eclipse.jetty.start;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -34,18 +35,13 @@ public class MainTest
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
System.setProperty("jetty.home",this.getClass().getResource("/jetty.home").getFile());
|
File testJettyHome = MavenTestingUtils.getTestResourceDir("jetty.home");
|
||||||
|
System.setProperty("jetty.home",testJettyHome.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test method for {@link org.eclipse.jetty.start.StartIniParser#loadStartIni(java.lang.String)}.
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadStartIni() throws IOException
|
public void testLoadStartIni() throws IOException
|
||||||
{
|
{
|
||||||
URL startIni = this.getClass().getResource("/jetty.home/");
|
|
||||||
System.setProperty("jetty.home",startIni.getFile());
|
|
||||||
Main main = new Main();
|
Main main = new Main();
|
||||||
List<String> args = main.parseStartIniFiles();
|
List<String> args = main.parseStartIniFiles();
|
||||||
assertEquals("Expected 5 uncommented lines in start.ini",9,args.size());
|
assertEquals("Expected 5 uncommented lines in start.ini",9,args.size());
|
||||||
|
|
|
@ -462,52 +462,60 @@ public class UrlEncoded extends MultiMap implements Cloneable
|
||||||
int totalLength=0;
|
int totalLength=0;
|
||||||
while ((b=in.read())>=0)
|
while ((b=in.read())>=0)
|
||||||
{
|
{
|
||||||
switch ((char) b)
|
try
|
||||||
{
|
{
|
||||||
case '&':
|
switch ((char) b)
|
||||||
value = buffer.length()==0?"":buffer.toString();
|
{
|
||||||
buffer.reset();
|
case '&':
|
||||||
if (key != null)
|
value = buffer.length()==0?"":buffer.toString();
|
||||||
{
|
buffer.reset();
|
||||||
map.add(key,value);
|
if (key != null)
|
||||||
}
|
{
|
||||||
else if (value!=null&&value.length()>0)
|
map.add(key,value);
|
||||||
{
|
}
|
||||||
map.add(value,"");
|
else if (value!=null&&value.length()>0)
|
||||||
}
|
{
|
||||||
key = null;
|
map.add(value,"");
|
||||||
value=null;
|
}
|
||||||
if (maxKeys>0 && map.size()>maxKeys)
|
key = null;
|
||||||
{
|
value=null;
|
||||||
LOG.warn("maxFormKeys limit exceeded keys>{}",maxKeys);
|
if (maxKeys>0 && map.size()>maxKeys)
|
||||||
return;
|
{
|
||||||
}
|
LOG.warn("maxFormKeys limit exceeded keys>{}",maxKeys);
|
||||||
break;
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case '=':
|
case '=':
|
||||||
if (key!=null)
|
if (key!=null)
|
||||||
{
|
{
|
||||||
|
buffer.append((byte)b);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
key = buffer.toString();
|
||||||
|
buffer.reset();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '+':
|
||||||
|
buffer.append((byte)' ');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '%':
|
||||||
|
int dh=in.read();
|
||||||
|
int dl=in.read();
|
||||||
|
if (dh<0||dl<0)
|
||||||
|
break;
|
||||||
|
buffer.append((byte)((TypeUtil.convertHexDigit((byte)dh)<<4) + TypeUtil.convertHexDigit((byte)dl)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
buffer.append((byte)b);
|
buffer.append((byte)b);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
key = buffer.toString();
|
}
|
||||||
buffer.reset();
|
catch(NotUtf8Exception e)
|
||||||
break;
|
{
|
||||||
|
LOG.warn(e.toString());
|
||||||
case '+':
|
LOG.debug(e);
|
||||||
buffer.append((byte)' ');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '%':
|
|
||||||
int dh=in.read();
|
|
||||||
int dl=in.read();
|
|
||||||
if (dh<0||dl<0)
|
|
||||||
break;
|
|
||||||
buffer.append((byte)((TypeUtil.convertHexDigit((byte)dh)<<4) + TypeUtil.convertHexDigit((byte)dl)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
buffer.append((byte)b);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (maxLength>=0 && (++totalLength > maxLength))
|
if (maxLength>=0 && (++totalLength > maxLength))
|
||||||
throw new IllegalStateException("Form too large");
|
throw new IllegalStateException("Form too large");
|
||||||
|
|
|
@ -40,7 +40,7 @@ import java.io.IOException;
|
||||||
**/
|
**/
|
||||||
public abstract class Utf8Appendable
|
public abstract class Utf8Appendable
|
||||||
{
|
{
|
||||||
private final char REPLACEMENT = '\ufffd';
|
public static final char REPLACEMENT = '\ufffd';
|
||||||
private static final int UTF8_ACCEPT = 0;
|
private static final int UTF8_ACCEPT = 0;
|
||||||
private static final int UTF8_REJECT = 12;
|
private static final int UTF8_REJECT = 12;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class StdErrLog extends AbstractLogger
|
||||||
{
|
{
|
||||||
private static final String EOL = System.getProperty("line.separator");
|
private static final String EOL = System.getProperty("line.separator");
|
||||||
private static DateCache _dateCache;
|
private static DateCache _dateCache;
|
||||||
private static Properties __props = Log.__props;
|
private static final Properties __props = new Properties();
|
||||||
|
|
||||||
private final static boolean __source = Boolean.parseBoolean(Log.__props.getProperty("org.eclipse.jetty.util.log.SOURCE",
|
private final static boolean __source = Boolean.parseBoolean(Log.__props.getProperty("org.eclipse.jetty.util.log.SOURCE",
|
||||||
Log.__props.getProperty("org.eclipse.jetty.util.log.stderr.SOURCE","false")));
|
Log.__props.getProperty("org.eclipse.jetty.util.log.stderr.SOURCE","false")));
|
||||||
|
@ -45,6 +45,8 @@ public class StdErrLog extends AbstractLogger
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
|
__props.putAll(Log.__props);
|
||||||
|
|
||||||
String deprecatedProperties[] =
|
String deprecatedProperties[] =
|
||||||
{ "DEBUG", "org.eclipse.jetty.util.log.DEBUG", "org.eclipse.jetty.util.log.stderr.DEBUG" };
|
{ "DEBUG", "org.eclipse.jetty.util.log.DEBUG", "org.eclipse.jetty.util.log.stderr.DEBUG" };
|
||||||
|
|
||||||
|
@ -97,7 +99,8 @@ public class StdErrLog extends AbstractLogger
|
||||||
|
|
||||||
public StdErrLog(String name, Properties props)
|
public StdErrLog(String name, Properties props)
|
||||||
{
|
{
|
||||||
__props = props;
|
if (props!=null)
|
||||||
|
__props.putAll(props);
|
||||||
this._name = name == null?"":name;
|
this._name = name == null?"":name;
|
||||||
this._abbrevname = condensePackageString(this._name);
|
this._abbrevname = condensePackageString(this._name);
|
||||||
this._level = getLoggingLevel(props,this._name);
|
this._level = getLoggingLevel(props,this._name);
|
||||||
|
@ -603,7 +606,8 @@ public class StdErrLog extends AbstractLogger
|
||||||
|
|
||||||
public static void setProperties(Properties props)
|
public static void setProperties(Properties props)
|
||||||
{
|
{
|
||||||
__props = props;
|
__props.clear();
|
||||||
|
__props.putAll(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ignore(Throwable ignored)
|
public void ignore(Throwable ignored)
|
||||||
|
|
|
@ -71,6 +71,22 @@ import org.eclipse.jetty.util.security.Password;
|
||||||
*/
|
*/
|
||||||
public class SslContextFactory extends AbstractLifeCycle
|
public class SslContextFactory extends AbstractLifeCycle
|
||||||
{
|
{
|
||||||
|
public final static TrustManager[] TRUST_ALL_CERTS = new X509TrustManager[]{new X509TrustManager()
|
||||||
|
{
|
||||||
|
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
||||||
|
{
|
||||||
|
return new java.security.cert.X509Certificate[]{};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
private static final Logger LOG = Log.getLogger(SslContextFactory.class);
|
private static final Logger LOG = Log.getLogger(SslContextFactory.class);
|
||||||
|
|
||||||
public static final String DEFAULT_KEYMANAGERFACTORY_ALGORITHM =
|
public static final String DEFAULT_KEYMANAGERFACTORY_ALGORITHM =
|
||||||
|
@ -229,22 +245,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
{
|
{
|
||||||
LOG.debug("No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!");
|
LOG.debug("No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!");
|
||||||
// Create a trust manager that does not validate certificate chains
|
// Create a trust manager that does not validate certificate chains
|
||||||
TrustManager trustAllCerts = new X509TrustManager()
|
trust_managers = TRUST_ALL_CERTS;
|
||||||
{
|
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
trust_managers = new TrustManager[] { trustAllCerts };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
||||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.util;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
@ -69,12 +70,26 @@ public class DateCacheTest
|
||||||
|
|
||||||
// Test string is cached
|
// Test string is cached
|
||||||
dc = new DateCache();
|
dc = new DateCache();
|
||||||
String s1=dc.format(System.currentTimeMillis());
|
long now = 1000L*(System.currentTimeMillis()%1000L)+123;
|
||||||
dc.format(1);
|
// format a time for now
|
||||||
String s2=dc.format(System.currentTimeMillis());
|
String s1=dc.format(now);
|
||||||
dc.format(System.currentTimeMillis()+10*60*60);
|
|
||||||
String s3=dc.format(System.currentTimeMillis());
|
// format a time in the past (this should not reset cached date)
|
||||||
assertTrue(s1==s2 || s2==s3);
|
dc.format(now-2000);
|
||||||
|
|
||||||
|
// format a time a little later than now
|
||||||
|
String s2=dc.format(now+10);
|
||||||
|
|
||||||
|
// format a time in future (this should reset cached data)
|
||||||
|
dc.format(now+2000);
|
||||||
|
|
||||||
|
// format time a little later than now
|
||||||
|
String s3=dc.format(now+20);
|
||||||
|
|
||||||
|
assertEquals(s1,s2);
|
||||||
|
assertEquals(s2,s3);
|
||||||
|
assertTrue(s1==s2);
|
||||||
|
assertFalse(s2==s3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,6 @@ public class URLEncodedTest
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
@Test
|
@Test
|
||||||
public void testUtf8()
|
public void testUtf8()
|
||||||
|
@ -236,4 +235,21 @@ public class URLEncodedTest
|
||||||
String expected = new String(TypeUtil.fromHexString(hex),"utf-8");
|
String expected = new String(TypeUtil.fromHexString(hex),"utf-8");
|
||||||
assertEquals(expected,url_encoded.get("text"));
|
assertEquals(expected,url_encoded.get("text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
@Test
|
||||||
|
public void testNotUtf8() throws Exception
|
||||||
|
{
|
||||||
|
String query="name=X%c0%afZ";
|
||||||
|
|
||||||
|
MultiMap<String> map = new MultiMap<String>();
|
||||||
|
|
||||||
|
UrlEncoded.decodeUtf8To(query.getBytes(StringUtil.__ISO_8859_1),0,query.length(),map);
|
||||||
|
assertEquals("X"+Utf8Appendable.REPLACEMENT+Utf8Appendable.REPLACEMENT+"Z",map.getValue("name",0));
|
||||||
|
|
||||||
|
map.clear();
|
||||||
|
|
||||||
|
UrlEncoded.decodeUtf8To(new ByteArrayInputStream(query.getBytes(StringUtil.__ISO_8859_1)),map,100,2);
|
||||||
|
assertEquals("X"+Utf8Appendable.REPLACEMENT+Utf8Appendable.REPLACEMENT+"Z",map.getValue("name",0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,10 +157,12 @@
|
||||||
<param-name>useFileMappedBuffer</param-name>
|
<param-name>useFileMappedBuffer</param-name>
|
||||||
<param-value>true</param-value>
|
<param-value>true</param-value>
|
||||||
</init-param>
|
</init-param>
|
||||||
|
<!--
|
||||||
<init-param>
|
<init-param>
|
||||||
<param-name>resourceCache</param-name>
|
<param-name>resourceCache</param-name>
|
||||||
<param-value>resourceCache</param-value>
|
<param-value>resourceCache</param-value>
|
||||||
</init-param>
|
</init-param>
|
||||||
|
-->
|
||||||
<!--
|
<!--
|
||||||
<init-param>
|
<init-param>
|
||||||
<param-name>cacheControl</param-name>
|
<param-name>cacheControl</param-name>
|
||||||
|
|
|
@ -13,15 +13,11 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.test.monitor;
|
package org.eclipse.jetty.test.monitor;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import javax.management.MBeanServerConnection;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.client.ContentExchange;
|
import org.eclipse.jetty.client.ContentExchange;
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.http.HttpMethods;
|
import org.eclipse.jetty.http.HttpMethods;
|
||||||
|
@ -35,7 +31,6 @@ import org.eclipse.jetty.monitor.jmx.MonitorAction;
|
||||||
import org.eclipse.jetty.monitor.triggers.GreaterThanAttrEventTrigger;
|
import org.eclipse.jetty.monitor.triggers.GreaterThanAttrEventTrigger;
|
||||||
import org.eclipse.jetty.monitor.triggers.LessThanOrEqualToAttrEventTrigger;
|
import org.eclipse.jetty.monitor.triggers.LessThanOrEqualToAttrEventTrigger;
|
||||||
import org.eclipse.jetty.monitor.triggers.OrEventTrigger;
|
import org.eclipse.jetty.monitor.triggers.OrEventTrigger;
|
||||||
import org.eclipse.jetty.toolchain.jmx.JmxServiceConnection;
|
|
||||||
import org.eclipse.jetty.toolchain.test.JettyDistro;
|
import org.eclipse.jetty.toolchain.test.JettyDistro;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
@ -98,7 +93,7 @@ public class ProgramConfigTest
|
||||||
@Override
|
@Override
|
||||||
public void execute(EventTrigger trigger, EventState<?> state, long timestamp)
|
public void execute(EventTrigger trigger, EventState<?> state, long timestamp)
|
||||||
{
|
{
|
||||||
System.out.println(counter.incrementAndGet());
|
counter.incrementAndGet();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
JMXMonitor.addMonitorActions(action);
|
JMXMonitor.addMonitorActions(action);
|
||||||
|
@ -121,7 +116,6 @@ public class ProgramConfigTest
|
||||||
}
|
}
|
||||||
gate.await();
|
gate.await();
|
||||||
JMXMonitor.removeMonitorActions(action);
|
JMXMonitor.removeMonitorActions(action);
|
||||||
assertTrue(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void runTest(String requestUrl, long count)
|
protected static void runTest(String requestUrl, long count)
|
||||||
|
|
|
@ -32,6 +32,7 @@ import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An HTTPS Socket Impl
|
* An HTTPS Socket Impl
|
||||||
|
@ -45,26 +46,6 @@ public class HttpsSocketImpl implements HttpSocket
|
||||||
|
|
||||||
public HttpsSocketImpl() throws Exception
|
public HttpsSocketImpl() throws Exception
|
||||||
{
|
{
|
||||||
// Create loose SSL context.
|
|
||||||
// Create a trust manager that does not validate certificate
|
|
||||||
// chains
|
|
||||||
TrustManager[] trustAllCerts = new TrustManager[]
|
|
||||||
{ new X509TrustManager()
|
|
||||||
{
|
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
} };
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
HostnameVerifier hostnameVerifier = new HostnameVerifier()
|
HostnameVerifier hostnameVerifier = new HostnameVerifier()
|
||||||
{
|
{
|
||||||
|
@ -80,7 +61,7 @@ public class HttpsSocketImpl implements HttpSocket
|
||||||
{
|
{
|
||||||
// TODO real trust manager
|
// TODO real trust manager
|
||||||
this.sslContext = SSLContext.getInstance("TLS");
|
this.sslContext = SSLContext.getInstance("TLS");
|
||||||
sslContext.init(null,trustAllCerts,new java.security.SecureRandom());
|
sslContext.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue