Changed class names to match new context classes.

This commit is contained in:
Luke Taylor 2005-11-06 22:00:27 +00:00
parent 8b88700079
commit e02dbd5c34
10 changed files with 44 additions and 44 deletions

View File

@ -79,13 +79,13 @@ public class HttpRequestIntegrationFilter implements Filter {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug( logger.debug(
"SecurityContext updated with Authentication from container: '" "SecurityContextHolder updated with Authentication from container: '"
+ principal + "'"); + principal + "'");
} }
} else { } else {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug( logger.debug(
"ContextHolder not set with new Authentication as Principal was: '" "SecurityContextHolder not set with new Authentication as Principal was: '"
+ principal + "'"); + principal + "'");
} }
} }

View File

@ -98,7 +98,7 @@ public class AuthenticationSimpleHttpInvokerRequestExecutor
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug( logger.debug(
"HttpInvocation now presenting via BASIC authentication ContextHolder-derived: " "HttpInvocation now presenting via BASIC authentication SecurityContextHolder-derived: "
+ auth.toString()); + auth.toString());
} }
} else { } else {

View File

@ -38,22 +38,22 @@ import javax.security.auth.spi.LoginModule;
* conjunction with it. <br /> * conjunction with it. <br />
* The {@link JaasAuthenticationProvider} allows Acegi to authenticate against * The {@link JaasAuthenticationProvider} allows Acegi to authenticate against
* Jaas. <br /> * Jaas. <br />
* The SecureContextLoginModule allows a Jaas based application to * The SecurityContextLoginModule allows a Jaas based application to
* authenticate against Acegi. If there is no Authentication in the {@link * authenticate against Acegi. If there is no Authentication in the {@link
* SecurityContextHolder} the login() method will throw a LoginException by * SecurityContextHolder} the login() method will throw a LoginException by
* default. This functionality can be changed with the * default. This functionality can be changed with the
* <tt>ignoreMissingAuthentication</tt> option by setting it to "true". * <tt>ignoreMissingAuthentication</tt> option by setting it to "true".
* Setting ignoreMissingAuthentication=true will tell the * Setting ignoreMissingAuthentication=true will tell the
* SecureContextLoginModule to simply return false and be ignored if the * SecurityContextLoginModule to simply return false and be ignored if the
* authentication is null. * authentication is null.
* *
* @author Brian Moseley * @author Brian Moseley
* @author Ray Krueger * @author Ray Krueger
*/ */
public class SecureContextLoginModule implements LoginModule { public class SecurityContextLoginModule implements LoginModule {
//~ Static fields/initializers ============================================= //~ Static fields/initializers =============================================
private static final Log log = LogFactory.getLog(SecureContextLoginModule.class); private static final Log log = LogFactory.getLog(SecurityContextLoginModule.class);
//~ Instance fields ======================================================== //~ Instance fields ========================================================

View File

@ -28,12 +28,12 @@ import javax.servlet.http.HttpServletRequest;
/** /**
* A <code>Filter</code> which populates the <code>ServletRequest</code> with * A <code>Filter</code> which populates the <code>ServletRequest</code> with
* an {@link ContextHolderAwareRequestWrapper}. * an {@link SecurityContextHolderAwareRequestWrapper}.
* *
* @author Orlando Garcia Carmona * @author Orlando Garcia Carmona
* @version $Id$ * @version $Id$
*/ */
public class ContextHolderAwareRequestFilter implements Filter { public class SecurityContextHolderAwareRequestFilter implements Filter {
//~ Methods ================================================================ //~ Methods ================================================================
public void destroy() {} public void destroy() {}
@ -43,8 +43,8 @@ public class ContextHolderAwareRequestFilter implements Filter {
throws IOException, ServletException { throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletRequest request = (HttpServletRequest) servletRequest;
if (!(request instanceof ContextHolderAwareRequestWrapper)) { if (!(request instanceof SecurityContextHolderAwareRequestWrapper)) {
request = new ContextHolderAwareRequestWrapper(request); request = new SecurityContextHolderAwareRequestWrapper(request);
} }
filterChain.doFilter(request, servletResponse); filterChain.doFilter(request, servletResponse);

View File

@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRequestWrapper;
/** /**
* An Acegi Security-aware <code>HttpServletRequestWrapper</code>, which uses * An Acegi Security-aware <code>HttpServletRequestWrapper</code>, which uses
* the <code>SecurityContext</code>-defined <code>Authentication</code> object * the <code>SecurityContext</code>-defined <code>Authentication</code> object
* for {@link ContextHolderAwareRequestWrapper#isUserInRole(java.lang.String)} * for {@link SecurityContextHolderAwareRequestWrapper#isUserInRole(java.lang.String)}
* and {@link javax.servlet.http.HttpServletRequestWrapper#getRemoteUser()} * and {@link javax.servlet.http.HttpServletRequestWrapper#getRemoteUser()}
* responses. * responses.
* *
@ -38,14 +38,14 @@ import javax.servlet.http.HttpServletRequestWrapper;
* @author Ben Alex * @author Ben Alex
* @version $Id$ * @version $Id$
*/ */
public class ContextHolderAwareRequestWrapper extends HttpServletRequestWrapper { public class SecurityContextHolderAwareRequestWrapper extends HttpServletRequestWrapper {
//~ Instance fields ======================================================== //~ Instance fields ========================================================
private AuthenticationTrustResolver authenticationTrustResolver = new AuthenticationTrustResolverImpl(); private AuthenticationTrustResolver authenticationTrustResolver = new AuthenticationTrustResolverImpl();
//~ Constructors =========================================================== //~ Constructors ===========================================================
public ContextHolderAwareRequestWrapper(HttpServletRequest request) { public SecurityContextHolderAwareRequestWrapper(HttpServletRequest request) {
super(request); super(request);
} }

View File

@ -181,7 +181,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
executeFilterInContainerSimulator(new MockFilterConfig(), filter, executeFilterInContainerSimulator(new MockFilterConfig(), filter,
request, response, chain); request, response, chain);
// Obtain new/update Authentication from HttpSession // Obtain new/updated Authentication from HttpSession
SecurityContext context = (SecurityContext) request.getSession(false) SecurityContext context = (SecurityContext) request.getSession(false)
.getAttribute(HttpSessionContextIntegrationFilter.ACEGI_SECURITY_CONTEXT_KEY); .getAttribute(HttpSessionContextIntegrationFilter.ACEGI_SECURITY_CONTEXT_KEY);
assertEquals(updatedPrincipal, assertEquals(updatedPrincipal,
@ -204,7 +204,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
executeFilterInContainerSimulator(new MockFilterConfig(), filter, executeFilterInContainerSimulator(new MockFilterConfig(), filter,
request, response, chain); request, response, chain);
// Obtain new/update Authentication from HttpSession // Check the session is null
assertNull(request.getSession(false)); assertNull(request.getSession(false));
} }

View File

@ -30,14 +30,14 @@ import javax.security.auth.login.LoginException;
/** /**
* Testst SecureContextLoginModule * Tests SecurityContextLoginModule
* *
* @author Ray Krueger * @author Ray Krueger
*/ */
public class SecureContextLoginModuleTests extends TestCase { public class SecurityContextLoginModuleTests extends TestCase {
//~ Instance fields ======================================================== //~ Instance fields ========================================================
private SecureContextLoginModule module = null; private SecurityContextLoginModule module = null;
private Subject subject = new Subject(false, new HashSet(), new HashSet(), private Subject subject = new Subject(false, new HashSet(), new HashSet(),
new HashSet()); new HashSet());
private UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("principal", private UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken("principal",
@ -82,7 +82,7 @@ public class SecureContextLoginModuleTests extends TestCase {
subject.getPrincipals().contains(auth)); subject.getPrincipals().contains(auth));
} }
public void testNullAuthenticationInSecureContext() public void testNullAuthenticationInSecurityContext()
throws Exception { throws Exception {
try { try {
SecurityContextHolder.getContext().setAuthentication(null); SecurityContextHolder.getContext().setAuthentication(null);
@ -92,9 +92,9 @@ public class SecureContextLoginModuleTests extends TestCase {
} }
} }
public void testNullAuthenticationInSecureContextIgnored() public void testNullAuthenticationInSecurityContextIgnored()
throws Exception { throws Exception {
module = new SecureContextLoginModule(); module = new SecurityContextLoginModule();
Map options = new HashMap(); Map options = new HashMap();
options.put("ignoreMissingAuthentication", "true"); options.put("ignoreMissingAuthentication", "true");
@ -109,7 +109,7 @@ public class SecureContextLoginModuleTests extends TestCase {
} }
protected void setUp() throws Exception { protected void setUp() throws Exception {
module = new SecureContextLoginModule(); module = new SecurityContextLoginModule();
module.initialize(subject, null, null, null); module.initialize(subject, null, null, null);
SecurityContextHolder.setContext(new SecurityContextImpl()); SecurityContextHolder.setContext(new SecurityContextImpl());
} }

View File

@ -79,7 +79,7 @@ public class AuthorizeTagTests extends TestCase {
Tag.EVAL_BODY_INCLUDE, authorizeTag.doStartTag()); Tag.EVAL_BODY_INCLUDE, authorizeTag.doStartTag());
} }
public void testPreventsBodyOutputIfNoSecureContext() public void testPreventsBodyOutputIfNoSecurityContext()
throws JspException { throws JspException {
SecurityContextHolder.getContext().setAuthentication(null); SecurityContextHolder.getContext().setAuthentication(null);
authorizeTag.setIfAnyGranted("ROLE_BANKER"); authorizeTag.setIfAnyGranted("ROLE_BANKER");

View File

@ -19,8 +19,8 @@ import junit.framework.TestCase;
import net.sf.acegisecurity.MockFilterConfig; import net.sf.acegisecurity.MockFilterConfig;
import net.sf.acegisecurity.wrapper.ContextHolderAwareRequestFilter; import net.sf.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter;
import net.sf.acegisecurity.wrapper.ContextHolderAwareRequestWrapper; import net.sf.acegisecurity.wrapper.SecurityContextHolderAwareRequestWrapper;
import java.io.IOException; import java.io.IOException;
@ -33,19 +33,19 @@ import org.springframework.mock.web.MockHttpServletRequest;
/** /**
* Tests {@link ContextHolderAwareRequestFilter}. * Tests {@link SecurityContextHolderAwareRequestFilter}.
* *
* @author Ben Alex * @author Ben Alex
* @version $Id$ * @version $Id$
*/ */
public class ContextHolderAwareRequestFilterTests extends TestCase { public class SecurityContextHolderAwareRequestFilterTests extends TestCase {
//~ Constructors =========================================================== //~ Constructors ===========================================================
public ContextHolderAwareRequestFilterTests() { public SecurityContextHolderAwareRequestFilterTests() {
super(); super();
} }
public ContextHolderAwareRequestFilterTests(String arg0) { public SecurityContextHolderAwareRequestFilterTests(String arg0) {
super(arg0); super(arg0);
} }
@ -56,18 +56,18 @@ public class ContextHolderAwareRequestFilterTests extends TestCase {
} }
public static void main(String[] args) { public static void main(String[] args) {
junit.textui.TestRunner.run(ContextHolderAwareRequestFilterTests.class); junit.textui.TestRunner.run(SecurityContextHolderAwareRequestFilterTests.class);
} }
public void testCorrectOperation() throws Exception { public void testCorrectOperation() throws Exception {
ContextHolderAwareRequestFilter filter = new ContextHolderAwareRequestFilter(); SecurityContextHolderAwareRequestFilter filter = new SecurityContextHolderAwareRequestFilter();
filter.init(new MockFilterConfig()); filter.init(new MockFilterConfig());
filter.doFilter(new MockHttpServletRequest(null, null), null, filter.doFilter(new MockHttpServletRequest(null, null), null,
new MockFilterChain(ContextHolderAwareRequestWrapper.class)); new MockFilterChain(SecurityContextHolderAwareRequestWrapper.class));
// Now re-execute the filter, ensuring our replacement wrapper is still used // Now re-execute the filter, ensuring our replacement wrapper is still used
filter.doFilter(new MockHttpServletRequest(null, null), null, filter.doFilter(new MockHttpServletRequest(null, null), null,
new MockFilterChain(ContextHolderAwareRequestWrapper.class)); new MockFilterChain(SecurityContextHolderAwareRequestWrapper.class));
filter.destroy(); filter.destroy();
} }

View File

@ -23,25 +23,25 @@ import net.sf.acegisecurity.GrantedAuthorityImpl;
import net.sf.acegisecurity.context.SecurityContextHolder; import net.sf.acegisecurity.context.SecurityContextHolder;
import net.sf.acegisecurity.providers.TestingAuthenticationToken; import net.sf.acegisecurity.providers.TestingAuthenticationToken;
import net.sf.acegisecurity.providers.dao.User; import net.sf.acegisecurity.providers.dao.User;
import net.sf.acegisecurity.wrapper.ContextHolderAwareRequestWrapper; import net.sf.acegisecurity.wrapper.SecurityContextHolderAwareRequestWrapper;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
/** /**
* Tests {@link ContextHolderAwareRequestWrapper}. * Tests {@link SecurityContextHolderAwareRequestWrapper}.
* *
* @author Ben Alex * @author Ben Alex
* @version $Id$ * @version $Id$
*/ */
public class ContextHolderAwareRequestWrapperTests extends TestCase { public class SecurityContextHolderAwareRequestWrapperTests extends TestCase {
//~ Constructors =========================================================== //~ Constructors ===========================================================
public ContextHolderAwareRequestWrapperTests() { public SecurityContextHolderAwareRequestWrapperTests() {
super(); super();
} }
public ContextHolderAwareRequestWrapperTests(String arg0) { public SecurityContextHolderAwareRequestWrapperTests(String arg0) {
super(arg0); super(arg0);
} }
@ -52,7 +52,7 @@ public class ContextHolderAwareRequestWrapperTests extends TestCase {
} }
public static void main(String[] args) { public static void main(String[] args) {
junit.textui.TestRunner.run(ContextHolderAwareRequestWrapperTests.class); junit.textui.TestRunner.run(SecurityContextHolderAwareRequestWrapperTests.class);
} }
public void testCorrectOperationWithStringBasedPrincipal() public void testCorrectOperationWithStringBasedPrincipal()
@ -65,7 +65,7 @@ public class ContextHolderAwareRequestWrapperTests extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI("/"); request.setRequestURI("/");
ContextHolderAwareRequestWrapper wrapper = new ContextHolderAwareRequestWrapper(request); SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request);
assertEquals("marissa", wrapper.getRemoteUser()); assertEquals("marissa", wrapper.getRemoteUser());
assertTrue(wrapper.isUserInRole("ROLE_FOO")); assertTrue(wrapper.isUserInRole("ROLE_FOO"));
@ -87,7 +87,7 @@ public class ContextHolderAwareRequestWrapperTests extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI("/"); request.setRequestURI("/");
ContextHolderAwareRequestWrapper wrapper = new ContextHolderAwareRequestWrapper(request); SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request);
assertEquals("marissaAsUserDetails", wrapper.getRemoteUser()); assertEquals("marissaAsUserDetails", wrapper.getRemoteUser());
assertFalse(wrapper.isUserInRole("ROLE_FOO")); assertFalse(wrapper.isUserInRole("ROLE_FOO"));
@ -105,7 +105,7 @@ public class ContextHolderAwareRequestWrapperTests extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI("/"); request.setRequestURI("/");
ContextHolderAwareRequestWrapper wrapper = new ContextHolderAwareRequestWrapper(request); SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request);
assertNull(wrapper.getRemoteUser()); assertNull(wrapper.getRemoteUser());
assertFalse(wrapper.isUserInRole("ROLE_ANY")); assertFalse(wrapper.isUserInRole("ROLE_ANY"));
assertNull(wrapper.getUserPrincipal()); assertNull(wrapper.getUserPrincipal());
@ -122,7 +122,7 @@ public class ContextHolderAwareRequestWrapperTests extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI("/"); request.setRequestURI("/");
ContextHolderAwareRequestWrapper wrapper = new ContextHolderAwareRequestWrapper(request); SecurityContextHolderAwareRequestWrapper wrapper = new SecurityContextHolderAwareRequestWrapper(request);
assertNull(wrapper.getRemoteUser()); assertNull(wrapper.getRemoteUser());
assertFalse(wrapper.isUserInRole("ROLE_HELLO")); // principal is null, so reject assertFalse(wrapper.isUserInRole("ROLE_HELLO")); // principal is null, so reject