diff --git a/adapters/.cvsignore b/adapters/.cvsignore
deleted file mode 100644
index eb5a316cbd..0000000000
--- a/adapters/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-target
diff --git a/adapters/catalina/.cvsignore b/adapters/catalina/.cvsignore
deleted file mode 100644
index e6165555be..0000000000
--- a/adapters/catalina/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-target
-.settings
-.classpath
-.project
-.wtpmodules
diff --git a/adapters/catalina/pom.xml b/adapters/catalina/pom.xml
deleted file mode 100644
index c8b0253f0e..0000000000
--- a/adapters/catalina/pom.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
Returns a {@link
- * PrincipalSpringSecurityUserToken} to Catalina's authentication system, which is subsequently available via
- * HttpServletRequest.getUserPrincipal().
-
-
-
diff --git a/adapters/catalina/src/main/resources/org/springframework/security/adapters/catalinaAdapterTest-invalid.xml b/adapters/catalina/src/main/resources/org/springframework/security/adapters/catalinaAdapterTest-invalid.xml
deleted file mode 100644
index c0ccefb5e1..0000000000
--- a/adapters/catalina/src/main/resources/org/springframework/security/adapters/catalinaAdapterTest-invalid.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-java:comp/env/security/subject.
- *
This filter never preserves the Authentication on the ContextHolder -
- * it is replaced every request.
See {@link HttpSessionContextIntegrationFilter} for further information.
- * - * @author Ben Alex - * @version $Id$ - */ -public class JbossIntegrationFilter implements Filter { - //~ Static fields/initializers ===================================================================================== - - private static final Log logger = LogFactory.getLog(JbossIntegrationFilter.class); - - //~ Methods ======================================================================================================== - - /** - * Does nothing. We use IoC container lifecycle services instead. - */ - public void destroy() {} - - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - Object principal = extractFromContainer(request); - - if ((principal != null) && principal instanceof Authentication) { - SecurityContextHolder.getContext().setAuthentication((Authentication) principal); - - if (logger.isDebugEnabled()) { - logger.debug("ContextHolder updated with Authentication from container: '" + principal + "'"); - } - } else { - if (logger.isDebugEnabled()) { - logger.debug("ContextHolder not set with new Authentication as Principal was: '" + principal + "'"); - } - } - - chain.doFilter(request, response); - } - - private Object extractFromContainer(ServletRequest request) { - Subject subject = null; - - try { - Context lc = this.getLookupContext(); - - if (lc == null) { - if (logger.isWarnEnabled()) { - logger.warn("Could not obtain a Context to perform lookup"); - } - - return null; - } - - Object result = lc.lookup("java:comp/env/security/subject"); - - if (result instanceof Subject) { - subject = (Subject) result; - } - } catch (NamingException ne) { - if (logger.isWarnEnabled()) { - logger.warn("Lookup on Subject failed " + ne.getLocalizedMessage()); - } - } - - if ((subject != null) && (subject.getPrincipals() != null)) { - Iterator principals = subject.getPrincipals().iterator(); - - while (principals.hasNext()) { - Principal p = (Principal) principals.next(); - - if (p instanceof Authentication) { - return p; - } - } - } - - return null; - } - - /** - * Provided so that unit tests can override. - * - * @return aContext that can be used for lookup
- *
- * @throws NamingException DOCUMENT ME!
- */
- protected Context getLookupContext() throws NamingException {
- return new InitialContext();
- }
-
- /**
- * Does nothing. We use IoC container lifecycle services instead.
- *
- * @param arg0 ignored
- *
- * @throws ServletException ignored
- */
- public void init(FilterConfig arg0) throws ServletException {}
-}
diff --git a/adapters/jboss/src/main/java/org/springframework/security/adapters/jboss/JbossSpringSecurityLoginModule.java b/adapters/jboss/src/main/java/org/springframework/security/adapters/jboss/JbossSpringSecurityLoginModule.java
deleted file mode 100644
index 440ab1d5aa..0000000000
--- a/adapters/jboss/src/main/java/org/springframework/security/adapters/jboss/JbossSpringSecurityLoginModule.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jboss;
-
-import org.springframework.security.AccountExpiredException;
-import org.springframework.security.Authentication;
-import org.springframework.security.AuthenticationException;
-import org.springframework.security.AuthenticationManager;
-import org.springframework.security.CredentialsExpiredException;
-
-import org.springframework.security.adapters.PrincipalSpringSecurityUserToken;
-
-import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
-
-import org.jboss.security.SimpleGroup;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.security.auth.spi.AbstractServerLoginModule;
-
-import org.springframework.beans.factory.access.BeanFactoryLocator;
-import org.springframework.beans.factory.access.BeanFactoryReference;
-import org.springframework.beans.factory.access.SingletonBeanFactoryLocator;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.security.Principal;
-import java.security.acl.Group;
-
-import java.util.Map;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.FailedLoginException;
-import javax.security.auth.login.LoginException;
-
-
-/**
- * Adapter to enable JBoss to authenticate via the Spring Security System for Spring.
- * Returns a {@link PrincipalSpringSecurityUserToken} to JBoss' authentication system,
- * which is subsequently available from java:comp/env/security/subject.
-
-
-
diff --git a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/JbossIntegrationFilterTests.java b/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/JbossIntegrationFilterTests.java
deleted file mode 100644
index f56909d47c..0000000000
--- a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/JbossIntegrationFilterTests.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jboss;
-
-import junit.framework.TestCase;
-
-import org.springframework.security.GrantedAuthority;
-import org.springframework.security.GrantedAuthorityImpl;
-
-import org.springframework.security.adapters.PrincipalSpringSecurityUserToken;
-
-import org.springframework.security.context.SecurityContextHolder;
-import org.springframework.security.context.SecurityContextImpl;
-
-import org.springframework.mock.web.MockHttpServletRequest;
-
-import java.io.IOException;
-
-import java.security.Principal;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.naming.Context;
-
-import javax.security.auth.Subject;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-
-/**
- * Tests {@link JbossIntegrationFilter}.
- *
- * @author Ben Alex
- * @version $Id:JbossIntegrationFilterTests.java 2151 2007-09-22 11:54:13Z luke_t $
- */
-public class JbossIntegrationFilterTests extends TestCase {
- //~ Constructors ===================================================================================================
-
- public JbossIntegrationFilterTests() {
- super();
- }
-
- public JbossIntegrationFilterTests(String arg0) {
- super(arg0);
- }
-
- //~ Methods ========================================================================================================
-
- private void executeFilterInContainerSimulator(FilterConfig filterConfig, Filter filter, ServletRequest request,
- ServletResponse response, FilterChain filterChain)
- throws ServletException, IOException {
- filter.init(filterConfig);
- filter.doFilter(request, response, filterChain);
- filter.destroy();
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(JbossIntegrationFilterTests.class);
- }
-
- private Subject makeIntoSubject(Principal principal) {
- Set principals = new HashSet();
- principals.add(principal);
-
- return new Subject(false, principals, new HashSet(), new HashSet());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- SecurityContextHolder.setContext(new SecurityContextImpl());
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- SecurityContextHolder.setContext(new SecurityContextImpl());
- }
-
- public void testCorrectOperation() throws Exception {
- PrincipalSpringSecurityUserToken principal = new PrincipalSpringSecurityUserToken("key", "someone", "password",
- new GrantedAuthority[] {new GrantedAuthorityImpl("SOME_ROLE")}, null);
-
- JbossIntegrationFilter filter = new MockJbossIntegrationFilter(new MockInitialContext(makeIntoSubject(principal)));
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- MockFilterChain chain = new MockFilterChain();
-
- filter.doFilter(request, null, chain);
-
- assertEquals(principal, SecurityContextHolder.getContext().getAuthentication());
- SecurityContextHolder.setContext(new SecurityContextImpl());
- }
-
- public void testReturnsNullIfContextReturnsSomethingOtherThanASubject()
- throws Exception {
- JbossIntegrationFilter filter = new MockJbossIntegrationFilter(new MockInitialContext("THIS_IS_NOT_A_SUBJECT"));
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- MockFilterChain chain = new MockFilterChain();
-
- filter.doFilter(request, null, chain);
- assertNull(SecurityContextHolder.getContext().getAuthentication());
- }
-
- public void testReturnsNullIfInitialContextHasNullPrincipal()
- throws Exception {
- JbossIntegrationFilter filter = new MockJbossIntegrationFilter(new MockInitialContext(makeIntoSubject(null)));
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- MockFilterChain chain = new MockFilterChain();
-
- filter.doFilter(request, null, chain);
- assertNull(SecurityContextHolder.getContext().getAuthentication());
- }
-
- public void testReturnsNullIfInitialContextHasNullSubject()
- throws Exception {
- JbossIntegrationFilter filter = new MockJbossIntegrationFilter(new MockInitialContext(null));
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- MockFilterChain chain = new MockFilterChain();
-
- filter.doFilter(request, null, chain);
- assertNull(SecurityContextHolder.getContext().getAuthentication());
- }
-
- public void testReturnsNullIfInitialContextIsNull()
- throws Exception {
- JbossIntegrationFilter filter = new MockJbossIntegrationFilter(null);
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- MockFilterChain chain = new MockFilterChain();
-
- filter.doFilter(request, null, chain);
- assertNull(SecurityContextHolder.getContext().getAuthentication());
- }
-
- public void testReturnsNullIfPrincipalNotAnAuthenticationImplementation()
- throws Exception {
- JbossIntegrationFilter filter = new MockJbossIntegrationFilter(new MockInitialContext(makeIntoSubject(
- new Principal() {
- public String getName() {
- return "MockPrincipal";
- }
- })));
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- MockFilterChain chain = new MockFilterChain();
-
- filter.doFilter(request, null, chain);
- assertNull(SecurityContextHolder.getContext().getAuthentication());
- }
-
- public void testTestingObjectReturnsInitialContext()
- throws Exception {
- JbossIntegrationFilter filter = new JbossIntegrationFilter();
- assertTrue(filter.getLookupContext() instanceof Context);
- }
-
- //~ Inner Classes ==================================================================================================
-
- private class MockFilterChain implements FilterChain {
- public void doFilter(ServletRequest arg0, ServletResponse arg1)
- throws IOException, ServletException {}
- }
-}
diff --git a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/JbossSpringSecurityLoginModuleTests.java b/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/JbossSpringSecurityLoginModuleTests.java
deleted file mode 100644
index cc77a7c8ab..0000000000
--- a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/JbossSpringSecurityLoginModuleTests.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jboss;
-
-import junit.framework.TestCase;
-
-import org.springframework.security.adapters.PrincipalSpringSecurityUserToken;
-
-import org.jboss.security.SimplePrincipal;
-
-import java.io.IOException;
-
-import java.security.Principal;
-import java.security.acl.Group;
-
-import java.util.Properties;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.FailedLoginException;
-import javax.security.auth.login.LoginException;
-
-
-/**
- * Tests {@link JbossSpringSecurityLoginModule}.
- *
- * @author Ben Alex
- * @version $Id:JbossSpringSecurityLoginModuleTests.java 2151 2007-09-22 11:54:13Z luke_t $
- */
-public class JbossSpringSecurityLoginModuleTests extends TestCase {
- //~ Instance fields ================================================================================================
-
- private final String ADAPTER_KEY = "my_key";
-
- //~ Constructors ===================================================================================================
-
- public JbossSpringSecurityLoginModuleTests() {
- super();
- }
-
- public JbossSpringSecurityLoginModuleTests(String arg0) {
- super(arg0);
- }
-
- //~ Methods ========================================================================================================
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(JbossSpringSecurityLoginModuleTests.class);
- }
-
- public final void setUp() throws Exception {
- super.setUp();
- }
-
- public void testAdapterAbortsIfAppContextDoesNotContainAnAuthenticationBean()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-invalid.xml");
-
- try {
- adapter.initialize(null, null, null, props);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertTrue(true);
- }
- }
-
- public void testAdapterAbortsIfNoAppContextSpecified()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
-
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
-
- try {
- adapter.initialize(null, null, null, props);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("appContextLocation must be defined", expected.getMessage());
- }
-
- props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "");
-
- try {
- adapter.initialize(null, null, null, props);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("appContextLocation must be defined", expected.getMessage());
- }
- }
-
- public void testAdapterAbortsIfNoKeySpecified() throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
-
- Properties props = new Properties();
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- try {
- adapter.initialize(null, null, null, props);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("key must be defined", expected.getMessage());
- }
-
- props = new Properties();
- props.put("key", "");
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- try {
- adapter.initialize(null, null, null, props);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("key must be defined", expected.getMessage());
- }
- }
-
- public void testAdapterAbortsWithIncorrectApplicationContextLocation()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
-
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "INVALID_PATH");
-
- try {
- adapter.initialize(null, null, null, props);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertTrue("Cannot locate INVALID_PATH".equals(expected.getMessage()));
- }
- }
-
- public void testAdapterFailsToAuthenticateIfNoCallbackHandlerAvailable()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
-
- adapter.initialize(subject, null, null, props);
-
- try {
- adapter.login();
- } catch (LoginException loginException) {
- assertEquals("Error: no CallbackHandler available to collect authentication information",
- loginException.getMessage());
- }
- }
-
- public void testAdapterStartsUpSuccess() throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
- adapter.initialize(null, null, null, props);
- assertTrue(true);
- }
-
- public void testAuthenticationFailsForIncorrectPassword()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
- CallbackHandler callback = new MockCallbackHandler("rod", "kangaroo");
-
- adapter.initialize(subject, callback, null, props);
-
- try {
- adapter.login();
- fail("Should have thrown FailedLoginException");
- } catch (FailedLoginException expected) {
- assertTrue(true);
- }
- }
-
- public void testAuthenticationFailsForIncorrectUserName()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
- CallbackHandler callback = new MockCallbackHandler("melissa", "koala");
-
- adapter.initialize(subject, callback, null, props);
-
- try {
- adapter.login();
- fail("Should have thrown FailedLoginException");
- } catch (FailedLoginException expected) {
- assertTrue(true);
- }
- }
-
- public void testAuthenticationSuccess() throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
- CallbackHandler callback = new MockCallbackHandler("rod", "koala");
-
- adapter.initialize(subject, callback, null, props);
- assertTrue(adapter.login());
-
- Principal result = adapter.getIdentity();
-
- if (!(result instanceof PrincipalSpringSecurityUserToken)) {
- fail("Should have returned PrincipalSpringSecurityUserToken");
- }
-
- PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result;
- assertEquals("rod", castResult.getPrincipal());
- assertEquals("koala", castResult.getCredentials());
- assertEquals("ROLE_TELLER", castResult.getAuthorities()[1].getAuthority());
- assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[0].getAuthority());
- assertEquals(ADAPTER_KEY.hashCode(), castResult.getKeyHash());
- }
-
- public void testAuthenticationWithNullPasswordHandledGracefully()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
- CallbackHandler callback = new MockCallbackHandler("rod", null);
-
- adapter.initialize(subject, callback, null, props);
-
- try {
- adapter.login();
- fail("Should have thrown FailedLoginException");
- } catch (FailedLoginException expected) {
- assertTrue(true);
- }
- }
-
- public void testAuthenticationWithNullUserNameAndNullPasswordHandledGracefully()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
- CallbackHandler callback = new MockCallbackHandler(null, null);
-
- adapter.initialize(subject, callback, null, props);
-
- try {
- adapter.login();
- fail("Should have thrown FailedLoginException");
- } catch (FailedLoginException expected) {
- assertTrue(true);
- }
- }
-
- public void testAuthenticationWithNullUserNameHandledGracefully()
- throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
- CallbackHandler callback = new MockCallbackHandler(null, "kangaroo");
-
- adapter.initialize(subject, callback, null, props);
-
- try {
- adapter.login();
- fail("Should have thrown FailedLoginException");
- } catch (FailedLoginException expected) {
- assertTrue(true);
- }
- }
-
- public void testGetRoleSets() throws Exception {
- JbossSpringSecurityLoginModule adapter = new JbossSpringSecurityLoginModule();
- Properties props = new Properties();
- props.put("key", ADAPTER_KEY);
- props.put("appContextLocation", "org/springframework/security/adapters/adaptertest-valid.xml");
-
- Subject subject = new Subject();
- CallbackHandler callback = new MockCallbackHandler("rod", "koala");
-
- adapter.initialize(subject, callback, null, props);
- assertTrue(adapter.login());
-
- Group[] result = adapter.getRoleSets();
- // Expect Roles group.
- assertEquals(1, result.length);
-
- Group roles = result[0];
- assertTrue(roles.isMember(new SimplePrincipal("ROLE_TELLER")));
- assertTrue(roles.isMember(new SimplePrincipal("ROLE_SUPERVISOR")));
- }
-
- //~ Inner Classes ==================================================================================================
-
- private class MockCallbackHandler implements CallbackHandler {
- private String password;
- private String username;
-
- public MockCallbackHandler(String username, String password) {
- this.username = username;
- this.password = password;
- }
-
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
- ((NameCallback) callbacks[i]).setName(username);
- } else if (callbacks[i] instanceof PasswordCallback) {
- if (this.password == null) {
- ((PasswordCallback) callbacks[i]).setPassword(null);
- } else {
- ((PasswordCallback) callbacks[i]).setPassword(password.toCharArray());
- }
- } else {
- throw new UnsupportedCallbackException(callbacks[i]);
- }
- }
- }
- }
-}
diff --git a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/MockInitialContext.java b/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/MockInitialContext.java
deleted file mode 100644
index 2a7234847d..0000000000
--- a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/MockInitialContext.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jboss;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-
-
-/**
- * Mocks a javax.naming.Context and returns an Object when queried for address
- * java:comp/env/security/subject.
- *
- * @author Ben Alex
- * @version $Id:MockInitialContext.java 2151 2007-09-22 11:54:13Z luke_t $
- */
-public class MockInitialContext implements Context {
- //~ Instance fields ================================================================================================
-
- private Object object;
-
- //~ Constructors ===================================================================================================
-
- public MockInitialContext(Object object) {
- this.object = object;
- }
-
- //~ Methods ========================================================================================================
-
- public Object addToEnvironment(String propName, Object propVal)
- throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void bind(String name, Object obj) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void bind(Name name, Object obj) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void close() throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public String composeName(String name, String prefix)
- throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Name composeName(Name name, Name prefix) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Context createSubcontext(String name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Context createSubcontext(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void destroySubcontext(String name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void destroySubcontext(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Hashtable getEnvironment() throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public String getNameInNamespace() throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public NameParser getNameParser(String name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public NameParser getNameParser(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public NamingEnumeration list(String name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public NamingEnumeration list(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public NamingEnumeration listBindings(String name)
- throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public NamingEnumeration listBindings(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Object lookup(String name) throws NamingException {
- return this.object;
- }
-
- public Object lookup(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Object lookupLink(String name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Object lookupLink(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void rebind(String name, Object obj) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void rebind(Name name, Object obj) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public Object removeFromEnvironment(String propName)
- throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void rename(String oldName, String newName)
- throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void rename(Name oldName, Name newName) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void unbind(String name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public void unbind(Name name) throws NamingException {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-}
diff --git a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/MockJbossIntegrationFilter.java b/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/MockJbossIntegrationFilter.java
deleted file mode 100644
index f2c19eb0c4..0000000000
--- a/adapters/jboss/src/test/java/org/springframework/security/adapters/jboss/MockJbossIntegrationFilter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jboss;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-
-/**
- * Provides mock of JbossIntegrationFilter, using a lookup Context provided in the
- * constructor.
- *
- * @author Ben Alex
- * @version $Id:MockJbossIntegrationFilter.java 2151 2007-09-22 11:54:13Z luke_t $
- */
-public class MockJbossIntegrationFilter extends JbossIntegrationFilter {
- //~ Instance fields ================================================================================================
-
- private Context context;
-
- //~ Constructors ===================================================================================================
-
- public MockJbossIntegrationFilter(Context context) {
- this.context = context;
- }
-
- //~ Methods ========================================================================================================
-
- protected Context getLookupContext() throws NamingException {
- return this.context;
- }
-}
diff --git a/adapters/jetty/.cvsignore b/adapters/jetty/.cvsignore
deleted file mode 100644
index e6165555be..0000000000
--- a/adapters/jetty/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-target
-.settings
-.classpath
-.project
-.wtpmodules
diff --git a/adapters/jetty/pom.xml b/adapters/jetty/pom.xml
deleted file mode 100644
index 86bf919518..0000000000
--- a/adapters/jetty/pom.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
Returns a {@link
- * JettySpringSecurityUserToken} to Jetty's authentication system, which is subsequently available via
- * HttpServletRequest.getUserPrincipal().
SpringUserRealm.
- *
- * @param realm the name of the authentication realm (within Jetty)
- * @param providerKey a password to sign all authentication objects
- * @param appContextLocation the classpath location of the bean context XML
- * file
- *
- * @throws IllegalArgumentException DOCUMENT ME!
- */
- public JettySpringSecurityUserRealm(String realm, String providerKey, String appContextLocation) {
- this.realm = realm;
- this.key = providerKey;
-
- if ((realm == null) || "".equals(realm)) {
- throw new IllegalArgumentException("realm must be specified");
- }
-
- if ((key == null) || "".equals(key)) {
- throw new IllegalArgumentException("key must be specified");
- }
-
- if ((appContextLocation == null) || "".equals(appContextLocation)) {
- throw new IllegalArgumentException("appContextLocation must be specified");
- }
-
- if (Thread.currentThread().getContextClassLoader().getResource(appContextLocation) == null) {
- throw new IllegalArgumentException("Cannot locate " + appContextLocation);
- }
-
- ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(appContextLocation);
- Map beans = ctx.getBeansOfType(AuthenticationManager.class, true, true);
-
- if (beans.size() == 0) {
- throw new IllegalArgumentException(
- "Bean context must contain at least one bean of type AuthenticationManager");
- }
-
- String beanName = (String) beans.keySet().iterator().next();
- authenticationManager = (AuthenticationManager) beans.get(beanName);
- }
-
- protected JettySpringSecurityUserRealm() {
- throw new IllegalArgumentException("Cannot use default constructor");
- }
-
- //~ Methods ========================================================================================================
-
- public UserPrincipal authenticate(String username, Object password, HttpRequest httpRequest) {
- if (username == null) {
- return null;
- }
-
- if (password == null) {
- password = "";
- }
-
- Authentication request = new UsernamePasswordAuthenticationToken(username.toString(), password.toString());
- Authentication response = null;
-
- try {
- response = authenticationManager.authenticate(request);
- } catch (AuthenticationException failed) {
- if (logger.isDebugEnabled()) {
- logger.debug("Authentication request for user: " + username + " failed: " + failed.toString());
- }
-
- return null;
- }
-
- return new JettySpringSecurityUserToken(this.key, response.getPrincipal().toString(),
- response.getCredentials().toString(), response.getAuthorities());
- }
-
- public void disassociate(UserPrincipal userPrincipal) {
- // No action required
- }
-
- public AuthenticationManager getAuthenticationManager() {
- return authenticationManager;
- }
-
- /**
- * Accesses the realm name.
- *
- * @return the name of the realm as defined when SpringUserRealm was created
- */
- public String getName() {
- return this.realm;
- }
-
- public void logout(UserPrincipal arg0) {
- // Not supported
- }
-
- public UserPrincipal popRole(UserPrincipal userPrincipal) {
- // Not supported
- return userPrincipal;
- }
-
- public UserPrincipal pushRole(UserPrincipal userPrincipal, String role) {
- // Not supported
- return userPrincipal;
- }
-}
diff --git a/adapters/jetty/src/main/java/org/springframework/security/adapters/jetty/JettySpringSecurityUserToken.java b/adapters/jetty/src/main/java/org/springframework/security/adapters/jetty/JettySpringSecurityUserToken.java
deleted file mode 100644
index 38ba7e37b0..0000000000
--- a/adapters/jetty/src/main/java/org/springframework/security/adapters/jetty/JettySpringSecurityUserToken.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jetty;
-
-import org.springframework.security.GrantedAuthority;
-
-import org.springframework.security.adapters.AbstractAdapterAuthenticationToken;
-
-import org.mortbay.http.UserPrincipal;
-
-
-/**
- * A Jetty compatible {@link org.springframework.security.Authentication} object.
- *
- * @author Ben Alex
- * @version $Id:JettySpringSecurityUserToken.java 2151 2007-09-22 11:54:13Z luke_t $
- */
-public class JettySpringSecurityUserToken extends AbstractAdapterAuthenticationToken implements UserPrincipal {
- //~ Instance fields ================================================================================================
-
- private static final long serialVersionUID = 1L;
- private String password;
- private String username;
-
- //~ Constructors ===================================================================================================
-
- public JettySpringSecurityUserToken(String key, String username, String password, GrantedAuthority[] authorities) {
- super(key, authorities);
- this.username = username;
- this.password = password;
- }
-
- protected JettySpringSecurityUserToken() {
- throw new IllegalArgumentException("Cannot use default constructor");
- }
-
- //~ Methods ========================================================================================================
-
- public Object getCredentials() {
- return this.password;
- }
-
- public String getName() {
- return this.username;
- }
-
- public Object getPrincipal() {
- return this.username;
- }
-}
diff --git a/adapters/jetty/src/main/java/org/springframework/security/adapters/jetty/package.html b/adapters/jetty/src/main/java/org/springframework/security/adapters/jetty/package.html
deleted file mode 100644
index f307ffa811..0000000000
--- a/adapters/jetty/src/main/java/org/springframework/security/adapters/jetty/package.html
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-Adapter to Jetty web container.
-
-
-
-
diff --git a/adapters/jetty/src/test/java/org/springframework/security/adapters/jetty/JettyAcegiUserRealmTests.java b/adapters/jetty/src/test/java/org/springframework/security/adapters/jetty/JettyAcegiUserRealmTests.java
deleted file mode 100644
index eb86fe049b..0000000000
--- a/adapters/jetty/src/test/java/org/springframework/security/adapters/jetty/JettyAcegiUserRealmTests.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jetty;
-
-import junit.framework.TestCase;
-
-import org.mortbay.http.UserPrincipal;
-
-
-/**
- * Tests {@link JettySpringSecurityUserRealm}.
- *
- * @author Ben Alex
- * @version $Id:JettyAcegiUserRealmTests.java 2151 2007-09-22 11:54:13Z luke_t $
- */
-public class JettyAcegiUserRealmTests extends TestCase {
- //~ Instance fields ================================================================================================
-
- private final String ADAPTER_KEY = "my_key";
- private final String REALM_NAME = "Acegi Powered Realm";
-
- //~ Constructors ===================================================================================================
-
- public JettyAcegiUserRealmTests() {
- super();
- }
-
- public JettyAcegiUserRealmTests(String arg0) {
- super(arg0);
- }
-
- //~ Methods ========================================================================================================
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(JettyAcegiUserRealmTests.class);
- }
-
- private JettySpringSecurityUserRealm makeAdapter(String fileName)
- throws Exception {
- String useFile = "org/springframework/security/adapters/" + fileName;
-
- return new JettySpringSecurityUserRealm(REALM_NAME, ADAPTER_KEY, useFile);
- }
-
- public final void setUp() throws Exception {
- super.setUp();
- }
-
- public void testAdapterAbortsIfAppContextDoesNotContainAnAuthenticationBean()
- throws Exception {
- try {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-invalid.xml");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("Bean context must contain at least one bean of type AuthenticationManager",
- expected.getMessage());
- }
- }
-
- public void testAdapterAbortsIfNoAppContextSpecified()
- throws Exception {
- try {
- new JettySpringSecurityUserRealm(REALM_NAME, ADAPTER_KEY, null);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("appContextLocation must be specified", expected.getMessage());
- }
-
- try {
- new JettySpringSecurityUserRealm(REALM_NAME, ADAPTER_KEY, "");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("appContextLocation must be specified", expected.getMessage());
- }
- }
-
- public void testAdapterAbortsIfNoKeySpecified() throws Exception {
- try {
- new JettySpringSecurityUserRealm(REALM_NAME, null, "SOME_PATH");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("key must be specified", expected.getMessage());
- }
-
- try {
- new JettySpringSecurityUserRealm(REALM_NAME, "", "SOME_PATH");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("key must be specified", expected.getMessage());
- }
- }
-
- public void testAdapterAbortsIfNoRealmNameSpecified()
- throws Exception {
- try {
- new JettySpringSecurityUserRealm(null, ADAPTER_KEY, "SOME_PATH");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("realm must be specified", expected.getMessage());
- }
-
- try {
- new JettySpringSecurityUserRealm(null, ADAPTER_KEY, "SOME_PATH");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertEquals("realm must be specified", expected.getMessage());
- }
- }
-
- public void testAdapterAbortsWithIncorrectApplicationContextLocation()
- throws Exception {
- try {
- new JettySpringSecurityUserRealm(REALM_NAME, ADAPTER_KEY, "SOME_INVALID_LOCATION");
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertTrue(expected.getMessage().startsWith("Cannot locate"));
- }
- }
-
- public void testAdapterIdentifiesTheRealmItManages()
- throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- assertEquals(REALM_NAME, adapter.getName());
- }
-
- public void testAdapterStartsUpSuccess() throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- assertTrue(true);
- }
-
- public void testAuthenticationFailsForIncorrectPassword()
- throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- assertEquals(null, adapter.authenticate("rod", "kangaroo", null));
- }
-
- public void testAuthenticationFailsForIncorrectUserName()
- throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- assertEquals(null, adapter.authenticate("melissa", "koala", null));
- }
-
- public void testAuthenticationSuccess() throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- UserPrincipal result = adapter.authenticate("rod", "koala", null);
-
- if (!(result instanceof JettySpringSecurityUserToken)) {
- fail("Should have returned JettySpringSecurityUserToken");
- }
-
- JettySpringSecurityUserToken castResult = (JettySpringSecurityUserToken) result;
- assertEquals("rod", castResult.getPrincipal());
- assertEquals("koala", castResult.getCredentials());
- assertEquals("ROLE_TELLER", castResult.getAuthorities()[1].getAuthority());
- assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[0].getAuthority());
- assertEquals(ADAPTER_KEY.hashCode(), castResult.getKeyHash());
- }
-
- public void testAuthenticationWithNullPasswordHandledGracefully()
- throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- assertEquals(null, adapter.authenticate("rod", null, null));
- }
-
- public void testAuthenticationWithNullUserNameHandledGracefully()
- throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- assertEquals(null, adapter.authenticate(null, "koala", null));
- }
-
- public void testDisassociateImplemented() throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- adapter.disassociate(new MockUserPrincipal());
- assertTrue(true);
- }
-
- public void testGetAuthenticationManager() throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- assertTrue(adapter.getAuthenticationManager() != null);
- }
-
- public void testLogoutImplemented() throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- adapter.logout(new MockUserPrincipal());
- assertTrue(true);
- }
-
- public void testNoArgsConstructor() {
- try {
- new JettySpringSecurityUserRealm();
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertTrue(true);
- }
- }
-
- public void testPopRoleImplemented() throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- MockUserPrincipal user = new MockUserPrincipal();
- assertEquals(user, adapter.popRole(user));
- }
-
- public void testPushRoleImplemented() throws Exception {
- JettySpringSecurityUserRealm adapter = makeAdapter("adaptertest-valid.xml");
- MockUserPrincipal user = new MockUserPrincipal();
- assertEquals(user, adapter.pushRole(user, "SOME_ROLE"));
- }
-
- //~ Inner Classes ==================================================================================================
-
- private class MockUserPrincipal implements UserPrincipal {
- public String getName() {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public boolean isAuthenticated() {
- throw new UnsupportedOperationException("mock method not implemented");
- }
-
- public boolean isUserInRole(String arg0) {
- throw new UnsupportedOperationException("mock method not implemented");
- }
- }
-}
diff --git a/adapters/jetty/src/test/java/org/springframework/security/adapters/jetty/JettySpringSecurityUserTokenTests.java b/adapters/jetty/src/test/java/org/springframework/security/adapters/jetty/JettySpringSecurityUserTokenTests.java
deleted file mode 100644
index b90af40b3f..0000000000
--- a/adapters/jetty/src/test/java/org/springframework/security/adapters/jetty/JettySpringSecurityUserTokenTests.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.security.adapters.jetty;
-
-import junit.framework.TestCase;
-
-import org.springframework.security.GrantedAuthority;
-import org.springframework.security.GrantedAuthorityImpl;
-
-
-/**
- * Tests {@link JettySpringSecurityUserToken}.
- *
- * @author Ben Alex
- * @version $Id:JettySpringSecurityUserTokenTests.java 2151 2007-09-22 11:54:13Z luke_t $
- */
-public class JettySpringSecurityUserTokenTests extends TestCase {
- //~ Constructors ===================================================================================================
-
- public JettySpringSecurityUserTokenTests() {
- }
-
- public JettySpringSecurityUserTokenTests(String arg0) {
- super(arg0);
- }
-
- //~ Methods ========================================================================================================
-
- public void testGetters() throws Exception {
- JettySpringSecurityUserToken token = new JettySpringSecurityUserToken("my_password", "Test", "Password",
- new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")});
- assertEquals("Test", token.getPrincipal());
- assertEquals("Password", token.getCredentials());
- assertEquals("my_password".hashCode(), token.getKeyHash());
- assertEquals("Test", token.getName());
- }
-
- public void testNoArgsConstructor() {
- try {
- new JettySpringSecurityUserToken();
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- assertTrue(true);
- }
- }
-}
diff --git a/adapters/pom.xml b/adapters/pom.xml
deleted file mode 100644
index 60a1e97c63..0000000000
--- a/adapters/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
Returns a {@link
- * PrincipalSpringSecurityUserToken} to Resin's authentication system, which is subsequently available via
- * HttpServletRequest.getUserPrincipal().
- - - diff --git a/adapters/resin/src/test/java/org/springframework/security/adapters/resin/ResinAcegiAuthenticatorTests.java b/adapters/resin/src/test/java/org/springframework/security/adapters/resin/ResinAcegiAuthenticatorTests.java deleted file mode 100644 index 4278507cd4..0000000000 --- a/adapters/resin/src/test/java/org/springframework/security/adapters/resin/ResinAcegiAuthenticatorTests.java +++ /dev/null @@ -1,261 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.security.adapters.resin; - -import junit.framework.TestCase; - -import org.springframework.security.GrantedAuthority; -import org.springframework.security.GrantedAuthorityImpl; - -import org.springframework.security.adapters.PrincipalSpringSecurityUserToken; - -import java.security.Principal; - -import javax.servlet.ServletException; - - -/** - * Tests {@link ResinAcegiAuthenticator}. - * - * @author Ben Alex - * @version $Id:ResinAcegiAuthenticatorTests.java 2151 2007-09-22 11:54:13Z luke_t $ - */ -public class ResinAcegiAuthenticatorTests extends TestCase { - //~ Instance fields ================================================================================================ - - private final String ADAPTER_KEY = "my_key"; - - //~ Constructors =================================================================================================== - - public ResinAcegiAuthenticatorTests() { - super(); - } - - public ResinAcegiAuthenticatorTests(String arg0) { - super(arg0); - } - - //~ Methods ======================================================================================================== - - public static void main(String[] args) { - junit.textui.TestRunner.run(ResinAcegiAuthenticatorTests.class); - } - - public final void setUp() throws Exception { - super.setUp(); - } - - public void testAdapterAbortsIfAppContextDoesNotContainAnAuthenticationBean() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-invalid.xml"); - adapter.setKey(ADAPTER_KEY); - - try { - adapter.init(); - fail("Should have thrown ServletException"); - } catch (ServletException expected) { - assertEquals("Bean context must contain at least one bean of type AuthenticationManager", - expected.getMessage()); - } - } - - public void testAdapterAbortsIfNoAppContextSpecified() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setKey(ADAPTER_KEY); - - try { - adapter.init(); - fail("Should have thrown ServletException"); - } catch (ServletException expected) { - assertEquals("appContextLocation must be defined", expected.getMessage()); - } - - adapter.setAppContextLocation(""); - - try { - adapter.init(); - fail("Should have thrown ServletException"); - } catch (ServletException expected) { - assertEquals("appContextLocation must be defined", expected.getMessage()); - } - } - - public void testAdapterAbortsIfNoKeySpecified() throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - - try { - adapter.init(); - fail("Should have thrown ServletException"); - } catch (ServletException expected) { - assertEquals("key must be defined", expected.getMessage()); - } - - adapter.setKey(""); - - try { - adapter.init(); - fail("Should have thrown ServletException"); - } catch (ServletException expected) { - assertEquals("key must be defined", expected.getMessage()); - } - } - - public void testAdapterAbortsWithIncorrectApplicationContextLocation() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("FILE_DOES_NOT_EXIST"); - adapter.setKey(ADAPTER_KEY); - - try { - adapter.init(); - fail("Should have thrown ServletException"); - } catch (ServletException expected) { - assertTrue(expected.getMessage().startsWith("Cannot locate")); - } - } - - public void testAdapterStartsUpSuccess() throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertTrue(true); - } - - public void testAuthenticationFailsForIncorrectPassword() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertEquals(null, adapter.loginImpl("rod", "kangaroo")); - } - - public void testAuthenticationFailsForIncorrectUserName() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertEquals(null, adapter.loginImpl("melissa", "koala")); - } - - public void testAuthenticationSuccess() throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - - Principal result = adapter.loginImpl("rod", "koala"); - - if (!(result instanceof PrincipalSpringSecurityUserToken)) { - fail("Should have returned PrincipalSpringSecurityUserToken"); - } - - PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result; - assertEquals("rod", castResult.getPrincipal()); - assertEquals("koala", castResult.getCredentials()); - assertEquals("ROLE_TELLER", castResult.getAuthorities()[1].getAuthority()); - assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[0].getAuthority()); - assertEquals(ADAPTER_KEY.hashCode(), castResult.getKeyHash()); - } - - public void testAuthenticationSuccessUsingAlternateMethod() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - - Principal result = adapter.loginImpl(null, null, null, "rod", "koala"); - - if (!(result instanceof PrincipalSpringSecurityUserToken)) { - fail("Should have returned PrincipalSpringSecurityUserToken"); - } - - PrincipalSpringSecurityUserToken castResult = (PrincipalSpringSecurityUserToken) result; - assertEquals("rod", castResult.getPrincipal()); - assertEquals("koala", castResult.getCredentials()); - assertEquals("ROLE_TELLER", castResult.getAuthorities()[1].getAuthority()); - assertEquals("ROLE_SUPERVISOR", castResult.getAuthorities()[0].getAuthority()); - assertEquals(ADAPTER_KEY.hashCode(), castResult.getKeyHash()); - } - - public void testAuthenticationWithNullPasswordHandledGracefully() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertEquals(null, adapter.loginImpl("rod", null)); - } - - public void testAuthenticationWithNullUserNameHandledGracefully() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertEquals(null, adapter.loginImpl(null, "koala")); - } - - public void testGetters() throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - assertEquals(ADAPTER_KEY, adapter.getKey()); - assertEquals("org/springframework/security/adapters/adaptertest-valid.xml", adapter.getAppContextLocation()); - } - - public void testHasRoleWithANullPrincipalFails() throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertTrue(!adapter.isUserInRole(null, null, null, null, "ROLE_ONE")); - } - - public void testHasRoleWithAPrincipalTheAdapterDidNotCreateFails() - throws Exception { - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertTrue(!adapter.isUserInRole(null, null, null, - new Principal() { - public String getName() { - return "MockPrincipal"; - } - }, "ROLE_ONE")); - } - - public void testHasRoleWithPrincipalAcegiUserToken() - throws Exception { - PrincipalSpringSecurityUserToken token = new PrincipalSpringSecurityUserToken("KEY", "Test", "Password", - new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_TWO")}, - null); - ResinAcegiAuthenticator adapter = new ResinAcegiAuthenticator(); - adapter.setAppContextLocation("org/springframework/security/adapters/adaptertest-valid.xml"); - adapter.setKey(ADAPTER_KEY); - adapter.init(); - assertTrue(adapter.isUserInRole(null, null, null, token, "ROLE_ONE")); - assertTrue(adapter.isUserInRole(null, null, null, token, "ROLE_ONE")); - assertTrue(!adapter.isUserInRole(null, null, null, token, "ROLE_WE_DO_NOT_HAVE")); - } -}