If the user fails to login, they will be redirected back to the page that contains the Login widget.

This commit is contained in:
jeb228 2010-11-15 17:03:35 +00:00
parent 46d4332ba3
commit f7b7046318
3 changed files with 55 additions and 34 deletions

View file

@ -36,10 +36,12 @@ public class HttpServletRequestStub implements HttpServletRequest {
private HttpSession session;
private final Map<String, List<String>> parameters;
private final Map<String, Object> attributes;
private final Map<String, List<String>> headers;
public HttpServletRequestStub() {
parameters = new HashMap<String, List<String>>();
attributes = new HashMap<String, Object>();
headers = new HashMap<String, List<String>>();
}
public HttpServletRequestStub(Map<String, List<String>> parameters,
@ -61,6 +63,14 @@ public class HttpServletRequestStub implements HttpServletRequest {
public void setRemoteAddr(String remoteAddr) {
this.remoteAddr = remoteAddr;
}
public void setHeader(String name, String value) {
name = name.toLowerCase();
if (!headers.containsKey(name)) {
headers.put(name, new ArrayList<String>());
}
headers.get(name).add(value);
}
public void addParameter(String name, String value) {
if (!parameters.containsKey(name)) {
@ -163,6 +173,30 @@ public class HttpServletRequestStub implements HttpServletRequest {
attributes.put(name, value);
}
@SuppressWarnings("rawtypes")
public Enumeration getHeaderNames() {
return Collections.enumeration(headers.keySet());
}
public String getHeader(String name) {
name = name.toLowerCase();
if (headers.containsKey(name)) {
return headers.get(name).get(0);
} else {
return null;
}
}
@SuppressWarnings("rawtypes")
public Enumeration getHeaders(String name) {
name = name.toLowerCase();
if (headers.containsKey(name)) {
return Collections.enumeration(headers.get(name));
} else {
return Collections.enumeration(Collections.emptyList());
}
}
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@ -182,23 +216,6 @@ public class HttpServletRequestStub implements HttpServletRequest {
"HttpServletRequestStub.getDateHeader() not implemented.");
}
public String getHeader(String arg0) {
throw new RuntimeException(
"HttpServletRequestStub.getHeader() not implemented.");
}
@SuppressWarnings("rawtypes")
public Enumeration getHeaderNames() {
throw new RuntimeException(
"HttpServletRequestStub.getHeaderNames() not implemented.");
}
@SuppressWarnings("rawtypes")
public Enumeration getHeaders(String arg0) {
throw new RuntimeException(
"HttpServletRequestStub.getHeaders() not implemented.");
}
public int getIntHeader(String arg0) {
throw new RuntimeException(
"HttpServletRequestStub.getIntHeader() not implemented.");