Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project
This commit is contained in:
commit
5d9e08c098
|
@ -323,9 +323,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
{
|
||||
synchronized (this)
|
||||
{
|
||||
_writable=false;
|
||||
if (!_dispatched)
|
||||
updateKey();
|
||||
if (_dispatched)
|
||||
_writable=false;
|
||||
}
|
||||
}
|
||||
else if (l>0)
|
||||
|
@ -349,9 +348,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
{
|
||||
synchronized (this)
|
||||
{
|
||||
_writable=false;
|
||||
if (!_dispatched)
|
||||
updateKey();
|
||||
if (_dispatched)
|
||||
_writable=false;
|
||||
}
|
||||
}
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -20,7 +20,8 @@ package org.eclipse.jetty.server.ssl;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.IOException;
|
||||
|
@ -37,8 +38,6 @@ import javax.net.ssl.HostnameVerifier;
|
|||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -81,25 +80,6 @@ public class SSLEngineTest
|
|||
|
||||
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 SslSelectChannelConnector connector;
|
||||
|
||||
|
@ -134,7 +114,7 @@ public class SSLEngineTest
|
|||
public void testBigResponse() throws Exception
|
||||
{
|
||||
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();
|
||||
|
||||
|
@ -152,7 +132,7 @@ public class SSLEngineTest
|
|||
|
||||
String response = IO.toString(client.getInputStream());
|
||||
|
||||
assertTrue(response.length()>102400);
|
||||
assertThat(response.length(),greaterThan(102400));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -164,7 +144,7 @@ public class SSLEngineTest
|
|||
Socket[] client=new Socket[numConns];
|
||||
|
||||
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();
|
||||
|
||||
|
@ -231,7 +211,7 @@ public class SSLEngineTest
|
|||
server.start();
|
||||
|
||||
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());
|
||||
|
||||
URL url = new URL("https://localhost:"+connector.getLocalPort()+"/test");
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
|||
{
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(__hostnameverifier);
|
||||
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());
|
||||
}
|
||||
catch(Exception e)
|
||||
|
|
|
@ -37,22 +37,6 @@ public class SslRenegotiateTest
|
|||
{
|
||||
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 _outPacketB;
|
||||
private ByteBuffer _inAppB;
|
||||
|
@ -110,7 +94,7 @@ public class SslRenegotiateTest
|
|||
_socket.configureBlocking(true);
|
||||
|
||||
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.setUseClientMode(true);
|
||||
|
|
|
@ -664,39 +664,40 @@ public class Main
|
|||
StringBuilder cmd = new StringBuilder();
|
||||
cmd.append(findJavaBin());
|
||||
for (String x : _jvmArgs) {
|
||||
cmd.append(" \"").append(x).append("\"");
|
||||
cmd.append(x);
|
||||
}
|
||||
cmd.append(" \"-Djetty.home=").append(_jettyHome).append("\"");
|
||||
cmd.append(" -Djetty.home=").append(escapeSpaces(_jettyHome));
|
||||
for (String p : _sysProps)
|
||||
{
|
||||
cmd.append(" \"-D").append(p);
|
||||
cmd.append(" -D").append(p);
|
||||
String v = System.getProperty(p);
|
||||
if (v != null && v.length() > 0)
|
||||
cmd.append('=').append(v);
|
||||
cmd.append("\"");
|
||||
cmd.append("=").append(escapeSpaces(v));
|
||||
}
|
||||
cmd.append(" -cp \"").append(classpath.toString()).append("\"");
|
||||
cmd.append(" ").append(_config.getMainClassname());
|
||||
cmd.append(" -cp ").append(classpath.toString());
|
||||
cmd.append(" ").append(_config.getMainClassname());
|
||||
|
||||
// Check if we need to pass properties as a file
|
||||
Properties properties = Config.getProperties();
|
||||
if (properties.size() > 0)
|
||||
{
|
||||
File prop_file = File.createTempFile("start",".properties");
|
||||
if (!_dryRun) {
|
||||
if (!_dryRun)
|
||||
prop_file.deleteOnExit();
|
||||
}
|
||||
properties.store(new FileOutputStream(prop_file),"start.jar properties");
|
||||
cmd.append(" \"").append(prop_file.getAbsolutePath()).append("\"");
|
||||
cmd.append(" ").append(escapeSpaces(prop_file.getAbsolutePath()));
|
||||
}
|
||||
|
||||
for (String xml : xmls)
|
||||
{
|
||||
cmd.append(" \"").append(xml).append("\"");
|
||||
}
|
||||
cmd.append(" ").append(escapeSpaces(xml));
|
||||
|
||||
return cmd.toString();
|
||||
}
|
||||
|
||||
private static String escapeSpaces(String s)
|
||||
{
|
||||
return s.replace(" ","\\ ");
|
||||
}
|
||||
|
||||
private String findJavaBin()
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ public class StdErrLog extends AbstractLogger
|
|||
{
|
||||
private static final String EOL = System.getProperty("line.separator");
|
||||
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",
|
||||
Log.__props.getProperty("org.eclipse.jetty.util.log.stderr.SOURCE","false")));
|
||||
|
@ -45,6 +45,8 @@ public class StdErrLog extends AbstractLogger
|
|||
|
||||
static
|
||||
{
|
||||
__props.putAll(Log.__props);
|
||||
|
||||
String deprecatedProperties[] =
|
||||
{ "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)
|
||||
{
|
||||
__props = props;
|
||||
if (props!=null)
|
||||
__props.putAll(props);
|
||||
this._name = name == null?"":name;
|
||||
this._abbrevname = condensePackageString(this._name);
|
||||
this._level = getLoggingLevel(props,this._name);
|
||||
|
@ -603,7 +606,8 @@ public class StdErrLog extends AbstractLogger
|
|||
|
||||
public static void setProperties(Properties props)
|
||||
{
|
||||
__props = props;
|
||||
__props.clear();
|
||||
__props.putAll(props);
|
||||
}
|
||||
|
||||
public void ignore(Throwable ignored)
|
||||
|
|
|
@ -71,6 +71,22 @@ import org.eclipse.jetty.util.security.Password;
|
|||
*/
|
||||
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);
|
||||
|
||||
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!!!!!");
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
TrustManager trustAllCerts = 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)
|
||||
{
|
||||
}
|
||||
};
|
||||
trust_managers = new TrustManager[] { trustAllCerts };
|
||||
trust_managers = TRUST_ALL_CERTS;
|
||||
}
|
||||
|
||||
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.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
@ -69,12 +70,26 @@ public class DateCacheTest
|
|||
|
||||
// Test string is cached
|
||||
dc = new DateCache();
|
||||
String s1=dc.format(System.currentTimeMillis());
|
||||
dc.format(1);
|
||||
String s2=dc.format(System.currentTimeMillis());
|
||||
dc.format(System.currentTimeMillis()+10*60*60);
|
||||
String s3=dc.format(System.currentTimeMillis());
|
||||
assertTrue(s1==s2 || s2==s3);
|
||||
long now = 1000L*(System.currentTimeMillis()%1000L)+123;
|
||||
// format a time for now
|
||||
String s1=dc.format(now);
|
||||
|
||||
// format a time in the past (this should not reset cached date)
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -157,10 +157,12 @@
|
|||
<param-name>useFileMappedBuffer</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<!--
|
||||
<init-param>
|
||||
<param-name>resourceCache</param-name>
|
||||
<param-value>resourceCache</param-value>
|
||||
</init-param>
|
||||
-->
|
||||
<!--
|
||||
<init-param>
|
||||
<param-name>cacheControl</param-name>
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.net.ssl.X509TrustManager;
|
|||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
/**
|
||||
* An HTTPS Socket Impl
|
||||
|
@ -45,26 +46,6 @@ public class HttpsSocketImpl implements HttpSocket
|
|||
|
||||
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")
|
||||
HostnameVerifier hostnameVerifier = new HostnameVerifier()
|
||||
{
|
||||
|
@ -80,7 +61,7 @@ public class HttpsSocketImpl implements HttpSocket
|
|||
{
|
||||
// TODO real trust manager
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue