15 changed files with 338 additions and 100 deletions
@ -1,8 +1,9 @@
@@ -1,8 +1,9 @@
|
||||
log4j.rootCategory=INFO, stdout |
||||
log4j.rootCategory=DEBUG, stdout |
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender |
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout |
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n |
||||
|
||||
log4j.category.org.mortbay.log=INFO |
||||
log4j.category.org.apache.jasper=DEBUG |
||||
log4j.category.org.mortbay.log=DEBUG |
||||
log4j.category.org.springframework.security=DEBUG |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/security" |
||||
xmlns:beans="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd |
||||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd"> |
||||
|
||||
<authentication-provider> |
||||
<user-service> |
||||
<user name="miles" password="milespassword" authorities="ROLE_USER,ROLE_JAZZ,ROLE_TRUMPETER"/> |
||||
<user name="johnc" password="johncspassword" authorities="ROLE_USER,ROLE_JAZZ,ROLE_SAXOPHONIST"/> |
||||
<user name="jimi" password="jimispassword" authorities="ROLE_USER,ROLE_ROCK,ROLE_GUITARIST"/> |
||||
</user-service> |
||||
</authentication-provider> |
||||
|
||||
</beans:beans> |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
<!-- %@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" % --> |
||||
|
||||
<!-- Not used unless you declare a <form-login login-page="/login.jsp"/> element --> |
||||
|
||||
<html> |
||||
<head> |
||||
<title>Custom Spring Security Login</title> |
||||
</head> |
||||
|
||||
<body> |
||||
<h1>Custom Spring Security Login</h1> |
||||
|
||||
<% |
||||
if (request.getParameter("login_error") != null) { |
||||
%> |
||||
<font color="red"> |
||||
Your login attempt was not successful, try again.<br/><br/> |
||||
</font> |
||||
<% |
||||
} |
||||
%> |
||||
|
||||
<form action="j_spring_security_check" method="POST"> |
||||
<table> |
||||
<tr><td>User:</td><td><input type='text' name='j_username' value=''/></td></tr> |
||||
<tr><td>Password:</td><td><input type='password' name='j_password'></td></tr> |
||||
<tr><td><input type="checkbox" name="_spring_security_remember_me"></td><td>Don't ask for my password for two weeks</td></tr> |
||||
<tr><td colspan='2'><input name="submit" type="submit"></td></tr> |
||||
<tr><td colspan='2'><input name="reset" type="reset"></td></tr> |
||||
</table> |
||||
</form> |
||||
|
||||
</body> |
||||
|
||||
</html> |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE html |
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
||||
<head> |
||||
<title>A secure page</title> |
||||
</head> |
||||
<body> |
||||
<jsp:include page="secure1body.jsp?x=1&y=2"/> |
||||
</body> |
||||
</html> |
||||
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
Params: x=<%= request.getParameter("x") %>, y=<%= request.getParameter("y") %> |
||||
xcount=<%= request.getParameterValues("x").length %> |
||||
@ -1,31 +0,0 @@
@@ -1,31 +0,0 @@
|
||||
package org.springframework.security.integration; |
||||
|
||||
import org.testng.annotations.Test; |
||||
|
||||
/** |
||||
* |
||||
* @author Luke Taylor |
||||
* @version $Id$ |
||||
*/ |
||||
public abstract class AbstractWebLoginTests extends AbstractWebServerIntegrationTests { |
||||
|
||||
@Test |
||||
public void loginFailsWithinvalidPassword() { |
||||
beginAt("secure/index.html"); |
||||
assertFormPresent(); |
||||
setFormElement("j_username", "bob"); |
||||
setFormElement("j_password", "wrongpassword"); |
||||
submit(); |
||||
assertTextPresent("Your login attempt was not successful"); |
||||
} |
||||
|
||||
@Test |
||||
public void loginSucceedsWithCorrectPassword() { |
||||
beginAt("secure/index.html"); |
||||
assertFormPresent(); |
||||
setFormElement("j_username", "bob"); |
||||
setFormElement("j_password", "bobspassword"); |
||||
submit(); |
||||
assertTextPresent("A Secure Page"); |
||||
} |
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
package org.springframework.security.integration; |
||||
|
||||
import org.testng.annotations.*; |
||||
|
||||
/** |
||||
* @author Luke Taylor |
||||
* @version $Id$ |
||||
*/ |
||||
public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTests { |
||||
|
||||
protected String getContextConfigLocations() { |
||||
return "/WEB-INF/http-security.xml /WEB-INF/in-memory-provider.xml"; |
||||
} |
||||
|
||||
@Test |
||||
public void loginFailsWithinvalidPassword() { |
||||
beginAt("secure/index.html"); |
||||
login("jimi", "wrongPassword"); |
||||
assertTextPresent("Your login attempt was not successful"); |
||||
} |
||||
|
||||
@Test |
||||
public void loginSucceedsWithCorrectPassword() { |
||||
beginAt("secure/index.html"); |
||||
login("jimi", "jimispassword"); |
||||
assertTextPresent("A Secure Page"); |
||||
tester.gotoPage("/logout"); |
||||
} |
||||
|
||||
/* |
||||
* Checks use of <jsp:include> with parameters in the secured page. |
||||
*/ |
||||
@Test |
||||
public void savedRequestWithJspIncludeSeesCorrectParams() { |
||||
beginAt("secure/secure1.jsp?x=0"); |
||||
login("jimi", "jimispassword"); |
||||
// Included JSP has params ?x=1&y=2
|
||||
assertTextPresent("Params: x=1, y=2"); |
||||
assertTextPresent("xcount=2"); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue