jetty-9 jetty-security passing tests
This commit is contained in:
parent
96cbd53c47
commit
c318cb8167
|
@ -574,8 +574,9 @@ public class HttpFields implements Iterable<HttpFields.Field>
|
|||
*/
|
||||
public void add(String name, String value) throws IllegalArgumentException
|
||||
{
|
||||
if (value == null) throw new IllegalArgumentException("null value");
|
||||
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
Field field = _names.get(name);
|
||||
Field last = null;
|
||||
while (field != null)
|
||||
|
@ -890,15 +891,15 @@ public class HttpFields implements Iterable<HttpFields.Field>
|
|||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
public void putTo(ByteBuffer buffer) throws IOException
|
||||
public void putTo(ByteBuffer bufferInFillMode) throws IOException
|
||||
{
|
||||
for (int i = 0; i < _fields.size(); i++)
|
||||
{
|
||||
Field field = _fields.get(i);
|
||||
if (field != null)
|
||||
field.putTo(buffer);
|
||||
field.putTo(bufferInFillMode);
|
||||
}
|
||||
BufferUtil.putCRLF(buffer);
|
||||
BufferUtil.putCRLF(bufferInFillMode);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
|
@ -1146,7 +1147,7 @@ public class HttpFields implements Iterable<HttpFields.Field>
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private byte[] toSanitisedBytes(String s)
|
||||
private byte[] toSanitisedName(String s)
|
||||
{
|
||||
byte[] bytes = s.getBytes(StringUtil.__ISO_8859_1_CHARSET);
|
||||
for (int i=bytes.length;i-->0;)
|
||||
|
@ -1161,6 +1162,22 @@ public class HttpFields implements Iterable<HttpFields.Field>
|
|||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private byte[] toSanitisedValue(String s)
|
||||
{
|
||||
byte[] bytes = s.getBytes(StringUtil.__ISO_8859_1_CHARSET);
|
||||
for (int i=bytes.length;i-->0;)
|
||||
{
|
||||
switch(bytes[i])
|
||||
{
|
||||
case '\r':
|
||||
case '\n':
|
||||
bytes[i]=(byte)'?';
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void putTo(ByteBuffer bufferInFillMode)
|
||||
|
@ -1176,16 +1193,16 @@ public class HttpFields implements Iterable<HttpFields.Field>
|
|||
if (value!=null)
|
||||
bufferInFillMode.put(value.toBuffer());
|
||||
else
|
||||
bufferInFillMode.put(toSanitisedBytes(_value));
|
||||
bufferInFillMode.put(toSanitisedValue(_value));
|
||||
}
|
||||
else
|
||||
bufferInFillMode.put(toSanitisedBytes(_value));
|
||||
bufferInFillMode.put(toSanitisedValue(_value));
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferInFillMode.put(toSanitisedBytes(_name));
|
||||
bufferInFillMode.put(toSanitisedName(_name));
|
||||
bufferInFillMode.put(__colon_space);
|
||||
bufferInFillMode.put(toSanitisedBytes(_value));
|
||||
bufferInFillMode.put(toSanitisedValue(_value));
|
||||
}
|
||||
|
||||
BufferUtil.putCRLF(bufferInFillMode);
|
||||
|
@ -1194,7 +1211,7 @@ public class HttpFields implements Iterable<HttpFields.Field>
|
|||
/* ------------------------------------------------------------ */
|
||||
public void putValueTo(ByteBuffer buffer)
|
||||
{
|
||||
buffer.put(toSanitisedBytes(_value));
|
||||
buffer.put(toSanitisedValue(_value));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -39,10 +39,10 @@ public class HttpFieldsTest
|
|||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
header.put("name0", "value0");
|
||||
header.put("name0", "value:0");
|
||||
header.put("name1", "value1");
|
||||
|
||||
assertEquals("value0",header.getStringField("name0"));
|
||||
assertEquals("value:0",header.getStringField("name0"));
|
||||
assertEquals("value1",header.getStringField("name1"));
|
||||
assertNull(header.getStringField("name2"));
|
||||
|
||||
|
@ -60,10 +60,31 @@ public class HttpFieldsTest
|
|||
|
||||
e = header.getValues("name0");
|
||||
assertEquals(true, e.hasMoreElements());
|
||||
assertEquals(e.nextElement(), "value0");
|
||||
assertEquals(e.nextElement(), "value:0");
|
||||
assertEquals(false, e.hasMoreElements());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutTo() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
header.put("name0", "value0");
|
||||
header.put("name1", "value:A");
|
||||
header.add("name1", "value:B");
|
||||
header.add("name2", "");
|
||||
|
||||
ByteBuffer buffer=BufferUtil.allocate(1024);
|
||||
BufferUtil.flipToFill(buffer);
|
||||
header.putTo(buffer);
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
String result=BufferUtil.toString(buffer);
|
||||
|
||||
assertThat(result,Matchers.containsString("name0: value0"));
|
||||
assertThat(result,Matchers.containsString("name1: value:A"));
|
||||
assertThat(result,Matchers.containsString("name1: value:B"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() throws Exception
|
||||
{
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import org.eclipse.jetty.http.PathMap;
|
||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.server.HttpConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
@ -43,6 +43,7 @@ import org.eclipse.jetty.util.security.Constraint;
|
|||
*/
|
||||
public class ConstraintSecurityHandler extends SecurityHandler implements ConstraintAware
|
||||
{
|
||||
private static final String ALL_METHODS = "*";
|
||||
private final List<ConstraintMapping> _constraintMappings= new CopyOnWriteArrayList<ConstraintMapping>();
|
||||
private final Set<String> _roles = new CopyOnWriteArraySet<String>();
|
||||
private final PathMap _constraintMap = new PathMap();
|
||||
|
@ -145,7 +146,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
if (cmr!=null)
|
||||
{
|
||||
for (String r : cmr)
|
||||
if (!"*".equals(r))
|
||||
if (!ALL_METHODS.equals(r))
|
||||
roles.add(r);
|
||||
}
|
||||
}
|
||||
|
@ -245,11 +246,13 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
mappings = new StringMap();
|
||||
_constraintMap.put(mapping.getPathSpec(),mappings);
|
||||
}
|
||||
RoleInfo allMethodsRoleInfo = mappings.get(null);
|
||||
RoleInfo allMethodsRoleInfo = mappings.get(ALL_METHODS);
|
||||
if (allMethodsRoleInfo != null && allMethodsRoleInfo.isForbidden())
|
||||
return;
|
||||
|
||||
String httpMethod = mapping.getMethod();
|
||||
if (httpMethod==null)
|
||||
httpMethod=ALL_METHODS;
|
||||
RoleInfo roleInfo = mappings.get(httpMethod);
|
||||
if (roleInfo == null)
|
||||
{
|
||||
|
@ -268,10 +271,10 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
roleInfo.setForbidden(forbidden);
|
||||
if (forbidden)
|
||||
{
|
||||
if (httpMethod == null)
|
||||
if (httpMethod.equals(ALL_METHODS))
|
||||
{
|
||||
mappings.clear();
|
||||
mappings.put(null,roleInfo);
|
||||
mappings.put(ALL_METHODS,roleInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -306,11 +309,11 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
}
|
||||
}
|
||||
}
|
||||
if (httpMethod == null)
|
||||
if (httpMethod.equals(ALL_METHODS))
|
||||
{
|
||||
for (Map.Entry<String, RoleInfo> entry : mappings.entrySet())
|
||||
{
|
||||
if (entry.getKey() != null)
|
||||
if (!entry.getKey().equals(ALL_METHODS))
|
||||
{
|
||||
RoleInfo specific = entry.getValue();
|
||||
specific.combine(roleInfo);
|
||||
|
@ -329,7 +332,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
String httpMethod = request.getMethod();
|
||||
RoleInfo roleInfo = mappings.get(httpMethod);
|
||||
if (roleInfo == null)
|
||||
roleInfo = mappings.get(null);
|
||||
roleInfo = mappings.get(ALL_METHODS);
|
||||
return roleInfo;
|
||||
}
|
||||
|
||||
|
@ -351,8 +354,8 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
{
|
||||
return true;
|
||||
}
|
||||
AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection();
|
||||
Connector connector = connection.getConnector();
|
||||
|
||||
HttpConnector connector = HttpChannel.getCurrentHttpChannel().getHttpConnector();
|
||||
|
||||
if (dataConstraint == UserDataConstraint.Integral)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ import javax.servlet.ServletResponse;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.security.ServerAuthException;
|
||||
import org.eclipse.jetty.security.UserAuthentication;
|
||||
import org.eclipse.jetty.server.Authentication;
|
||||
|
@ -57,7 +57,7 @@ public class BasicAuthenticator extends LoginAuthenticator
|
|||
{
|
||||
HttpServletRequest request = (HttpServletRequest)req;
|
||||
HttpServletResponse response = (HttpServletResponse)res;
|
||||
String credentials = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
String credentials = request.getHeader(HttpHeader.AUTHORIZATION.asString());
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ public class BasicAuthenticator extends LoginAuthenticator
|
|||
if (_deferred.isDeferred(response))
|
||||
return Authentication.UNAUTHENTICATED;
|
||||
|
||||
response.setHeader(HttpHeaders.WWW_AUTHENTICATE, "basic realm=\"" + _loginService.getName() + '"');
|
||||
response.setHeader(HttpHeader.WWW_AUTHENTICATE.asString(), "basic realm=\"" + _loginService.getName() + '"');
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return Authentication.SEND_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import javax.servlet.ServletResponse;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.security.ServerAuthException;
|
||||
import org.eclipse.jetty.security.UserAuthentication;
|
||||
|
@ -120,7 +120,7 @@ public class DigestAuthenticator extends LoginAuthenticator
|
|||
|
||||
HttpServletRequest request = (HttpServletRequest)req;
|
||||
HttpServletResponse response = (HttpServletResponse)res;
|
||||
String credentials = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
String credentials = request.getHeader(HttpHeader.AUTHORIZATION.asString());
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ public class DigestAuthenticator extends LoginAuthenticator
|
|||
String domain = request.getContextPath();
|
||||
if (domain == null)
|
||||
domain = "/";
|
||||
response.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"" + _loginService.getName()
|
||||
response.setHeader(HttpHeader.WWW_AUTHENTICATE.asString(), "Digest realm=\"" + _loginService.getName()
|
||||
+ "\", domain=\""
|
||||
+ domain
|
||||
+ "\", nonce=\""
|
||||
|
|
|
@ -27,14 +27,15 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.security.ServerAuthException;
|
||||
import org.eclipse.jetty.security.UserAuthentication;
|
||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||
import org.eclipse.jetty.server.Authentication;
|
||||
import org.eclipse.jetty.server.Authentication.User;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
|
@ -217,8 +218,8 @@ public class FormAuthenticator extends LoginAuthenticator
|
|||
else if (_dispatch)
|
||||
{
|
||||
RequestDispatcher dispatcher = request.getRequestDispatcher(_formErrorPage);
|
||||
response.setHeader(HttpHeaders.CACHE_CONTROL,"No-cache");
|
||||
response.setDateHeader(HttpHeaders.EXPIRES,1);
|
||||
response.setHeader(HttpHeader.CACHE_CONTROL.asString(),HttpHeaderValue.NO_CACHE.asString());
|
||||
response.setDateHeader(HttpHeader.EXPIRES.asString(),1);
|
||||
dispatcher.forward(new FormRequest(request), new FormResponse(response));
|
||||
}
|
||||
else
|
||||
|
@ -259,8 +260,8 @@ public class FormAuthenticator extends LoginAuthenticator
|
|||
// so restore method and parameters
|
||||
|
||||
session.removeAttribute(__J_POST);
|
||||
Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
|
||||
base_request.setMethod(HttpMethods.POST);
|
||||
Request base_request = HttpChannel.getCurrentHttpChannel().getRequest();
|
||||
base_request.setMethod(HttpMethod.POST,HttpMethod.POST.asString());
|
||||
base_request.setParameters(j_post);
|
||||
}
|
||||
}
|
||||
|
@ -287,9 +288,9 @@ public class FormAuthenticator extends LoginAuthenticator
|
|||
buf.append("?").append(request.getQueryString());
|
||||
session.setAttribute(__J_URI, buf.toString());
|
||||
|
||||
if (MimeTypes.FORM_ENCODED.equalsIgnoreCase(req.getContentType()) && HttpMethods.POST.equals(request.getMethod()))
|
||||
if (MimeTypes.Type.FORM_ENCODED.is(req.getContentType()) && HttpMethod.POST.is(request.getMethod()))
|
||||
{
|
||||
Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
|
||||
Request base_request = (req instanceof Request)?(Request)req:HttpChannel.getCurrentHttpChannel().getRequest();
|
||||
base_request.extractParameters();
|
||||
session.setAttribute(__J_POST, new MultiMap<String>(base_request.getParameters()));
|
||||
}
|
||||
|
@ -300,8 +301,8 @@ public class FormAuthenticator extends LoginAuthenticator
|
|||
if (_dispatch)
|
||||
{
|
||||
RequestDispatcher dispatcher = request.getRequestDispatcher(_formLoginPage);
|
||||
response.setHeader(HttpHeaders.CACHE_CONTROL,"No-cache");
|
||||
response.setDateHeader(HttpHeaders.EXPIRES,1);
|
||||
response.setHeader(HttpHeader.CACHE_CONTROL.asString(),HttpHeaderValue.NO_CACHE.asString());
|
||||
response.setDateHeader(HttpHeader.EXPIRES.asString(),1);
|
||||
dispatcher.forward(new FormRequest(request), new FormResponse(response));
|
||||
}
|
||||
else
|
||||
|
@ -427,12 +428,12 @@ public class FormAuthenticator extends LoginAuthenticator
|
|||
|
||||
private boolean notIgnored(String name)
|
||||
{
|
||||
if (HttpHeaders.CACHE_CONTROL.equalsIgnoreCase(name) ||
|
||||
HttpHeaders.PRAGMA.equalsIgnoreCase(name) ||
|
||||
HttpHeaders.ETAG.equalsIgnoreCase(name) ||
|
||||
HttpHeaders.EXPIRES.equalsIgnoreCase(name) ||
|
||||
HttpHeaders.LAST_MODIFIED.equalsIgnoreCase(name) ||
|
||||
HttpHeaders.AGE.equalsIgnoreCase(name))
|
||||
if (HttpHeader.CACHE_CONTROL.is(name) ||
|
||||
HttpHeader.PRAGMA.is(name) ||
|
||||
HttpHeader.ETAG.is(name) ||
|
||||
HttpHeader.EXPIRES.is(name) ||
|
||||
HttpHeader.LAST_MODIFIED.is(name) ||
|
||||
HttpHeader.AGE.is(name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import javax.servlet.ServletResponse;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.security.ServerAuthException;
|
||||
import org.eclipse.jetty.security.UserAuthentication;
|
||||
import org.eclipse.jetty.server.Authentication;
|
||||
|
@ -46,7 +46,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
|
|||
HttpServletRequest req = (HttpServletRequest)request;
|
||||
HttpServletResponse res = (HttpServletResponse)response;
|
||||
|
||||
String header = req.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
String header = req.getHeader(HttpHeader.AUTHORIZATION.asString());
|
||||
|
||||
if (!mandatory)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
|
|||
}
|
||||
|
||||
LOG.debug("SpengoAuthenticator: sending challenge");
|
||||
res.setHeader(HttpHeaders.WWW_AUTHENTICATE, HttpHeaders.NEGOTIATE);
|
||||
res.setHeader(HttpHeader.WWW_AUTHENTICATE.asString(), HttpHeader.NEGOTIATE.asString());
|
||||
res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return Authentication.SEND_CONTINUE;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
|
|||
throw new ServerAuthException(ioe);
|
||||
}
|
||||
}
|
||||
else if (header != null && header.startsWith(HttpHeaders.NEGOTIATE))
|
||||
else if (header != null && header.startsWith(HttpHeader.NEGOTIATE.asString()))
|
||||
{
|
||||
String spnegoToken = header.substring(10);
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
package org.eclipse.jetty.security;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
@ -30,7 +32,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
|
||||
import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
@ -42,9 +44,11 @@ import org.eclipse.jetty.util.B64Code;
|
|||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.util.security.Password;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.matchers.JUnitMatchers;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1441 $ $Date: 2010-04-02 12:28:17 +0200 (Fri, 02 Apr 2010) $
|
||||
|
@ -53,7 +57,7 @@ public class ConstraintTest
|
|||
{
|
||||
private static final String TEST_REALM = "TestRealm";
|
||||
private static Server _server;
|
||||
private static LocalConnector _connector;
|
||||
private static LocalHttpConnector _connector;
|
||||
private static SessionHandler _session;
|
||||
private ConstraintSecurityHandler _security;
|
||||
|
||||
|
@ -61,7 +65,7 @@ public class ConstraintTest
|
|||
public static void startServer()
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalConnector();
|
||||
_connector = new LocalHttpConnector();
|
||||
_server.setConnectors(new Connector[]{_connector});
|
||||
|
||||
ContextHandler _context = new ContextHandler();
|
||||
|
@ -254,9 +258,9 @@ public class ConstraintTest
|
|||
assertTrue(response.startsWith("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n\r\n");
|
||||
assertTrue(response.indexOf("Cache-Control: no-cache") > 0);
|
||||
assertTrue(response.indexOf("Expires") > 0);
|
||||
assertTrue(response.indexOf("URI=/ctx/testLoginPage") > 0);
|
||||
assertThat(response,containsString("Cache-Control: no-cache"));
|
||||
assertThat(response,containsString("Expires"));
|
||||
assertThat(response,containsString("URI=/ctx/testLoginPage"));
|
||||
|
||||
String session = response.substring(response.indexOf("JSESSIONID=") + 11, response.indexOf(";Path=/ctx"));
|
||||
|
||||
|
|
|
@ -23,12 +23,11 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.http.HttpSchemes;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
@ -46,8 +45,8 @@ import org.junit.Test;
|
|||
public class DataConstraintsTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalConnector _connector;
|
||||
private LocalConnector _connectorS;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalHttpConnector _connectorS;
|
||||
private SessionHandler _session;
|
||||
private ConstraintSecurityHandler _security;
|
||||
|
||||
|
@ -55,21 +54,23 @@ public class DataConstraintsTest
|
|||
public void startServer()
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalConnector();
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector.setMaxIdleTime(300000);
|
||||
_connector.setIntegralPort(9998);
|
||||
_connector.setIntegralScheme("FTP");
|
||||
_connector.setConfidentialPort(9999);
|
||||
_connector.setConfidentialScheme("SPDY");
|
||||
_connectorS = new LocalConnector()
|
||||
_connectorS = new LocalHttpConnector()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void customize(EndPoint endpoint, Request request) throws IOException
|
||||
public void customize(Request request) throws IOException
|
||||
{
|
||||
super.customize(endpoint,request);
|
||||
request.setScheme(HttpSchemes.HTTPS);
|
||||
request.setScheme(HttpScheme.HTTPS.asString());
|
||||
super.customize(request);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isIntegral(Request request)
|
||||
{
|
||||
|
@ -214,7 +215,7 @@ public class DataConstraintsTest
|
|||
constraint0.setDataConstraint(Constraint.DC_CONFIDENTIAL);
|
||||
ConstraintMapping mapping0 = new ConstraintMapping();
|
||||
mapping0.setPathSpec("/confid/*");
|
||||
mapping0.setMethod(HttpMethods.POST);
|
||||
mapping0.setMethod(HttpMethod.POST.asString());
|
||||
mapping0.setConstraint(constraint0);
|
||||
|
||||
_security.setConstraintMappings(Arrays.asList(new ConstraintMapping[]
|
||||
|
@ -248,7 +249,7 @@ public class DataConstraintsTest
|
|||
constraint0.setDataConstraint(Constraint.DC_CONFIDENTIAL);
|
||||
ConstraintMapping mapping0 = new ConstraintMapping();
|
||||
mapping0.setPathSpec("/confid/*");
|
||||
mapping0.setMethod(HttpMethods.POST);
|
||||
mapping0.setMethod(HttpMethod.POST.asString());
|
||||
mapping0.setConstraint(constraint0);
|
||||
|
||||
_security.setConstraintMappings(Arrays.asList(new ConstraintMapping[]
|
||||
|
@ -284,7 +285,7 @@ public class DataConstraintsTest
|
|||
constraint0.setDataConstraint(Constraint.DC_CONFIDENTIAL);
|
||||
ConstraintMapping mapping0 = new ConstraintMapping();
|
||||
mapping0.setPathSpec("/confid/*");
|
||||
mapping0.setMethod(HttpMethods.POST);
|
||||
mapping0.setMethod(HttpMethod.POST.asString());
|
||||
mapping0.setConstraint(constraint0);
|
||||
|
||||
_security.setConstraintMappings(Arrays.asList(new ConstraintMapping[]
|
||||
|
@ -347,10 +348,10 @@ public class DataConstraintsTest
|
|||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n Authorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n Authorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
}
|
||||
|
|
|
@ -608,7 +608,8 @@ public abstract class HttpChannel
|
|||
break;
|
||||
}
|
||||
}
|
||||
_requestFields.add(name, value);
|
||||
if (name!=null)
|
||||
_requestFields.add(name, value);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.jetty.continuation.ContinuationSupport;
|
|||
import org.eclipse.jetty.server.AsyncContinuation;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
|
@ -34,7 +34,7 @@ public class AsyncContextDispatchWithQueryStrings {
|
|||
|
||||
private Server _server = new Server();
|
||||
private ServletContextHandler _contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
|
||||
private LocalConnector _connector = new LocalConnector();
|
||||
private LocalHttpConnector _connector = new LocalHttpConnector();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
|
@ -16,7 +16,7 @@ import javax.servlet.ServletResponse;
|
|||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
@ -36,7 +36,7 @@ public class DefaultServletTest
|
|||
public TestingDir testdir = new TestingDir();
|
||||
|
||||
private Server server;
|
||||
private LocalConnector connector;
|
||||
private LocalHttpConnector connector;
|
||||
private ServletContextHandler context;
|
||||
|
||||
@Before
|
||||
|
@ -45,7 +45,7 @@ public class DefaultServletTest
|
|||
server = new Server();
|
||||
server.setSendServerVersion(false);
|
||||
|
||||
connector = new LocalConnector();
|
||||
connector = new LocalHttpConnector();
|
||||
|
||||
context = new ServletContextHandler();
|
||||
context.setContextPath("/context");
|
||||
|
|
|
@ -45,7 +45,7 @@ import javax.servlet.http.HttpServletResponseWrapper;
|
|||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
|
@ -58,7 +58,7 @@ import org.junit.Test;
|
|||
public class DispatcherTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalConnector _connector;
|
||||
private LocalHttpConnector _connector;
|
||||
private ContextHandlerCollection _contextCollection;
|
||||
private ServletContextHandler _contextHandler;
|
||||
private ResourceHandler _resourceHandler;
|
||||
|
@ -68,7 +68,7 @@ public class DispatcherTest
|
|||
{
|
||||
_server = new Server();
|
||||
_server.setSendServerVersion(false);
|
||||
_connector = new LocalConnector();
|
||||
_connector = new LocalHttpConnector();
|
||||
|
||||
_contextCollection = new ContextHandlerCollection();
|
||||
_contextHandler = new ServletContextHandler();
|
||||
|
|
|
@ -23,7 +23,7 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -35,13 +35,13 @@ import org.junit.Test;
|
|||
public class InvokerTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalConnector _connector;
|
||||
private LocalHttpConnector _connector;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalConnector();
|
||||
_connector = new LocalHttpConnector();
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
|
||||
_server.setSendServerVersion(false);
|
||||
|
|
|
@ -14,7 +14,7 @@ import junit.framework.AssertionFailedError;
|
|||
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandlerContainer;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
|
@ -27,14 +27,14 @@ import org.junit.Test;
|
|||
public class ServletContextHandlerTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalConnector _connector;
|
||||
private LocalHttpConnector _connector;
|
||||
|
||||
@Before
|
||||
public void createServer()
|
||||
{
|
||||
_server = new Server();
|
||||
|
||||
_connector = new LocalConnector();
|
||||
_connector = new LocalHttpConnector();
|
||||
_server.addConnector(_connector);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.jetty.servlet;
|
|||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||
import org.junit.After;
|
||||
|
@ -24,7 +24,7 @@ import org.junit.Test;
|
|||
public class StatisticsServletTest
|
||||
{
|
||||
private Server server;
|
||||
private LocalConnector connector;
|
||||
private LocalHttpConnector connector;
|
||||
private ServletContextHandler context;
|
||||
|
||||
@Before
|
||||
|
@ -40,7 +40,7 @@ public class StatisticsServletTest
|
|||
context.addServlet(holder, "/stats");
|
||||
|
||||
server.setHandler(context);
|
||||
connector = new LocalConnector();
|
||||
connector = new LocalHttpConnector();
|
||||
server.addConnector(connector);
|
||||
}
|
||||
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -347,12 +347,12 @@
|
|||
<module>jetty-websocket</module>
|
||||
<module>jetty-continuation</module>
|
||||
<module>jetty-server</module>
|
||||
<module>jetty-client</module>
|
||||
<!--
|
||||
<module>jetty-xml</module>
|
||||
<module>jetty-security</module>
|
||||
<module>jetty-jaspi</module>
|
||||
<module>jetty-servlet</module>
|
||||
<!--
|
||||
<module>jetty-jaspi</module>
|
||||
<module>jetty-client</module>
|
||||
<module>jetty-webapp</module>
|
||||
<module>jetty-servlets</module>
|
||||
<module>jetty-deploy</module>
|
||||
|
|
Loading…
Reference in New Issue