Merged branch 'jetty-9' into jetty-9-open-close.
This commit is contained in:
commit
37a7e5977d
|
@ -23,20 +23,22 @@ import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
import org.eclipse.jetty.webapp.FragmentDescriptor;
|
import org.eclipse.jetty.webapp.FragmentDescriptor;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestAnnotationConfiguration
|
* TestAnnotationConfiguration
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TestAnnotationConfiguration extends TestCase
|
public class TestAnnotationConfiguration
|
||||||
{
|
{
|
||||||
public void testGetFragmentFromJar ()
|
@Test
|
||||||
throws Exception
|
public void testGetFragmentFromJar() throws Exception
|
||||||
{
|
{
|
||||||
String dir = System.getProperty("basedir", ".");
|
String dir = System.getProperty("basedir", ".");
|
||||||
File file = new File(dir);
|
File file = new File(dir);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
|
||||||
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
|
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.eclipse.jetty.security.ConstraintAware;
|
import org.eclipse.jetty.security.ConstraintAware;
|
||||||
import org.eclipse.jetty.security.ConstraintMapping;
|
import org.eclipse.jetty.security.ConstraintMapping;
|
||||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||||
|
@ -35,8 +34,15 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.servlet.ServletMapping;
|
import org.eclipse.jetty.servlet.ServletMapping;
|
||||||
import org.eclipse.jetty.util.security.Constraint;
|
import org.eclipse.jetty.util.security.Constraint;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestSecurityAnnotationConversions extends TestCase
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
public class TestSecurityAnnotationConversions
|
||||||
{
|
{
|
||||||
@ServletSecurity(value=@HttpConstraint(value=EmptyRoleSemantic.DENY))
|
@ServletSecurity(value=@HttpConstraint(value=EmptyRoleSemantic.DENY))
|
||||||
public static class DenyServlet extends HttpServlet
|
public static class DenyServlet extends HttpServlet
|
||||||
|
@ -65,8 +71,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDenyAllOnClass ()
|
@Test
|
||||||
throws Exception
|
public void testDenyAllOnClass() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
WebAppContext wac = makeWebAppContext(DenyServlet.class.getCanonicalName(), "denyServlet", new String[]{"/foo/*", "*.foo"});
|
WebAppContext wac = makeWebAppContext(DenyServlet.class.getCanonicalName(), "denyServlet", new String[]{"/foo/*", "*.foo"});
|
||||||
|
@ -97,9 +103,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
||||||
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPermitAll()
|
public void testPermitAll() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
//Assume we found 1 servlet with a @ServletSecurity security annotation
|
//Assume we found 1 servlet with a @ServletSecurity security annotation
|
||||||
WebAppContext wac = makeWebAppContext(PermitServlet.class.getCanonicalName(), "permitServlet", new String[]{"/foo/*", "*.foo"});
|
WebAppContext wac = makeWebAppContext(PermitServlet.class.getCanonicalName(), "permitServlet", new String[]{"/foo/*", "*.foo"});
|
||||||
|
@ -129,8 +134,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
||||||
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRolesAllowedWithTransportGuarantee ()
|
@Test
|
||||||
throws Exception
|
public void testRolesAllowedWithTransportGuarantee() throws Exception
|
||||||
{
|
{
|
||||||
//Assume we found 1 servlet with annotation with roles defined and
|
//Assume we found 1 servlet with annotation with roles defined and
|
||||||
//and a TransportGuarantee
|
//and a TransportGuarantee
|
||||||
|
@ -161,9 +166,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
||||||
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMethodAnnotation ()
|
public void testMethodAnnotation() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
//ServletSecurity annotation with HttpConstraint of TransportGuarantee.CONFIDENTIAL, and a list of rolesAllowed, and
|
//ServletSecurity annotation with HttpConstraint of TransportGuarantee.CONFIDENTIAL, and a list of rolesAllowed, and
|
||||||
//a HttpMethodConstraint for GET method that permits all and has TransportGuarantee.NONE (ie is default)
|
//a HttpMethodConstraint for GET method that permits all and has TransportGuarantee.NONE (ie is default)
|
||||||
|
@ -209,8 +213,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
||||||
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMethodAnnotation2 ()
|
@Test
|
||||||
throws Exception
|
public void testMethodAnnotation2() throws Exception
|
||||||
{
|
{
|
||||||
//A ServletSecurity annotation that has HttpConstraint of CONFIDENTIAL with defined roles, but a
|
//A ServletSecurity annotation that has HttpConstraint of CONFIDENTIAL with defined roles, but a
|
||||||
//HttpMethodConstraint for GET that permits all, but also requires CONFIDENTIAL
|
//HttpMethodConstraint for GET that permits all, but also requires CONFIDENTIAL
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.eclipse.jetty.client.api.CookieStore;
|
||||||
import org.eclipse.jetty.client.api.Destination;
|
import org.eclipse.jetty.client.api.Destination;
|
||||||
import org.eclipse.jetty.client.api.Request;
|
import org.eclipse.jetty.client.api.Request;
|
||||||
import org.eclipse.jetty.client.api.Response;
|
import org.eclipse.jetty.client.api.Response;
|
||||||
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||||
|
@ -223,6 +224,16 @@ public class HttpClient extends AggregateLifeCycle
|
||||||
return newRequest(uri).send();
|
return newRequest(uri).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Request POST(String uri)
|
||||||
|
{
|
||||||
|
return POST(URI.create(uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request POST(URI uri)
|
||||||
|
{
|
||||||
|
return newRequest(uri).method(HttpMethod.POST);
|
||||||
|
}
|
||||||
|
|
||||||
public Request newRequest(String host, int port)
|
public Request newRequest(String host, int port)
|
||||||
{
|
{
|
||||||
return newRequest(URI.create(address("http", host, port)));
|
return newRequest(URI.create(address("http", host, port)));
|
||||||
|
@ -280,7 +291,7 @@ public class HttpClient extends AggregateLifeCycle
|
||||||
return new ArrayList<Destination>(destinations.values());
|
return new ArrayList<Destination>(destinations.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(Request request, Response.Listener listener)
|
protected void send(Request request, Response.Listener listener)
|
||||||
{
|
{
|
||||||
String scheme = request.scheme().toLowerCase();
|
String scheme = request.scheme().toLowerCase();
|
||||||
if (!Arrays.asList("http", "https").contains(scheme))
|
if (!Arrays.asList("http", "https").contains(scheme))
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.client;
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,13 +32,16 @@ import org.eclipse.jetty.client.api.Connection;
|
||||||
import org.eclipse.jetty.client.api.ContentProvider;
|
import org.eclipse.jetty.client.api.ContentProvider;
|
||||||
import org.eclipse.jetty.client.api.Request;
|
import org.eclipse.jetty.client.api.Request;
|
||||||
import org.eclipse.jetty.client.api.Response;
|
import org.eclipse.jetty.client.api.Response;
|
||||||
|
import org.eclipse.jetty.client.util.StringContentProvider;
|
||||||
import org.eclipse.jetty.http.HttpCookie;
|
import org.eclipse.jetty.http.HttpCookie;
|
||||||
import org.eclipse.jetty.http.HttpFields;
|
import org.eclipse.jetty.http.HttpFields;
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpMethod;
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
import org.eclipse.jetty.http.HttpVersion;
|
import org.eclipse.jetty.http.HttpVersion;
|
||||||
|
import org.eclipse.jetty.http.MimeTypes;
|
||||||
import org.eclipse.jetty.io.AbstractConnection;
|
import org.eclipse.jetty.io.AbstractConnection;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
|
import org.eclipse.jetty.util.Fields;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -120,6 +126,7 @@ public class HttpConnection extends AbstractConnection implements Connection
|
||||||
if (request.idleTimeout() <= 0)
|
if (request.idleTimeout() <= 0)
|
||||||
request.idleTimeout(client.getIdleTimeout());
|
request.idleTimeout(client.getIdleTimeout());
|
||||||
|
|
||||||
|
HttpMethod method = request.method();
|
||||||
HttpVersion version = request.version();
|
HttpVersion version = request.version();
|
||||||
HttpFields headers = request.headers();
|
HttpFields headers = request.headers();
|
||||||
ContentProvider content = request.content();
|
ContentProvider content = request.content();
|
||||||
|
@ -127,7 +134,64 @@ public class HttpConnection extends AbstractConnection implements Connection
|
||||||
// Make sure the path is there
|
// Make sure the path is there
|
||||||
String path = request.path();
|
String path = request.path();
|
||||||
if (path.matches("\\s*"))
|
if (path.matches("\\s*"))
|
||||||
request.path("/");
|
{
|
||||||
|
path = "/";
|
||||||
|
request.path(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Fields fields = request.params();
|
||||||
|
if (!fields.isEmpty())
|
||||||
|
{
|
||||||
|
StringBuilder params = new StringBuilder();
|
||||||
|
for (Iterator<Fields.Field> fieldIterator = fields.iterator(); fieldIterator.hasNext();)
|
||||||
|
{
|
||||||
|
Fields.Field field = fieldIterator.next();
|
||||||
|
String[] values = field.values();
|
||||||
|
for (int i = 0; i < values.length; ++i)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
params.append("&");
|
||||||
|
params.append(field.name()).append("=");
|
||||||
|
params.append(urlEncode(values[i]));
|
||||||
|
}
|
||||||
|
if (fieldIterator.hasNext())
|
||||||
|
params.append("&");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Behave as a GET, adding the params to the path, if it's a POST with some content
|
||||||
|
if (method == HttpMethod.POST && request.content() != null)
|
||||||
|
method = HttpMethod.GET;
|
||||||
|
|
||||||
|
switch (method)
|
||||||
|
{
|
||||||
|
case GET:
|
||||||
|
{
|
||||||
|
path += "?";
|
||||||
|
path += params.toString();
|
||||||
|
request.path(path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case POST:
|
||||||
|
{
|
||||||
|
request.header(HttpHeader.CONTENT_TYPE.asString(), MimeTypes.Type.FORM_ENCODED.asString());
|
||||||
|
request.content(new StringContentProvider(params.toString()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are HTTP 1.1, add the Host header
|
||||||
|
if (version.getVersion() > 10)
|
||||||
|
{
|
||||||
|
if (!headers.containsKey(HttpHeader.HOST.asString()))
|
||||||
|
{
|
||||||
|
String value = request.host();
|
||||||
|
int port = request.port();
|
||||||
|
if (port > 0)
|
||||||
|
value += ":" + port;
|
||||||
|
headers.put(HttpHeader.HOST, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add content headers
|
// Add content headers
|
||||||
if (content != null)
|
if (content != null)
|
||||||
|
@ -181,18 +245,18 @@ public class HttpConnection extends AbstractConnection implements Connection
|
||||||
headers.put(HttpHeader.ACCEPT_ENCODING, value.toString());
|
headers.put(HttpHeader.ACCEPT_ENCODING, value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we are HTTP 1.1, add the Host header
|
private String urlEncode(String value)
|
||||||
if (version.getVersion() > 10)
|
{
|
||||||
|
String encoding = "UTF-8";
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!headers.containsKey(HttpHeader.HOST.asString()))
|
return URLEncoder.encode(value, encoding);
|
||||||
{
|
}
|
||||||
String value = request.host();
|
catch (UnsupportedEncodingException e)
|
||||||
int port = request.port();
|
{
|
||||||
if (port > 0)
|
throw new UnsupportedCharsetException(encoding);
|
||||||
value += ":" + port;
|
|
||||||
headers.put(HttpHeader.HOST, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.client;
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -33,7 +32,6 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
import org.eclipse.jetty.util.Callback;
|
import org.eclipse.jetty.util.Callback;
|
||||||
import org.eclipse.jetty.util.Fields;
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -95,27 +93,7 @@ public class HttpSender
|
||||||
{
|
{
|
||||||
case NEED_INFO:
|
case NEED_INFO:
|
||||||
{
|
{
|
||||||
String path = request.path();
|
info = new HttpGenerator.RequestInfo(request.version(), request.headers(), contentLength, request.method().asString(), request.path());
|
||||||
Fields fields = request.params();
|
|
||||||
if (!fields.isEmpty())
|
|
||||||
{
|
|
||||||
path += "?";
|
|
||||||
for (Iterator<Fields.Field> fieldIterator = fields.iterator(); fieldIterator.hasNext();)
|
|
||||||
{
|
|
||||||
Fields.Field field = fieldIterator.next();
|
|
||||||
String[] values = field.values();
|
|
||||||
for (int i = 0; i < values.length; ++i)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
|
||||||
path += "&";
|
|
||||||
path += field.name() + "=";
|
|
||||||
path += URLEncoder.encode(values[i], "UTF-8");
|
|
||||||
}
|
|
||||||
if (fieldIterator.hasNext())
|
|
||||||
path += "&";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
info = new HttpGenerator.RequestInfo(request.version(), request.headers(), contentLength, request.method().asString(), path);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NEED_HEADER:
|
case NEED_HEADER:
|
||||||
|
|
|
@ -15,14 +15,20 @@
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
package org.eclipse.jetty.ant;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
package org.eclipse.jetty.client.util;
|
||||||
|
|
||||||
public class JettyRunTaskTest extends TestCase
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
public class StringContentProvider extends BytesContentProvider
|
||||||
{
|
{
|
||||||
public void testInit()
|
public StringContentProvider(String content)
|
||||||
{
|
{
|
||||||
|
this(content, "UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringContentProvider(String content, String encoding)
|
||||||
|
{
|
||||||
|
super(content.getBytes(Charset.forName(encoding)));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -67,7 +67,7 @@ public class HttpClientLoadTest extends AbstractHttpClientServerTest
|
||||||
client.setMaxQueueSizePerAddress(1024 * 1024);
|
client.setMaxQueueSizePerAddress(1024 * 1024);
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int iterations = 1000;
|
int iterations = 200;
|
||||||
CountDownLatch latch = new CountDownLatch(iterations);
|
CountDownLatch latch = new CountDownLatch(iterations);
|
||||||
List<String> failures = new ArrayList<>();
|
List<String> failures = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class HttpClientLoadTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
testThread.interrupt();
|
testThread.interrupt();
|
||||||
}
|
}
|
||||||
}, iterations * ("http".equalsIgnoreCase(scheme) ? 10 : 500), TimeUnit.MILLISECONDS);
|
}, iterations * ("http".equalsIgnoreCase(scheme) ? 10 : 1000), TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
long begin = System.nanoTime();
|
long begin = System.nanoTime();
|
||||||
for (int i = 0; i < iterations; ++i)
|
for (int i = 0; i < iterations; ++i)
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.jetty.client.api.Destination;
|
||||||
import org.eclipse.jetty.client.api.Request;
|
import org.eclipse.jetty.client.api.Request;
|
||||||
import org.eclipse.jetty.client.api.Response;
|
import org.eclipse.jetty.client.api.Response;
|
||||||
import org.eclipse.jetty.client.api.Result;
|
import org.eclipse.jetty.client.api.Result;
|
||||||
|
import org.eclipse.jetty.client.util.BytesContentProvider;
|
||||||
import org.eclipse.jetty.http.HttpCookie;
|
import org.eclipse.jetty.http.HttpCookie;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
|
@ -214,6 +215,67 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(value11 + value12 + value2, content);
|
Assert.assertEquals(value11 + value12 + value2, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_POST_WithParameters() throws Exception
|
||||||
|
{
|
||||||
|
final String paramName = "a";
|
||||||
|
final String paramValue = "\u20AC";
|
||||||
|
start(new AbstractHandler()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
|
{
|
||||||
|
baseRequest.setHandled(true);
|
||||||
|
String value = request.getParameter(paramName);
|
||||||
|
if (paramValue.equals(value))
|
||||||
|
{
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setContentType("text/plain");
|
||||||
|
response.getOutputStream().print(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ContentResponse response = client.POST(scheme + "://localhost:" + connector.getLocalPort())
|
||||||
|
.param(paramName, paramValue).send().get(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
Assert.assertNotNull(response);
|
||||||
|
Assert.assertEquals(200, response.status());
|
||||||
|
Assert.assertEquals(paramValue, new String(response.content(), "UTF-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_POST_WithParameters_WithContent() throws Exception
|
||||||
|
{
|
||||||
|
final byte[] content = {0, 1, 2, 3};
|
||||||
|
final String paramName = "a";
|
||||||
|
final String paramValue = "\u20AC";
|
||||||
|
start(new AbstractHandler()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
|
{
|
||||||
|
baseRequest.setHandled(true);
|
||||||
|
String value = request.getParameter(paramName);
|
||||||
|
if (paramValue.equals(value))
|
||||||
|
{
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setContentType("text/plain");
|
||||||
|
response.getOutputStream().write(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ContentResponse response = client.POST(scheme + "://localhost:" + connector.getLocalPort() + "/?b=1")
|
||||||
|
.param(paramName, paramValue)
|
||||||
|
.content(new BytesContentProvider(content))
|
||||||
|
.send().get(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
Assert.assertNotNull(response);
|
||||||
|
Assert.assertEquals(200, response.status());
|
||||||
|
Assert.assertArrayEquals(content, response.content());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_QueuedRequest_IsSent_WhenPreviousRequestSucceeded() throws Exception
|
public void test_QueuedRequest_IsSent_WhenPreviousRequestSucceeded() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,8 +20,8 @@ package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.http.HttpCookie;
|
import org.eclipse.jetty.http.HttpCookie;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class HttpCookieParserTest
|
public class HttpCookieParserTest
|
||||||
|
|
|
@ -96,6 +96,13 @@ public class Usage
|
||||||
Assert.assertEquals(200, response.status());
|
Assert.assertEquals(200, response.status());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPOSTWithParams() throws Exception
|
||||||
|
{
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.POST("http://localhost:8080").param("a", "\u20AC").send();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequestListener() throws Exception
|
public void testRequestListener() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,10 +18,9 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.deploy.graph;
|
package org.eclipse.jetty.deploy.graph;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class GraphTest
|
public class GraphTest
|
||||||
{
|
{
|
||||||
final Node nodeA = new Node("A");
|
final Node nodeA = new Node("A");
|
||||||
|
@ -37,7 +36,7 @@ public class GraphTest
|
||||||
|
|
||||||
Path path = new Path();
|
Path path = new Path();
|
||||||
|
|
||||||
Assert.assertEquals(0,path.nodes());
|
Assert.assertEquals(0, path.nodes());
|
||||||
Assert.assertEquals(null,path.firstNode());
|
Assert.assertEquals(null,path.firstNode());
|
||||||
Assert.assertEquals(null,path.lastNode());
|
Assert.assertEquals(null,path.lastNode());
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,21 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.http;
|
package org.eclipse.jetty.http;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PathMapTest extends TestCase
|
public class PathMapTest
|
||||||
{
|
{
|
||||||
@Test
|
@Test
|
||||||
public void testPathMap() throws Exception
|
public void testPathMap() throws Exception
|
||||||
{
|
{
|
||||||
PathMap p = new PathMap();
|
PathMap<String> p = new PathMap<>();
|
||||||
|
|
||||||
p.put("/abs/path", "1");
|
p.put("/abs/path", "1");
|
||||||
p.put("/abs/path/longer", "2");
|
p.put("/abs/path/longer", "2");
|
||||||
|
|
|
@ -34,10 +34,10 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
import static org.hamcrest.Matchers.greaterThan;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
|
@ -27,9 +27,9 @@ import java.nio.channels.SocketChannel;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static junit.framework.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
|
@ -43,6 +42,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
import org.eclipse.jetty.util.thread.TimerScheduler;
|
import org.eclipse.jetty.util.thread.TimerScheduler;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -232,7 +232,7 @@ public class SslConnectionTest
|
||||||
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
|
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int len=client.getInputStream().read(buffer);
|
int len=client.getInputStream().read(buffer);
|
||||||
Assert.assertEquals(10,len);
|
Assert.assertEquals(10, len);
|
||||||
Assert.assertEquals("HelloWorld",new String(buffer,0,len,StringUtil.__UTF8_CHARSET));
|
Assert.assertEquals("HelloWorld",new String(buffer,0,len,StringUtil.__UTF8_CHARSET));
|
||||||
|
|
||||||
client.close();
|
client.close();
|
||||||
|
|
|
@ -45,12 +45,12 @@ import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
import static junit.framework.Assert.assertFalse;
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ public class WriteFlusherTest
|
||||||
public void testConcurrentAccessToWriteAndOnFail() throws Exception
|
public void testConcurrentAccessToWriteAndOnFail() throws Exception
|
||||||
{
|
{
|
||||||
// TODO review this test - It was changed for the boolean flush return, but not really well inspected
|
// TODO review this test - It was changed for the boolean flush return, but not really well inspected
|
||||||
|
|
||||||
final CountDownLatch failedCalledLatch = new CountDownLatch(1);
|
final CountDownLatch failedCalledLatch = new CountDownLatch(1);
|
||||||
final CountDownLatch writeCalledLatch = new CountDownLatch(1);
|
final CountDownLatch writeCalledLatch = new CountDownLatch(1);
|
||||||
final CountDownLatch writeCompleteLatch = new CountDownLatch(1);
|
final CountDownLatch writeCompleteLatch = new CountDownLatch(1);
|
||||||
|
@ -377,13 +377,13 @@ public class WriteFlusherTest
|
||||||
executor.submit(new Writer(writeFlusher, callback));
|
executor.submit(new Writer(writeFlusher, callback));
|
||||||
assertThat("Write has been called.", writeCalledLatch.await(5, TimeUnit.SECONDS), is(true));
|
assertThat("Write has been called.", writeCalledLatch.await(5, TimeUnit.SECONDS), is(true));
|
||||||
executor.submit(new FailedCaller(writeFlusher, failedCalledLatch)).get();
|
executor.submit(new FailedCaller(writeFlusher, failedCalledLatch)).get();
|
||||||
|
|
||||||
|
|
||||||
// callback failed is NOT called because in WRITING state failed() doesn't know about the callback. However
|
// callback failed is NOT called because in WRITING state failed() doesn't know about the callback. However
|
||||||
// either the write succeeds or we get an IOException which will call callback.failed()
|
// either the write succeeds or we get an IOException which will call callback.failed()
|
||||||
assertThat("write complete", writeCompleteLatch.await(5, TimeUnit.SECONDS), is(true));
|
assertThat("write complete", writeCompleteLatch.await(5, TimeUnit.SECONDS), is(true));
|
||||||
|
|
||||||
|
|
||||||
// in this testcase we more or less emulate that the write has successfully finished and we return from
|
// in this testcase we more or less emulate that the write has successfully finished and we return from
|
||||||
// EndPoint.flush() back to WriteFlusher.write(). Then someone calls failed. So the callback should have been
|
// EndPoint.flush() back to WriteFlusher.write(). Then someone calls failed. So the callback should have been
|
||||||
// completed.
|
// completed.
|
||||||
|
@ -570,7 +570,7 @@ public class WriteFlusherTest
|
||||||
{
|
{
|
||||||
byteBuffer.position(byteBuffer.limit());
|
byteBuffer.position(byteBuffer.limit());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ByteBuffer b: buffers)
|
for (ByteBuffer b: buffers)
|
||||||
if (BufferUtil.hasContent(b))
|
if (BufferUtil.hasContent(b))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -25,11 +25,11 @@ import javax.management.MBeanOperationInfo;
|
||||||
import javax.management.MBeanParameterInfo;
|
import javax.management.MBeanParameterInfo;
|
||||||
|
|
||||||
import com.acme.Derived;
|
import com.acme.Derived;
|
||||||
import junit.framework.Assert;
|
|
||||||
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.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -27,8 +27,8 @@ import java.nio.channels.FileChannel;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.plugins.model.Plugin;
|
import org.eclipse.jetty.plugins.model.Plugin;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
|
@ -25,9 +25,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.util.security.Credential;
|
import org.eclipse.jetty.util.security.Credential;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -18,23 +18,22 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.server;
|
package org.eclipse.jetty.server;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.http.HttpURI;
|
import org.eclipse.jetty.http.HttpURI;
|
||||||
import org.eclipse.jetty.util.MultiMap;
|
import org.eclipse.jetty.util.MultiMap;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class HttpURITest
|
public class HttpURITest
|
||||||
{
|
{
|
||||||
private final String[][] partial_tests=
|
private final String[][] partial_tests=
|
||||||
|
|
|
@ -20,15 +20,13 @@ package org.eclipse.jetty.server.handler;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Connector;
|
import org.eclipse.jetty.server.Connector;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -37,14 +35,13 @@ import org.junit.Test;
|
||||||
*
|
*
|
||||||
* TODO: increase the testing going on here
|
* TODO: increase the testing going on here
|
||||||
*/
|
*/
|
||||||
public class ResourceHandlerTest extends TestCase
|
public class ResourceHandlerTest
|
||||||
{
|
{
|
||||||
private static Server _server;
|
private static Server _server;
|
||||||
private static ServerConnector _connector;
|
private static ServerConnector _connector;
|
||||||
private static ContextHandler _contextHandler;
|
private static ContextHandler _contextHandler;
|
||||||
private static ResourceHandler _resourceHandler;
|
private static ResourceHandler _resourceHandler;
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -60,7 +57,6 @@ public class ResourceHandlerTest extends TestCase
|
||||||
_server.start();
|
_server.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -78,5 +74,4 @@ public class ResourceHandlerTest extends TestCase
|
||||||
|
|
||||||
Assert.assertNotNull("missing jetty.css" , sr.getString("/resource/jetty-dir.css"));
|
Assert.assertNotNull("missing jetty.css" , sr.getString("/resource/jetty-dir.css"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -37,38 +33,19 @@ import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
|
||||||
* HttpServer Tester.
|
|
||||||
*/
|
|
||||||
public class SSLCloseTest
|
public class SSLCloseTest
|
||||||
{
|
{
|
||||||
private static class CredulousTM implements TrustManager, X509TrustManager
|
|
||||||
{
|
|
||||||
public X509Certificate[] getAcceptedIssuers()
|
|
||||||
{
|
|
||||||
return new X509Certificate[]{};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final TrustManager[] s_dummyTrustManagers=new TrustManager[] { new CredulousTM() };
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClose() throws Exception
|
public void testClose() throws Exception
|
||||||
{
|
{
|
||||||
String keystore = System.getProperty("user.dir")+File.separator+"src"+File.separator+"test"+File.separator+"resources"+File.separator+"keystore";
|
File keystore = MavenTestingUtils.getTestResourceFile("keystore");
|
||||||
SslContextFactory sslContextFactory = new SslContextFactory();
|
SslContextFactory sslContextFactory = new SslContextFactory();
|
||||||
sslContextFactory.setKeyStorePath(keystore);
|
sslContextFactory.setKeyStoreResource(Resource.newResource(keystore));
|
||||||
sslContextFactory.setKeyStorePassword("storepwd");
|
sslContextFactory.setKeyStorePassword("storepwd");
|
||||||
sslContextFactory.setKeyManagerPassword("keypwd");
|
sslContextFactory.setKeyManagerPassword("keypwd");
|
||||||
|
|
||||||
|
@ -81,7 +58,7 @@ public class SSLCloseTest
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
@ -109,7 +86,6 @@ public class SSLCloseTest
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class WriteHandler extends AbstractHandler
|
private static class WriteHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
|
|
|
@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpServletResponseWrapper;
|
import javax.servlet.http.HttpServletResponseWrapper;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.server.Connector;
|
import org.eclipse.jetty.server.Connector;
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.LocalConnector;
|
import org.eclipse.jetty.server.LocalConnector;
|
||||||
|
@ -38,6 +37,7 @@ import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||||
import org.eclipse.jetty.server.handler.HandlerList;
|
import org.eclipse.jetty.server.handler.HandlerList;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class AsyncContextTest
|
||||||
|
|
||||||
BufferedReader br = parseHeader(responseString);
|
BufferedReader br = parseHeader(responseString);
|
||||||
|
|
||||||
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath",br.readLine());
|
Assert.assertEquals("servlet gets right path", "doGet:getServletPath:/servletPath", br.readLine());
|
||||||
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath",br.readLine());
|
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath",br.readLine());
|
||||||
Assert.assertEquals("async context gets right path in async","async:run:attr:servletPath:/servletPath",br.readLine());
|
Assert.assertEquals("async context gets right path in async","async:run:attr:servletPath:/servletPath",br.readLine());
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ public class AsyncContextTest
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
|
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
if (((Request)request).getDispatcherType() == DispatcherType.ASYNC)
|
if (request.getDispatcherType() == DispatcherType.ASYNC)
|
||||||
{
|
{
|
||||||
response.getOutputStream().print("Dispatched back to ForwardingServlet");
|
response.getOutputStream().print("Dispatched back to ForwardingServlet");
|
||||||
}
|
}
|
||||||
|
@ -310,8 +310,6 @@ public class AsyncContextTest
|
||||||
asyncContext.start(new AsyncRunnable(asyncContext));
|
asyncContext.start(new AsyncRunnable(asyncContext));
|
||||||
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +324,6 @@ public class AsyncContextTest
|
||||||
AsyncContext asyncContext = request.startAsync(request, response);
|
AsyncContext asyncContext = request.startAsync(request, response);
|
||||||
response.getOutputStream().print("doGet:async:getServletPath:" + ((HttpServletRequest)asyncContext.getRequest()).getServletPath() + "\n");
|
response.getOutputStream().print("doGet:async:getServletPath:" + ((HttpServletRequest)asyncContext.getRequest()).getServletPath() + "\n");
|
||||||
asyncContext.start(new AsyncRunnable(asyncContext));
|
asyncContext.start(new AsyncRunnable(asyncContext));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ import javax.servlet.http.HttpServletRequestWrapper;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpServletResponseWrapper;
|
import javax.servlet.http.HttpServletResponseWrapper;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.server.Dispatcher;
|
import org.eclipse.jetty.server.Dispatcher;
|
||||||
import org.eclipse.jetty.server.LocalConnector;
|
import org.eclipse.jetty.server.LocalConnector;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
@ -51,6 +50,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
|
||||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||||
import org.eclipse.jetty.security.SecurityHandler;
|
import org.eclipse.jetty.security.SecurityHandler;
|
||||||
import org.eclipse.jetty.server.LocalConnector;
|
import org.eclipse.jetty.server.LocalConnector;
|
||||||
|
@ -35,6 +34,7 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||||
import org.eclipse.jetty.server.session.SessionHandler;
|
import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public class ServletContextHandlerTest
|
||||||
err.append("\n").append(response);
|
err.append("\n").append(response);
|
||||||
|
|
||||||
System.err.println(err);
|
System.err.println(err);
|
||||||
throw new AssertionFailedError(err.toString());
|
Assert.fail(err.toString());
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.client.api.ContentResponse;
|
import org.eclipse.jetty.client.api.ContentResponse;
|
||||||
import org.eclipse.jetty.client.api.Response;
|
import org.eclipse.jetty.client.api.Response;
|
||||||
|
@ -51,6 +50,7 @@ import org.eclipse.jetty.spdy.api.Stream;
|
||||||
import org.eclipse.jetty.spdy.api.StreamFrameListener;
|
import org.eclipse.jetty.spdy.api.StreamFrameListener;
|
||||||
import org.eclipse.jetty.spdy.api.SynInfo;
|
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||||
import org.eclipse.jetty.util.Fields;
|
import org.eclipse.jetty.util.Fields;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,10 @@ package org.eclipse.jetty.spdy.server;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.spdy.api.GoAwayInfo;
|
import org.eclipse.jetty.spdy.api.GoAwayInfo;
|
||||||
import org.eclipse.jetty.spdy.api.Session;
|
import org.eclipse.jetty.spdy.api.Session;
|
||||||
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
|
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class SPDYClientFactoryTest extends AbstractTest
|
public class SPDYClientFactoryTest extends AbstractTest
|
||||||
|
|
|
@ -22,10 +22,10 @@ package org.eclipse.jetty.spdy.server;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.spdy.api.GoAwayInfo;
|
import org.eclipse.jetty.spdy.api.GoAwayInfo;
|
||||||
import org.eclipse.jetty.spdy.api.Session;
|
import org.eclipse.jetty.spdy.api.Session;
|
||||||
import org.eclipse.jetty.spdy.api.SessionFrameListener;
|
import org.eclipse.jetty.spdy.api.SessionFrameListener;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class SPDYServerConnectorTest extends AbstractTest
|
public class SPDYServerConnectorTest extends AbstractTest
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class SpringXmlConfigurationTest
|
public class SpringXmlConfigurationTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,10 +55,6 @@ public class JSONTest
|
||||||
"\"undefined\": undefined," +
|
"\"undefined\": undefined," +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see junit.framework.TestCase#setUp()
|
|
||||||
*/
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception
|
public static void setUp() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,6 @@ import org.eclipse.jetty.util.security.CertificateValidator;
|
||||||
import org.eclipse.jetty.util.security.Password;
|
import org.eclipse.jetty.util.security.Password;
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* SslContextFactory is used to configure SSL connectors
|
* SslContextFactory is used to configure SSL connectors
|
||||||
* as well as HttpClient. It holds all SSL parameters and
|
* as well as HttpClient. It holds all SSL parameters and
|
||||||
|
@ -110,12 +109,12 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public static final String PASSWORD_PROPERTY = "org.eclipse.jetty.ssl.password";
|
public static final String PASSWORD_PROPERTY = "org.eclipse.jetty.ssl.password";
|
||||||
|
|
||||||
/** Excluded protocols. */
|
/** Excluded protocols. */
|
||||||
private final Set<String> _excludeProtocols = new LinkedHashSet<String>();
|
private final Set<String> _excludeProtocols = new LinkedHashSet<>();
|
||||||
/** Included protocols. */
|
/** Included protocols. */
|
||||||
private Set<String> _includeProtocols = null;
|
private Set<String> _includeProtocols = null;
|
||||||
|
|
||||||
/** Excluded cipher suites. */
|
/** Excluded cipher suites. */
|
||||||
private final Set<String> _excludeCipherSuites = new LinkedHashSet<String>();
|
private final Set<String> _excludeCipherSuites = new LinkedHashSet<>();
|
||||||
/** Included cipher suites. */
|
/** Included cipher suites. */
|
||||||
private Set<String> _includeCipherSuites = null;
|
private Set<String> _includeCipherSuites = null;
|
||||||
|
|
||||||
|
@ -198,7 +197,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
|
|
||||||
private boolean _trustAll;
|
private boolean _trustAll;
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance of SslContextFactory
|
* Construct an instance of SslContextFactory
|
||||||
* Default constructor for use in XmlConfiguration files
|
* Default constructor for use in XmlConfiguration files
|
||||||
|
@ -208,7 +206,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_trustAll=true;
|
_trustAll=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance of SslContextFactory
|
* Construct an instance of SslContextFactory
|
||||||
* Default constructor for use in XmlConfiguration files
|
* Default constructor for use in XmlConfiguration files
|
||||||
|
@ -220,7 +217,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_trustAll=trustAll;
|
_trustAll=trustAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance of SslContextFactory
|
* Construct an instance of SslContextFactory
|
||||||
* @param keyStorePath default keystore location
|
* @param keyStorePath default keystore location
|
||||||
|
@ -230,7 +226,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_keyStorePath = keyStorePath;
|
_keyStorePath = keyStorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Create the SSLContext object and start the lifecycle
|
* Create the SSLContext object and start the lifecycle
|
||||||
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
|
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
|
||||||
|
@ -253,8 +248,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
||||||
_context = SSLContext.getInstance(_sslProtocol);
|
SSLContext context = SSLContext.getInstance(_sslProtocol);
|
||||||
_context.init(null, trust_managers, secureRandom);
|
context.init(null, trust_managers, secureRandom);
|
||||||
|
_context = context;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -293,19 +289,25 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
TrustManager[] trustManagers = getTrustManagers(trustStore,crls);
|
TrustManager[] trustManagers = getTrustManagers(trustStore,crls);
|
||||||
|
|
||||||
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
||||||
_context = (_sslProvider == null)?SSLContext.getInstance(_sslProtocol):SSLContext.getInstance(_sslProtocol,_sslProvider);
|
SSLContext context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol,_sslProvider);
|
||||||
_context.init(keyManagers,trustManagers,secureRandom);
|
context.init(keyManagers,trustManagers,secureRandom);
|
||||||
|
_context = context;
|
||||||
SSLEngine engine= newSSLEngine();
|
|
||||||
|
|
||||||
LOG.info("Enabled Protocols {} of {}",Arrays.asList(engine.getEnabledProtocols()),Arrays.asList(engine.getSupportedProtocols()));
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Enabled Ciphers {} of {}",Arrays.asList(engine.getEnabledCipherSuites()),Arrays.asList(engine.getSupportedCipherSuites()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSLEngine engine = newSSLEngine();
|
||||||
|
LOG.debug("Enabled Protocols {} of {}",Arrays.asList(engine.getEnabledProtocols()),Arrays.asList(engine.getSupportedProtocols()));
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Enabled Ciphers {} of {}",Arrays.asList(engine.getEnabledCipherSuites()),Arrays.asList(engine.getSupportedCipherSuites()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
@Override
|
||||||
|
protected void doStop() throws Exception
|
||||||
|
{
|
||||||
|
_context = null;
|
||||||
|
super.doStop();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The array of protocol names to exclude from
|
* @return The array of protocol names to exclude from
|
||||||
* {@link SSLEngine#setEnabledProtocols(String[])}
|
* {@link SSLEngine#setEnabledProtocols(String[])}
|
||||||
|
@ -315,7 +317,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _excludeProtocols.toArray(new String[_excludeProtocols.size()]);
|
return _excludeProtocols.toArray(new String[_excludeProtocols.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param protocols
|
* @param protocols
|
||||||
* The array of protocol names to exclude from
|
* The array of protocol names to exclude from
|
||||||
|
@ -324,12 +325,10 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setExcludeProtocols(String... protocols)
|
public void setExcludeProtocols(String... protocols)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_excludeProtocols.clear();
|
_excludeProtocols.clear();
|
||||||
_excludeProtocols.addAll(Arrays.asList(protocols));
|
_excludeProtocols.addAll(Arrays.asList(protocols));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param protocol Protocol names to add to {@link SSLEngine#setEnabledProtocols(String[])}
|
* @param protocol Protocol names to add to {@link SSLEngine#setEnabledProtocols(String[])}
|
||||||
*/
|
*/
|
||||||
|
@ -339,7 +338,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_excludeProtocols.addAll(Arrays.asList(protocol));
|
_excludeProtocols.addAll(Arrays.asList(protocol));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The array of protocol names to include in
|
* @return The array of protocol names to include in
|
||||||
* {@link SSLEngine#setEnabledProtocols(String[])}
|
* {@link SSLEngine#setEnabledProtocols(String[])}
|
||||||
|
@ -349,7 +347,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _includeProtocols.toArray(new String[_includeProtocols.size()]);
|
return _includeProtocols.toArray(new String[_includeProtocols.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param protocols
|
* @param protocols
|
||||||
* The array of protocol names to include in
|
* The array of protocol names to include in
|
||||||
|
@ -358,11 +355,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setIncludeProtocols(String... protocols)
|
public void setIncludeProtocols(String... protocols)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
_includeProtocols = new LinkedHashSet<>(Arrays.asList(protocols));
|
||||||
_includeProtocols = new LinkedHashSet<String>(Arrays.asList(protocols));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The array of cipher suite names to exclude from
|
* @return The array of cipher suite names to exclude from
|
||||||
* {@link SSLEngine#setEnabledCipherSuites(String[])}
|
* {@link SSLEngine#setEnabledCipherSuites(String[])}
|
||||||
|
@ -372,7 +367,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _excludeCipherSuites.toArray(new String[_excludeCipherSuites.size()]);
|
return _excludeCipherSuites.toArray(new String[_excludeCipherSuites.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param cipherSuites
|
* @param cipherSuites
|
||||||
* The array of cipher suite names to exclude from
|
* The array of cipher suite names to exclude from
|
||||||
|
@ -385,7 +379,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_excludeCipherSuites.addAll(Arrays.asList(cipherSuites));
|
_excludeCipherSuites.addAll(Arrays.asList(cipherSuites));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param cipher Cipher names to add to {@link SSLEngine#setEnabledCipherSuites(String[])}
|
* @param cipher Cipher names to add to {@link SSLEngine#setEnabledCipherSuites(String[])}
|
||||||
*/
|
*/
|
||||||
|
@ -395,7 +388,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_excludeCipherSuites.addAll(Arrays.asList(cipher));
|
_excludeCipherSuites.addAll(Arrays.asList(cipher));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The array of cipher suite names to include in
|
* @return The array of cipher suite names to include in
|
||||||
* {@link SSLEngine#setEnabledCipherSuites(String[])}
|
* {@link SSLEngine#setEnabledCipherSuites(String[])}
|
||||||
|
@ -405,7 +397,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _includeCipherSuites.toArray(new String[_includeCipherSuites.size()]);
|
return _includeCipherSuites.toArray(new String[_includeCipherSuites.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param cipherSuites
|
* @param cipherSuites
|
||||||
* The array of cipher suite names to include in
|
* The array of cipher suite names to include in
|
||||||
|
@ -414,11 +405,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setIncludeCipherSuites(String... cipherSuites)
|
public void setIncludeCipherSuites(String... cipherSuites)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
_includeCipherSuites = new LinkedHashSet<>(Arrays.asList(cipherSuites));
|
||||||
_includeCipherSuites = new LinkedHashSet<String>(Arrays.asList(cipherSuites));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The file or URL of the SSL Key store.
|
* @return The file or URL of the SSL Key store.
|
||||||
*/
|
*/
|
||||||
|
@ -427,7 +416,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _keyStorePath;
|
return _keyStorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param keyStorePath
|
* @param keyStorePath
|
||||||
* The file or URL of the SSL Key store.
|
* The file or URL of the SSL Key store.
|
||||||
|
@ -435,11 +423,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setKeyStorePath(String keyStorePath)
|
public void setKeyStorePath(String keyStorePath)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_keyStorePath = keyStorePath;
|
_keyStorePath = keyStorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The provider of the key store
|
* @return The provider of the key store
|
||||||
*/
|
*/
|
||||||
|
@ -448,7 +434,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _keyStoreProvider;
|
return _keyStoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param keyStoreProvider
|
* @param keyStoreProvider
|
||||||
* The provider of the key store
|
* The provider of the key store
|
||||||
|
@ -456,11 +441,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setKeyStoreProvider(String keyStoreProvider)
|
public void setKeyStoreProvider(String keyStoreProvider)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_keyStoreProvider = keyStoreProvider;
|
_keyStoreProvider = keyStoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The type of the key store (default "JKS")
|
* @return The type of the key store (default "JKS")
|
||||||
*/
|
*/
|
||||||
|
@ -469,7 +452,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return (_keyStoreType);
|
return (_keyStoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param keyStoreType
|
* @param keyStoreType
|
||||||
* The type of the key store (default "JKS")
|
* The type of the key store (default "JKS")
|
||||||
|
@ -477,11 +459,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setKeyStoreType(String keyStoreType)
|
public void setKeyStoreType(String keyStoreType)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_keyStoreType = keyStoreType;
|
_keyStoreType = keyStoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return Alias of SSL certificate for the connector
|
* @return Alias of SSL certificate for the connector
|
||||||
*/
|
*/
|
||||||
|
@ -490,7 +470,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _certAlias;
|
return _certAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param certAlias
|
* @param certAlias
|
||||||
* Alias of SSL certificate for the connector
|
* Alias of SSL certificate for the connector
|
||||||
|
@ -498,11 +477,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setCertAlias(String certAlias)
|
public void setCertAlias(String certAlias)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_certAlias = certAlias;
|
_certAlias = certAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The file name or URL of the trust store location
|
* @return The file name or URL of the trust store location
|
||||||
*/
|
*/
|
||||||
|
@ -511,7 +488,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _trustStorePath;
|
return _trustStorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param trustStorePath
|
* @param trustStorePath
|
||||||
* The file name or URL of the trust store location
|
* The file name or URL of the trust store location
|
||||||
|
@ -519,11 +495,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setTrustStorePath(String trustStorePath)
|
public void setTrustStorePath(String trustStorePath)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_trustStorePath = trustStorePath;
|
_trustStorePath = trustStorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The provider of the trust store
|
* @return The provider of the trust store
|
||||||
*/
|
*/
|
||||||
|
@ -532,7 +506,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _trustStoreProvider;
|
return _trustStoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param trustStoreProvider
|
* @param trustStoreProvider
|
||||||
* The provider of the trust store
|
* The provider of the trust store
|
||||||
|
@ -540,11 +513,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setTrustStoreProvider(String trustStoreProvider)
|
public void setTrustStoreProvider(String trustStoreProvider)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_trustStoreProvider = trustStoreProvider;
|
_trustStoreProvider = trustStoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The type of the trust store (default "JKS")
|
* @return The type of the trust store (default "JKS")
|
||||||
*/
|
*/
|
||||||
|
@ -553,7 +524,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _trustStoreType;
|
return _trustStoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param trustStoreType
|
* @param trustStoreType
|
||||||
* The type of the trust store (default "JKS")
|
* The type of the trust store (default "JKS")
|
||||||
|
@ -561,11 +531,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setTrustStoreType(String trustStoreType)
|
public void setTrustStoreType(String trustStoreType)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_trustStoreType = trustStoreType;
|
_trustStoreType = trustStoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return True if SSL needs client authentication.
|
* @return True if SSL needs client authentication.
|
||||||
* @see SSLEngine#getNeedClientAuth()
|
* @see SSLEngine#getNeedClientAuth()
|
||||||
|
@ -575,7 +543,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _needClientAuth;
|
return _needClientAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param needClientAuth
|
* @param needClientAuth
|
||||||
* True if SSL needs client authentication.
|
* True if SSL needs client authentication.
|
||||||
|
@ -584,11 +551,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setNeedClientAuth(boolean needClientAuth)
|
public void setNeedClientAuth(boolean needClientAuth)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_needClientAuth = needClientAuth;
|
_needClientAuth = needClientAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return True if SSL wants client authentication.
|
* @return True if SSL wants client authentication.
|
||||||
* @see SSLEngine#getWantClientAuth()
|
* @see SSLEngine#getWantClientAuth()
|
||||||
|
@ -598,7 +563,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _wantClientAuth;
|
return _wantClientAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param wantClientAuth
|
* @param wantClientAuth
|
||||||
* True if SSL wants client authentication.
|
* True if SSL wants client authentication.
|
||||||
|
@ -607,22 +571,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setWantClientAuth(boolean wantClientAuth)
|
public void setWantClientAuth(boolean wantClientAuth)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_wantClientAuth = wantClientAuth;
|
_wantClientAuth = wantClientAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
|
||||||
* @return true if SSL certificate has to be validated
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean getValidateCerts()
|
|
||||||
{
|
|
||||||
return _validateCerts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return true if SSL certificate has to be validated
|
* @return true if SSL certificate has to be validated
|
||||||
*/
|
*/
|
||||||
|
@ -631,7 +582,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _validateCerts;
|
return _validateCerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param validateCerts
|
* @param validateCerts
|
||||||
* true if SSL certificates have to be validated
|
* true if SSL certificates have to be validated
|
||||||
|
@ -639,11 +589,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setValidateCerts(boolean validateCerts)
|
public void setValidateCerts(boolean validateCerts)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_validateCerts = validateCerts;
|
_validateCerts = validateCerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return true if SSL certificates of the peer have to be validated
|
* @return true if SSL certificates of the peer have to be validated
|
||||||
*/
|
*/
|
||||||
|
@ -652,7 +600,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _validatePeerCerts;
|
return _validatePeerCerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param validatePeerCerts
|
* @param validatePeerCerts
|
||||||
* true if SSL certificates of the peer have to be validated
|
* true if SSL certificates of the peer have to be validated
|
||||||
|
@ -660,12 +607,10 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setValidatePeerCerts(boolean validatePeerCerts)
|
public void setValidatePeerCerts(boolean validatePeerCerts)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_validatePeerCerts = validatePeerCerts;
|
_validatePeerCerts = validatePeerCerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param password
|
* @param password
|
||||||
* The password for the key store
|
* The password for the key store
|
||||||
|
@ -673,11 +618,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setKeyStorePassword(String password)
|
public void setKeyStorePassword(String password)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_keyStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
_keyStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param password
|
* @param password
|
||||||
* The password (if any) for the specific key within the key store
|
* The password (if any) for the specific key within the key store
|
||||||
|
@ -685,11 +628,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setKeyManagerPassword(String password)
|
public void setKeyManagerPassword(String password)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_keyManagerPassword = Password.getPassword(KEYPASSWORD_PROPERTY,password,null);
|
_keyManagerPassword = Password.getPassword(KEYPASSWORD_PROPERTY,password,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param password
|
* @param password
|
||||||
* The password for the trust store
|
* The password for the trust store
|
||||||
|
@ -697,11 +638,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setTrustStorePassword(String password)
|
public void setTrustStorePassword(String password)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_trustStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
_trustStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The SSL provider name, which if set is passed to
|
* @return The SSL provider name, which if set is passed to
|
||||||
* {@link SSLContext#getInstance(String, String)}
|
* {@link SSLContext#getInstance(String, String)}
|
||||||
|
@ -711,7 +650,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _sslProvider;
|
return _sslProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param provider
|
* @param provider
|
||||||
* The SSL provider name, which if set is passed to
|
* The SSL provider name, which if set is passed to
|
||||||
|
@ -720,11 +658,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setProvider(String provider)
|
public void setProvider(String provider)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_sslProvider = provider;
|
_sslProvider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The SSL protocol (default "TLS") passed to
|
* @return The SSL protocol (default "TLS") passed to
|
||||||
* {@link SSLContext#getInstance(String, String)}
|
* {@link SSLContext#getInstance(String, String)}
|
||||||
|
@ -734,7 +670,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _sslProtocol;
|
return _sslProtocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param protocol
|
* @param protocol
|
||||||
* The SSL protocol (default "TLS") passed to
|
* The SSL protocol (default "TLS") passed to
|
||||||
|
@ -743,11 +678,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setProtocol(String protocol)
|
public void setProtocol(String protocol)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_sslProtocol = protocol;
|
_sslProtocol = protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The algorithm name, which if set is passed to
|
* @return The algorithm name, which if set is passed to
|
||||||
* {@link SecureRandom#getInstance(String)} to obtain the {@link SecureRandom} instance passed to
|
* {@link SecureRandom#getInstance(String)} to obtain the {@link SecureRandom} instance passed to
|
||||||
|
@ -758,7 +691,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _secureRandomAlgorithm;
|
return _secureRandomAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param algorithm
|
* @param algorithm
|
||||||
* The algorithm name, which if set is passed to
|
* The algorithm name, which if set is passed to
|
||||||
|
@ -768,11 +700,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setSecureRandomAlgorithm(String algorithm)
|
public void setSecureRandomAlgorithm(String algorithm)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_secureRandomAlgorithm = algorithm;
|
_secureRandomAlgorithm = algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The algorithm name (default "SunX509") used by the {@link KeyManagerFactory}
|
* @return The algorithm name (default "SunX509") used by the {@link KeyManagerFactory}
|
||||||
*/
|
*/
|
||||||
|
@ -781,7 +711,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return (_keyManagerFactoryAlgorithm);
|
return (_keyManagerFactoryAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param algorithm
|
* @param algorithm
|
||||||
* The algorithm name (default "SunX509") used by the {@link KeyManagerFactory}
|
* The algorithm name (default "SunX509") used by the {@link KeyManagerFactory}
|
||||||
|
@ -789,11 +718,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setSslKeyManagerFactoryAlgorithm(String algorithm)
|
public void setSslKeyManagerFactoryAlgorithm(String algorithm)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_keyManagerFactoryAlgorithm = algorithm;
|
_keyManagerFactoryAlgorithm = algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The algorithm name (default "SunX509") used by the {@link TrustManagerFactory}
|
* @return The algorithm name (default "SunX509") used by the {@link TrustManagerFactory}
|
||||||
*/
|
*/
|
||||||
|
@ -802,7 +729,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return (_trustManagerFactoryAlgorithm);
|
return (_trustManagerFactoryAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return True if all certificates should be trusted if there is no KeyStore or TrustStore
|
* @return True if all certificates should be trusted if there is no KeyStore or TrustStore
|
||||||
*/
|
*/
|
||||||
|
@ -811,7 +737,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _trustAll;
|
return _trustAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param trustAll True if all certificates should be trusted if there is no KeyStore or TrustStore
|
* @param trustAll True if all certificates should be trusted if there is no KeyStore or TrustStore
|
||||||
*/
|
*/
|
||||||
|
@ -820,7 +745,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_trustAll = trustAll;
|
_trustAll = trustAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param algorithm
|
* @param algorithm
|
||||||
* The algorithm name (default "SunX509") used by the {@link TrustManagerFactory}
|
* The algorithm name (default "SunX509") used by the {@link TrustManagerFactory}
|
||||||
|
@ -829,11 +753,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setTrustManagerFactoryAlgorithm(String algorithm)
|
public void setTrustManagerFactoryAlgorithm(String algorithm)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_trustManagerFactoryAlgorithm = algorithm;
|
_trustManagerFactoryAlgorithm = algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return Path to file that contains Certificate Revocation List
|
* @return Path to file that contains Certificate Revocation List
|
||||||
*/
|
*/
|
||||||
|
@ -842,7 +764,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _crlPath;
|
return _crlPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param crlPath
|
* @param crlPath
|
||||||
* Path to file that contains Certificate Revocation List
|
* Path to file that contains Certificate Revocation List
|
||||||
|
@ -850,11 +771,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setCrlPath(String crlPath)
|
public void setCrlPath(String crlPath)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_crlPath = crlPath;
|
_crlPath = crlPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return Maximum number of intermediate certificates in
|
* @return Maximum number of intermediate certificates in
|
||||||
* the certification path (-1 for unlimited)
|
* the certification path (-1 for unlimited)
|
||||||
|
@ -864,7 +783,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _maxCertPathLength;
|
return _maxCertPathLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param maxCertPathLength
|
* @param maxCertPathLength
|
||||||
* maximum number of intermediate certificates in
|
* maximum number of intermediate certificates in
|
||||||
|
@ -873,11 +791,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setMaxCertPathLength(int maxCertPathLength)
|
public void setMaxCertPathLength(int maxCertPathLength)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_maxCertPathLength = maxCertPathLength;
|
_maxCertPathLength = maxCertPathLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return The SSLContext
|
* @return The SSLContext
|
||||||
*/
|
*/
|
||||||
|
@ -888,7 +804,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _context;
|
return _context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @param sslContext
|
* @param sslContext
|
||||||
* Set a preconfigured SSLContext
|
* Set a preconfigured SSLContext
|
||||||
|
@ -896,11 +811,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void setSslContext(SSLContext sslContext)
|
public void setSslContext(SSLContext sslContext)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_context = sslContext;
|
_context = sslContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Override this method to provide alternate way to load a keystore.
|
* Override this method to provide alternate way to load a keystore.
|
||||||
*
|
*
|
||||||
|
@ -914,7 +827,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_keyStorePassword==null? null: _keyStorePassword.toString());
|
_keyStorePassword==null? null: _keyStorePassword.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Override this method to provide alternate way to load a truststore.
|
* Override this method to provide alternate way to load a truststore.
|
||||||
*
|
*
|
||||||
|
@ -928,7 +840,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_trustStorePassword==null? null: _trustStorePassword.toString());
|
_trustStorePassword==null? null: _trustStorePassword.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Loads keystore using an input stream or a file path in the same
|
* Loads keystore using an input stream or a file path in the same
|
||||||
* order of precedence.
|
* order of precedence.
|
||||||
|
@ -952,7 +863,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return CertificateUtils.getKeyStore(storeStream, storePath, storeType, storeProvider, storePassword);
|
return CertificateUtils.getKeyStore(storeStream, storePath, storeType, storeProvider, storePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Loads certificate revocation list (CRL) from a file.
|
* Loads certificate revocation list (CRL) from a file.
|
||||||
*
|
*
|
||||||
|
@ -968,7 +878,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return CertificateUtils.loadCRL(crlPath);
|
return CertificateUtils.loadCRL(crlPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
protected KeyManager[] getKeyManagers(KeyStore keyStore) throws Exception
|
protected KeyManager[] getKeyManagers(KeyStore keyStore) throws Exception
|
||||||
{
|
{
|
||||||
KeyManager[] managers = null;
|
KeyManager[] managers = null;
|
||||||
|
@ -994,7 +903,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return managers;
|
return managers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
protected TrustManager[] getTrustManagers(KeyStore trustStore, Collection<? extends CRL> crls) throws Exception
|
protected TrustManager[] getTrustManagers(KeyStore trustStore, Collection<? extends CRL> crls) throws Exception
|
||||||
{
|
{
|
||||||
TrustManager[] managers = null;
|
TrustManager[] managers = null;
|
||||||
|
@ -1051,7 +959,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return managers;
|
return managers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Check KeyStore Configuration. Ensures that if keystore has been
|
* Check KeyStore Configuration. Ensures that if keystore has been
|
||||||
* configured but there's no truststore, that keystore is
|
* configured but there's no truststore, that keystore is
|
||||||
|
@ -1061,8 +968,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public void checkKeyStore()
|
public void checkKeyStore()
|
||||||
{
|
{
|
||||||
if (_context != null)
|
if (_context != null)
|
||||||
return; //nothing to check if using preconfigured context
|
return;
|
||||||
|
|
||||||
|
|
||||||
if (_keyStore == null && _keyStoreInputStream == null && _keyStorePath == null)
|
if (_keyStore == null && _keyStoreInputStream == null && _keyStorePath == null)
|
||||||
throw new IllegalStateException("SSL doesn't have a valid keystore");
|
throw new IllegalStateException("SSL doesn't have a valid keystore");
|
||||||
|
@ -1099,7 +1005,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Select protocols to be used by the connector
|
* Select protocols to be used by the connector
|
||||||
* based on configured inclusion and exclusion lists
|
* based on configured inclusion and exclusion lists
|
||||||
|
@ -1110,7 +1015,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
*/
|
*/
|
||||||
public String[] selectProtocols(String[] enabledProtocols, String[] supportedProtocols)
|
public String[] selectProtocols(String[] enabledProtocols, String[] supportedProtocols)
|
||||||
{
|
{
|
||||||
Set<String> selected_protocols = new LinkedHashSet<String>();
|
Set<String> selected_protocols = new LinkedHashSet<>();
|
||||||
|
|
||||||
// Set the starting protocols - either from the included or enabled list
|
// Set the starting protocols - either from the included or enabled list
|
||||||
if (_includeProtocols!=null)
|
if (_includeProtocols!=null)
|
||||||
|
@ -1131,7 +1036,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return selected_protocols.toArray(new String[selected_protocols.size()]);
|
return selected_protocols.toArray(new String[selected_protocols.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Select cipher suites to be used by the connector
|
* Select cipher suites to be used by the connector
|
||||||
* based on configured inclusion and exclusion lists
|
* based on configured inclusion and exclusion lists
|
||||||
|
@ -1142,7 +1046,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
*/
|
*/
|
||||||
public String[] selectCipherSuites(String[] enabledCipherSuites, String[] supportedCipherSuites)
|
public String[] selectCipherSuites(String[] enabledCipherSuites, String[] supportedCipherSuites)
|
||||||
{
|
{
|
||||||
Set<String> selected_ciphers = new LinkedHashSet<String>();
|
Set<String> selected_ciphers = new LinkedHashSet<>();
|
||||||
|
|
||||||
// Set the starting ciphers - either from the included or enabled list
|
// Set the starting ciphers - either from the included or enabled list
|
||||||
if (_includeCipherSuites!=null)
|
if (_includeCipherSuites!=null)
|
||||||
|
@ -1162,7 +1066,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return selected_ciphers.toArray(new String[selected_ciphers.size()]);
|
return selected_ciphers.toArray(new String[selected_ciphers.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* Check if the lifecycle has been started and throw runtime exception
|
* Check if the lifecycle has been started and throw runtime exception
|
||||||
*/
|
*/
|
||||||
|
@ -1172,7 +1075,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
throw new IllegalStateException("Cannot modify configuration when "+getState());
|
throw new IllegalStateException("Cannot modify configuration when "+getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return true if CRL Distribution Points support is enabled
|
* @return true if CRL Distribution Points support is enabled
|
||||||
*/
|
*/
|
||||||
|
@ -1181,18 +1083,15 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _enableCRLDP;
|
return _enableCRLDP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Enables CRL Distribution Points Support
|
/** Enables CRL Distribution Points Support
|
||||||
* @param enableCRLDP true - turn on, false - turns off
|
* @param enableCRLDP true - turn on, false - turns off
|
||||||
*/
|
*/
|
||||||
public void setEnableCRLDP(boolean enableCRLDP)
|
public void setEnableCRLDP(boolean enableCRLDP)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_enableCRLDP = enableCRLDP;
|
_enableCRLDP = enableCRLDP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return true if On-Line Certificate Status Protocol support is enabled
|
* @return true if On-Line Certificate Status Protocol support is enabled
|
||||||
*/
|
*/
|
||||||
|
@ -1201,18 +1100,15 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _enableOCSP;
|
return _enableOCSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Enables On-Line Certificate Status Protocol support
|
/** Enables On-Line Certificate Status Protocol support
|
||||||
* @param enableOCSP true - turn on, false - turn off
|
* @param enableOCSP true - turn on, false - turn off
|
||||||
*/
|
*/
|
||||||
public void setEnableOCSP(boolean enableOCSP)
|
public void setEnableOCSP(boolean enableOCSP)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_enableOCSP = enableOCSP;
|
_enableOCSP = enableOCSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return Location of the OCSP Responder
|
* @return Location of the OCSP Responder
|
||||||
*/
|
*/
|
||||||
|
@ -1221,47 +1117,39 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _ocspResponderURL;
|
return _ocspResponderURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set the location of the OCSP Responder.
|
/** Set the location of the OCSP Responder.
|
||||||
* @param ocspResponderURL location of the OCSP Responder
|
* @param ocspResponderURL location of the OCSP Responder
|
||||||
*/
|
*/
|
||||||
public void setOcspResponderURL(String ocspResponderURL)
|
public void setOcspResponderURL(String ocspResponderURL)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_ocspResponderURL = ocspResponderURL;
|
_ocspResponderURL = ocspResponderURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set the key store.
|
/** Set the key store.
|
||||||
* @param keyStore the key store to set
|
* @param keyStore the key store to set
|
||||||
*/
|
*/
|
||||||
public void setKeyStore(KeyStore keyStore)
|
public void setKeyStore(KeyStore keyStore)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_keyStore = keyStore;
|
_keyStore = keyStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set the trust store.
|
/** Set the trust store.
|
||||||
* @param trustStore the trust store to set
|
* @param trustStore the trust store to set
|
||||||
*/
|
*/
|
||||||
public void setTrustStore(KeyStore trustStore)
|
public void setTrustStore(KeyStore trustStore)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
_trustStore = trustStore;
|
_trustStore = trustStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set the key store resource.
|
/** Set the key store resource.
|
||||||
* @param resource the key store resource to set
|
* @param resource the key store resource to set
|
||||||
*/
|
*/
|
||||||
public void setKeyStoreResource(Resource resource)
|
public void setKeyStoreResource(Resource resource)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_keyStoreInputStream = resource.getInputStream();
|
_keyStoreInputStream = resource.getInputStream();
|
||||||
|
@ -1273,14 +1161,12 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set the trust store resource.
|
/** Set the trust store resource.
|
||||||
* @param resource the trust store resource to set
|
* @param resource the trust store resource to set
|
||||||
*/
|
*/
|
||||||
public void setTrustStoreResource(Resource resource)
|
public void setTrustStoreResource(Resource resource)
|
||||||
{
|
{
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_trustStoreInputStream = resource.getInputStream();
|
_trustStoreInputStream = resource.getInputStream();
|
||||||
|
@ -1292,7 +1178,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
/**
|
||||||
* @return true if SSL Session caching is enabled
|
* @return true if SSL Session caching is enabled
|
||||||
*/
|
*/
|
||||||
|
@ -1301,7 +1186,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _sessionCachingEnabled;
|
return _sessionCachingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set the flag to enable SSL Session caching.
|
/** Set the flag to enable SSL Session caching.
|
||||||
* @param enableSessionCaching the value of the flag
|
* @param enableSessionCaching the value of the flag
|
||||||
*/
|
*/
|
||||||
|
@ -1310,7 +1194,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_sessionCachingEnabled = enableSessionCaching;
|
_sessionCachingEnabled = enableSessionCaching;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Get SSL session cache size.
|
/** Get SSL session cache size.
|
||||||
* @return SSL session cache size
|
* @return SSL session cache size
|
||||||
*/
|
*/
|
||||||
|
@ -1319,7 +1202,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _sslSessionCacheSize;
|
return _sslSessionCacheSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** SEt SSL session cache size.
|
/** SEt SSL session cache size.
|
||||||
* @param sslSessionCacheSize SSL session cache size to set
|
* @param sslSessionCacheSize SSL session cache size to set
|
||||||
*/
|
*/
|
||||||
|
@ -1328,7 +1210,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
_sslSessionCacheSize = sslSessionCacheSize;
|
_sslSessionCacheSize = sslSessionCacheSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Get SSL session timeout.
|
/** Get SSL session timeout.
|
||||||
* @return SSL session timeout
|
* @return SSL session timeout
|
||||||
*/
|
*/
|
||||||
|
@ -1337,7 +1218,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _sslSessionTimeout;
|
return _sslSessionTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** Set SSL session timeout.
|
/** Set SSL session timeout.
|
||||||
* @param sslSessionTimeout SSL session timeout to set
|
* @param sslSessionTimeout SSL session timeout to set
|
||||||
*/
|
*/
|
||||||
|
@ -1347,7 +1227,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
public SSLServerSocket newSslServerSocket(String host,int port,int backlog) throws IOException
|
public SSLServerSocket newSslServerSocket(String host,int port,int backlog) throws IOException
|
||||||
{
|
{
|
||||||
SSLServerSocketFactory factory = _context.getServerSocketFactory();
|
SSLServerSocketFactory factory = _context.getServerSocketFactory();
|
||||||
|
@ -1370,7 +1249,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
public SSLSocket newSslSocket() throws IOException
|
public SSLSocket newSslSocket() throws IOException
|
||||||
{
|
{
|
||||||
SSLSocketFactory factory = _context.getSocketFactory();
|
SSLSocketFactory factory = _context.getSocketFactory();
|
||||||
|
@ -1390,19 +1268,18 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
public SSLEngine newSSLEngine(String host, int port)
|
public SSLEngine newSSLEngine(String host, int port)
|
||||||
{
|
{
|
||||||
if (!isRunning())
|
if (!isRunning())
|
||||||
throw new IllegalStateException("!STARTED");
|
throw new IllegalStateException("!STARTED");
|
||||||
|
SSLContext context = _context;
|
||||||
SSLEngine sslEngine=isSessionCachingEnabled()
|
SSLEngine sslEngine=isSessionCachingEnabled()
|
||||||
?_context.createSSLEngine(host, port)
|
? context.createSSLEngine(host, port)
|
||||||
:_context.createSSLEngine();
|
: context.createSSLEngine();
|
||||||
customize(sslEngine);
|
customize(sslEngine);
|
||||||
return sslEngine;
|
return sslEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
public SSLEngine newSSLEngine()
|
public SSLEngine newSSLEngine()
|
||||||
{
|
{
|
||||||
if (!isRunning())
|
if (!isRunning())
|
||||||
|
@ -1412,7 +1289,6 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return sslEngine;
|
return sslEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
public void customize(SSLEngine sslEngine)
|
public void customize(SSLEngine sslEngine)
|
||||||
{
|
{
|
||||||
if (getWantClientAuth())
|
if (getWantClientAuth())
|
||||||
|
@ -1427,13 +1303,11 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
sslEngine.setEnabledProtocols(selectProtocols(sslEngine.getEnabledProtocols(),sslEngine.getSupportedProtocols()));
|
sslEngine.setEnabledProtocols(selectProtocols(sslEngine.getEnabledProtocols(),sslEngine.getSupportedProtocols()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
public SSLEngine newSSLEngine(InetSocketAddress address)
|
public SSLEngine newSSLEngine(InetSocketAddress address)
|
||||||
{
|
{
|
||||||
return address != null ? newSSLEngine(address.getAddress().getHostAddress(), address.getPort()) : newSSLEngine();
|
return address != null ? newSSLEngine(address.getAddress().getHostAddress(), address.getPort()) : newSSLEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,9 +23,9 @@ import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||||
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@ -69,7 +69,6 @@ public class DateCacheTest
|
||||||
TimeUnit.MILLISECONDS.sleep(50);
|
TimeUnit.MILLISECONDS.sleep(50);
|
||||||
now=System.currentTimeMillis();
|
now=System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
Assert.assertTrue(hits/10 > misses);
|
Assert.assertTrue(hits / 10 > misses);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,28 +28,34 @@ import javax.servlet.MultipartConfigElement;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.Part;
|
import javax.servlet.http.Part;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.eclipse.jetty.util.MultiPartInputStream.MultiPart;
|
import org.eclipse.jetty.util.MultiPartInputStream.MultiPart;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MultiPartInputStreamTest
|
* MultiPartInputStreamTest
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MultiPartInputStreamTest extends TestCase
|
public class MultiPartInputStreamTest
|
||||||
{
|
{
|
||||||
private static final String FILENAME = "stuff.txt";
|
private static final String FILENAME = "stuff.txt";
|
||||||
protected String _contentType = "multipart/form-data, boundary=AaB03x";
|
protected String _contentType = "multipart/form-data, boundary=AaB03x";
|
||||||
protected String _multi = createMultipartRequestString(FILENAME);
|
protected String _multi = createMultipartRequestString(FILENAME);
|
||||||
protected String _dirname = System.getProperty("java.io.tmpdir")+File.separator+"myfiles-"+System.currentTimeMillis();
|
protected String _dirname = System.getProperty("java.io.tmpdir")+File.separator+"myfiles-"+System.currentTimeMillis();
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNonMultiPartRequest()
|
public void testNonMultiPartRequest()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -61,6 +67,7 @@ public class MultiPartInputStreamTest extends TestCase
|
||||||
assertTrue(mpis.getParts().isEmpty());
|
assertTrue(mpis.getParts().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNoLimits()
|
public void testNoLimits()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -73,6 +80,7 @@ public class MultiPartInputStreamTest extends TestCase
|
||||||
assertFalse(parts.isEmpty());
|
assertFalse(parts.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRequestTooBig ()
|
public void testRequestTooBig ()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -93,6 +101,7 @@ public class MultiPartInputStreamTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFileTooBig()
|
public void testFileTooBig()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -113,13 +122,14 @@ public class MultiPartInputStreamTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMulti ()
|
public void testMulti ()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
testMulti(FILENAME);
|
testMulti(FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMultiWithSpaceInFilename() throws Exception
|
public void testMultiWithSpaceInFilename() throws Exception
|
||||||
{
|
{
|
||||||
testMulti("stuff with spaces.txt");
|
testMulti("stuff with spaces.txt");
|
||||||
|
@ -164,9 +174,9 @@ public class MultiPartInputStreamTest extends TestCase
|
||||||
assertThat(stuff.getHeader("content-disposition"),is("form-data; name=\"stuff\"; filename=\"" + filename + "\""));
|
assertThat(stuff.getHeader("content-disposition"),is("form-data; name=\"stuff\"; filename=\"" + filename + "\""));
|
||||||
assertThat(stuff.getHeaderNames().size(),is(2));
|
assertThat(stuff.getHeaderNames().size(),is(2));
|
||||||
assertThat(stuff.getSize(),is(51L));
|
assertThat(stuff.getSize(),is(51L));
|
||||||
f = ((MultiPartInputStream.MultiPart)stuff).getFile();
|
f = stuff.getFile();
|
||||||
assertThat(f,notNullValue()); // longer than 100 bytes, should already be a file
|
assertThat(f,notNullValue()); // longer than 100 bytes, should already be a file
|
||||||
assertThat(((MultiPartInputStream.MultiPart)stuff).getBytes(),nullValue()); //not in internal buffer any more
|
assertThat(stuff.getBytes(),nullValue()); //not in internal buffer any more
|
||||||
assertThat(f.exists(),is(true));
|
assertThat(f.exists(),is(true));
|
||||||
assertThat(f.getName(),is(not("stuff with space.txt")));
|
assertThat(f.getName(),is(not("stuff with space.txt")));
|
||||||
stuff.write(filename);
|
stuff.write(filename);
|
||||||
|
@ -174,6 +184,7 @@ public class MultiPartInputStreamTest extends TestCase
|
||||||
assertThat(f.exists(),is(true));
|
assertThat(f.exists(),is(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMultiSameNames ()
|
public void testMultiSameNames ()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,18 +18,13 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.util;
|
package org.eclipse.jetty.util;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class StringUtilTest
|
public class StringUtilTest
|
||||||
{
|
{
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,8 +23,8 @@ import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.util.TypeUtil;
|
import org.eclipse.jetty.util.TypeUtil;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class AggregateLifeCycleTest
|
||||||
a0.addBean(a1);
|
a0.addBean(a1);
|
||||||
|
|
||||||
a0.start();
|
a0.start();
|
||||||
Assert.assertEquals(1,started.get());
|
Assert.assertEquals(1, started.get());
|
||||||
Assert.assertEquals(0,stopped.get());
|
Assert.assertEquals(0,stopped.get());
|
||||||
Assert.assertEquals(0,destroyed.get());
|
Assert.assertEquals(0,destroyed.get());
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ public class AggregateLifeCycleTest
|
||||||
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump,"");
|
dump=check(dump,"");
|
||||||
|
|
||||||
AggregateLifeCycle aa2 = new AggregateLifeCycle();
|
AggregateLifeCycle aa2 = new AggregateLifeCycle();
|
||||||
a0.addBean(aa2,false);
|
a0.addBean(aa2,false);
|
||||||
dump=trim(a0.dump());
|
dump=trim(a0.dump());
|
||||||
|
@ -259,7 +259,7 @@ public class AggregateLifeCycleTest
|
||||||
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump,"");
|
dump=check(dump,"");
|
||||||
|
|
||||||
aa1.start();
|
aa1.start();
|
||||||
a0.start();
|
a0.start();
|
||||||
dump=trim(a0.dump());
|
dump=trim(a0.dump());
|
||||||
|
@ -268,14 +268,14 @@ public class AggregateLifeCycleTest
|
||||||
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump,"");
|
dump=check(dump,"");
|
||||||
|
|
||||||
a0.manage(aa1);
|
a0.manage(aa1);
|
||||||
a0.removeBean(aa2);
|
a0.removeBean(aa2);
|
||||||
dump=trim(a0.dump());
|
dump=trim(a0.dump());
|
||||||
dump=check(dump,"org.eclipse.jetty.util.component.AggregateLifeCycl");
|
dump=check(dump,"org.eclipse.jetty.util.component.AggregateLifeCycl");
|
||||||
dump=check(dump," +- org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," +- org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump," +- org.eclipse.jetty.util.component.AggregateLife");
|
dump=check(dump," +- org.eclipse.jetty.util.component.AggregateLife");
|
||||||
dump=check(dump,"");
|
dump=check(dump,"");
|
||||||
|
|
||||||
AggregateLifeCycle aaa0 = new AggregateLifeCycle();
|
AggregateLifeCycle aaa0 = new AggregateLifeCycle();
|
||||||
aa0.addBean(aaa0);
|
aa0.addBean(aaa0);
|
||||||
|
|
|
@ -30,10 +30,10 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class SslContextFactoryTest
|
public class SslContextFactoryTest
|
||||||
|
|
|
@ -22,9 +22,9 @@ import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||||
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ public class QueuedThreadPoolTest
|
||||||
tp.setMaxThreads(10);
|
tp.setMaxThreads(10);
|
||||||
tp.setMaxIdleTimeMs(1000);
|
tp.setMaxIdleTimeMs(1000);
|
||||||
tp.setThreadsPriority(Thread.NORM_PRIORITY-1);
|
tp.setThreadsPriority(Thread.NORM_PRIORITY-1);
|
||||||
|
|
||||||
tp.start();
|
tp.start();
|
||||||
|
|
||||||
waitForThreads(tp,5);
|
waitForThreads(tp,5);
|
||||||
waitForIdle(tp,5);
|
waitForIdle(tp,5);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class QueuedThreadPoolTest
|
||||||
jobs[i]=new RunningJob();
|
jobs[i]=new RunningJob();
|
||||||
tp.dispatch(jobs[i]);
|
tp.dispatch(jobs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForIdle(tp,1);
|
waitForIdle(tp,1);
|
||||||
waitForThreads(tp,6);
|
waitForThreads(tp,6);
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ public class QueuedThreadPoolTest
|
||||||
{}
|
{}
|
||||||
now=System.currentTimeMillis();
|
now=System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
Assert.assertEquals(idle,tp.getIdleThreads());
|
Assert.assertEquals(idle, tp.getIdleThreads());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForThreads(QueuedThreadPool tp, int threads)
|
private void waitForThreads(QueuedThreadPool tp, int threads)
|
||||||
|
|
|
@ -29,16 +29,12 @@ import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class TimeoutTest
|
public class TimeoutTest
|
||||||
{
|
{
|
||||||
private boolean _stress=Boolean.getBoolean("STRESS");
|
private boolean _stress=Boolean.getBoolean("STRESS");
|
||||||
|
|
||||||
Object lock = new Object();
|
Object lock = new Object();
|
||||||
Timeout timeout = new Timeout(null);
|
Timeout timeout = new Timeout(null);
|
||||||
Timeout.Task[] tasks;
|
Timeout.Task[] tasks;
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/*
|
|
||||||
* @see junit.framework.TestCase#setUp()
|
|
||||||
*/
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,11 +27,11 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.HandlerList;
|
import org.eclipse.jetty.server.handler.HandlerList;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
|
@ -31,10 +31,9 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
import org.eclipse.jetty.websocket.core.api.WebSocketBehavior;
|
import org.eclipse.jetty.websocket.core.api.WebSocketBehavior;
|
||||||
|
@ -46,6 +45,7 @@ import org.eclipse.jetty.websocket.core.protocol.Parser;
|
||||||
import org.eclipse.jetty.websocket.core.protocol.WebSocketFrame;
|
import org.eclipse.jetty.websocket.core.protocol.WebSocketFrame;
|
||||||
import org.eclipse.jetty.websocket.server.examples.MyEchoSocket;
|
import org.eclipse.jetty.websocket.server.examples.MyEchoSocket;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -142,7 +142,7 @@ public class WebSocketLoadRFC6455Test
|
||||||
// TODO: Send it
|
// TODO: Send it
|
||||||
// TODO: Receive response
|
// TODO: Receive response
|
||||||
|
|
||||||
Assert.assertEquals(message,_response.toString());
|
Assert.assertEquals(message, _response.toString());
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@ import java.util.Map;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -509,7 +509,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
|
|
|
@ -19,15 +19,18 @@
|
||||||
package org.eclipse.jetty;
|
package org.eclipse.jetty;
|
||||||
|
|
||||||
import com.acme.DispatchServlet;
|
import com.acme.DispatchServlet;
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.servlet.ServletTester;
|
import org.eclipse.jetty.servlet.ServletTester;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple tests against DispatchServlet.
|
* Simple tests against DispatchServlet.
|
||||||
*/
|
*/
|
||||||
public class DispatchServletTest extends TestCase
|
public class DispatchServletTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* As filed in JETTY-978.
|
* As filed in JETTY-978.
|
||||||
|
@ -65,6 +68,7 @@ public class DispatchServletTest extends TestCase
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testSelfRefForwardDenialOfService() throws Exception
|
public void testSelfRefForwardDenialOfService() throws Exception
|
||||||
{
|
{
|
||||||
ServletTester tester = new ServletTester();
|
ServletTester tester = new ServletTester();
|
||||||
|
@ -74,8 +78,8 @@ public class DispatchServletTest extends TestCase
|
||||||
tester.addServlet(DefaultServlet.class,"/");
|
tester.addServlet(DefaultServlet.class,"/");
|
||||||
tester.start();
|
tester.start();
|
||||||
|
|
||||||
StringBuffer req1 = new StringBuffer();
|
StringBuilder req1 = new StringBuilder();
|
||||||
req1.append("GET /tests/dispatch/includeN/"+dispatch.getName()+" HTTP/1.1\n");
|
req1.append("GET /tests/dispatch/includeN/").append(dispatch.getName()).append(" HTTP/1.1\n");
|
||||||
req1.append("Host: tester\n");
|
req1.append("Host: tester\n");
|
||||||
req1.append("Connection: close\n");
|
req1.append("Connection: close\n");
|
||||||
req1.append("\n");
|
req1.append("\n");
|
||||||
|
@ -88,6 +92,7 @@ public class DispatchServletTest extends TestCase
|
||||||
assertTrue(msg + " should return error code 403 (Forbidden)", response.startsWith("HTTP/1.1 403 "));
|
assertTrue(msg + " should return error code 403 (Forbidden)", response.startsWith("HTTP/1.1 403 "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSelfRefDeep() throws Exception
|
public void testSelfRefDeep() throws Exception
|
||||||
{
|
{
|
||||||
ServletTester tester = new ServletTester();
|
ServletTester tester = new ServletTester();
|
||||||
|
@ -106,11 +111,9 @@ public class DispatchServletTest extends TestCase
|
||||||
*/
|
*/
|
||||||
int nestedDepth = 220;
|
int nestedDepth = 220;
|
||||||
|
|
||||||
for (int sri = 0; sri < selfRefs.length; sri++)
|
for (String selfRef : selfRefs)
|
||||||
{
|
{
|
||||||
String selfRef = selfRefs[sri];
|
StringBuilder req1 = new StringBuilder();
|
||||||
|
|
||||||
StringBuffer req1 = new StringBuffer();
|
|
||||||
req1.append("GET /tests");
|
req1.append("GET /tests");
|
||||||
for (int i = 0; i < nestedDepth; i++)
|
for (int i = 0; i < nestedDepth; i++)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +127,7 @@ public class DispatchServletTest extends TestCase
|
||||||
|
|
||||||
String response = tester.getResponses(req1.toString());
|
String response = tester.getResponses(req1.toString());
|
||||||
|
|
||||||
StringBuffer msg = new StringBuffer();
|
StringBuilder msg = new StringBuilder();
|
||||||
msg.append("Response code on nested \"").append(selfRef).append("\"");
|
msg.append("Response code on nested \"").append(selfRef).append("\"");
|
||||||
msg.append(" (depth:").append(nestedDepth).append(")");
|
msg.append(" (depth:").append(nestedDepth).append(")");
|
||||||
|
|
||||||
|
@ -132,7 +135,7 @@ public class DispatchServletTest extends TestCase
|
||||||
"the nestedDepth in the TestCase is too large (reduce it)",
|
"the nestedDepth in the TestCase is too large (reduce it)",
|
||||||
response.startsWith("HTTP/1.1 413 "));
|
response.startsWith("HTTP/1.1 413 "));
|
||||||
|
|
||||||
assertFalse(msg + " should not be code 500.",response.startsWith("HTTP/1.1 500 "));
|
assertFalse(msg + " should not be code 500.", response.startsWith("HTTP/1.1 500 "));
|
||||||
|
|
||||||
assertTrue(msg + " should return error code 403 (Forbidden)", response.startsWith("HTTP/1.1 403 "));
|
assertTrue(msg + " should return error code 403 (Forbidden)", response.startsWith("HTTP/1.1 403 "));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue