diff --git a/sandbox/spring-security-config/.classpath b/sandbox/spring-security-config/.classpath
deleted file mode 100644
index 921f13b43f..0000000000
--- a/sandbox/spring-security-config/.classpath
+++ /dev/null
@@ -1,47 +0,0 @@
-SecurityContextHolder
.
For a detailed background on what this filter is designed to process, - * refer to RFC 1945, Section 11.1. Any realm name presented in - * the HTTP request is ignored.
- *In summary, this filter is responsible for processing any request that has a HTTP request header of
- * Authorization
with an authentication scheme of Basic
and a Base64-encoded
- * username:password
token. For example, to authenticate user "Aladdin" with password "open sesame" the
- * following header would be presented:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
.
This filter can be used to provide BASIC authentication services to both remoting protocol clients (such as - * Hessian and SOAP) as well as standard user agents (such as Internet Explorer and Netscape).
- *If authentication is successful, the resulting {@link Authentication} object will be placed into the
- * SecurityContextHolder
.
If authentication fails and ignoreFailure
is false
(the default), an {@link
- * AuthenticationEntryPoint} implementation is called. Usually this should be {@link BasicProcessingFilterEntryPoint},
- * which will prompt the user to authenticate again via BASIC authentication.
Basic authentication is an attractive protocol because it is simple and widely deployed. However, it still - * transmits a password in clear text and as such is undesirable in many situations. Digest authentication is also - * provided by Acegi Security and should be used instead of Basic authentication wherever possible. See {@link - * org.acegisecurity.ui.digestauth.DigestProcessingFilter}.
- *Note that if a {@link #rememberMeServices} is set, this filter will automatically send back remember-me - * details to the client. Therefore, subsequent requests will not need to present a BASIC authentication header as - * they will be authenticated using the remember-me mechanism.
- *Do not use this class directly. Instead configure web.xml
to use the {@link
- * org.acegisecurity.util.FilterToBeanProxy}.
SecurityEnforcementFilter
to commence
- * authentication via the {@link BasicProcessingFilter}.
- * - * Once a user agent is authenticated using BASIC authentication, logout - * requires that the browser be closed or an unauthorized (401) header be sent. - * The simplest way of achieving the latter is to call the - * {@link #commence(ServletRequest, ServletResponse, AuthenticationException)} - * method below. This will indicate to the browser its credentials are no longer - * authorized, causing it to prompt the user to login again. - *
- * - * @author Ben Alex - * @version $Id: BasicProcessingFilterEntryPoint.java 1822 2007-05-17 12:20:16Z - * vishalpuri $ - */ -public class BasicProcessingFilterEntryPoint implements AuthenticationEntryPoint, InitializingBean, Ordered, - ApplicationContextAware { - // ~ Static fields/initializers - // ===================================================================================== - private static final int DEFAULT_ORDER = Integer.MAX_VALUE; - - // ~ Instance fields - // ================================================================================================ - - private String realmName; - - private int order = DEFAULT_ORDER; - - private ApplicationContext applicationContext; - - // ~ Methods - // ======================================================================================================== - - public int getOrder() { - return order; - } - - public void setOrder(int order) { - this.order = order; - } - - public void afterPropertiesSet() throws Exception { - Assert.hasText(realmName, "realmName must be specified"); - if (order == DEFAULT_ORDER) { - OrderedUtils.copyOrderFromOtherClass(BasicProcessingFilter.class, applicationContext, this, true); - } - } - - public void commence(ServletRequest request, ServletResponse response, AuthenticationException authException) - throws IOException, ServletException { - HttpServletResponse httpResponse = (HttpServletResponse) response; - httpResponse.addHeader("WWW-Authenticate", "Basic realm=\"" + realmName + "\""); - httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); - } - - public String getRealmName() { - return realmName; - } - - public void setRealmName(String realmName) { - this.realmName = realmName; - } - - public void setApplicationContext(ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - } -} diff --git a/sandbox/spring-security-config/basicauth/package.html b/sandbox/spring-security-config/basicauth/package.html deleted file mode 100644 index dcd7c31c91..0000000000 --- a/sandbox/spring-security-config/basicauth/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -Authenticates HTTP BASIC authentication requests. - - diff --git a/sandbox/spring-security-config/pom.xml b/sandbox/spring-security-config/pom.xml deleted file mode 100644 index e91ee781f8..0000000000 --- a/sandbox/spring-security-config/pom.xml +++ /dev/null @@ -1,169 +0,0 @@ - -BankService
sample using Java 5 Annotations.
- *
- * @author Mark St.Godard
- * @version $Id: BankService.java 1496 2006-05-23 13:38:33Z benalex $
- *
- * @see org.acegisecurity.annotation.Secured
- */
-@Secured({"ROLE_TELLER"})
-public interface BankService {
- //~ Methods ========================================================================================================
-
- /**
- * Get the account balance.
- *
- * @param accountNumber The account number
- *
- * @return The balance
- */
- @Secured({"ROLE_PERMISSION_BALANCE"})
- public float balance(String accountNumber);
-
- /**
- * List accounts
- *
- * @return The list of accounts
- */
- @Secured({"ROLE_PERMISSION_LIST"})
- public String[] listAccounts();
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/BankServiceImpl.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/BankServiceImpl.java
deleted file mode 100644
index ea6c7bfc5a..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/BankServiceImpl.java
+++ /dev/null
@@ -1,34 +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.acegisecurity;
-
-/**
- * BankService
sample implementation.
- *
- * @author Mark St.Godard
- * @version $Id: BankServiceImpl.java 1496 2006-05-23 13:38:33Z benalex $
- */
-public class BankServiceImpl implements BankService {
- //~ Methods ========================================================================================================
-
- public float balance(String accountNumber) {
- return 42000000;
- }
-
- public String[] listAccounts() {
- return new String[] {"1", "2", "3"};
- }
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/Main.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/Main.java
deleted file mode 100644
index 8b51c9810d..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/Main.java
+++ /dev/null
@@ -1,77 +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.acegisecurity;
-
-import org.acegisecurity.AccessDeniedException;
-import org.acegisecurity.GrantedAuthority;
-import org.acegisecurity.GrantedAuthorityImpl;
-
-import org.acegisecurity.context.SecurityContextHolder;
-import org.acegisecurity.context.SecurityContextImpl;
-
-import org.acegisecurity.providers.TestingAuthenticationToken;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-/**
- *
-DOCUMENT ME!
- *
- * @author Mark St.Godard
- * @version $Id: Main.java 1496 2006-05-23 13:38:33Z benalex $
- */
-public class Main {
- //~ Methods ========================================================================================================
-
- /**
- * This can be done in a web app by using a filter or SpringMvcIntegrationInterceptor
.
- */
- private static void createSecureContext() {
- TestingAuthenticationToken auth = new TestingAuthenticationToken("test", "test",
- new GrantedAuthority[] {
- new GrantedAuthorityImpl("ROLE_TELLER"), new GrantedAuthorityImpl("ROLE_PERMISSION_LIST")
- });
-
- SecurityContextHolder.getContext().setAuthentication(auth);
- }
-
- private static void destroySecureContext() {
- SecurityContextHolder.setContext(new SecurityContextImpl());
- }
-
- public static void main(String[] args) throws Exception {
- createSecureContext();
-
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
- "org/acegisecurity/config/auto-config.xml");
- BankService service = (BankService) context.getBean("bankService");
-
- // will succeed
- service.listAccounts();
-
- // will fail
- try {
- System.out.println(
- "We expect an AccessDeniedException now, as we do not hold the ROLE_PERMISSION_BALANCE granted authority, and we're using a unanimous access decision manager... ");
- service.balance("1");
- } catch (AccessDeniedException e) {
- e.printStackTrace();
- }
-
- destroySecureContext();
- }
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationMechanismBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationMechanismBeanDefinitionParser.java
deleted file mode 100644
index 4b5cce4e86..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationMechanismBeanDefinitionParser.java
+++ /dev/null
@@ -1,145 +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.acegisecurity.config;
-
-import org.acegisecurity.ldap.DefaultInitialDirContextFactory;
-import org.acegisecurity.providers.ProviderManager;
-import org.acegisecurity.providers.ldap.LdapAuthenticationProvider;
-import org.acegisecurity.providers.ldap.authenticator.BindAuthenticator;
-import org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator;
-import org.acegisecurity.util.BeanDefinitionParserUtils;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * * {@link BeanDefinitionParser} for the authentication-mechanism
- * tag, resolves to {@link org.acegisecurity.providers.ProviderManager}
- *
- * @author vpuri
- * @see {@link org.springframework.beans.factory.BeanFactory}
- * @see {@link org.acegisecurity.providers.ProviderManager}
- *
- */
-public class AuthenticationMechanismBeanDefinitionParser extends AbstractBeanDefinitionParser implements
- BeanDefinitionParser {
- // ~ Instance fields
- // ================================================================================================
-
- private static final String AUTHENTICATION_JDBC = "authentication-jdbc";
-
- private static final String AUTHENTICATION_LDAP = "authentication-ldap";
-
- private static final String REF = "ref";
-
- // ~ Methods
- // ========================================================================================================
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
-
- ManagedList providers = new ManagedList();
- Assert.notNull(parserContext, "ParserContext must not be null");
- RootBeanDefinition authMechanismBeanDef = new RootBeanDefinition(ProviderManager.class);
- NodeList childNodes = element.getChildNodes();
-
- for (int i = 0, n = childNodes.getLength(); i < n; i++) {
- Node node = childNodes.item(i);
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element childElement = (Element) node;
- // this.providerExists = true;
-
- if (AUTHENTICATION_JDBC.equals(node.getLocalName())) {
- String attribute = childElement.getAttribute(REF);
- if (StringUtils.hasLength(attribute)) {
- // create a beandefinition
- providers.add(new RuntimeBeanReference(attribute));
- }
- }
- else if (AUTHENTICATION_LDAP.equals(node.getLocalName())) {
- providers.add(createLdapAuthencticationProviderBeanDefinition(childElement, parserContext));
- }
- }
- authMechanismBeanDef.getPropertyValues().addPropertyValue("providers", providers);
-
- }
- return authMechanismBeanDef;
- }
-
- /**
- * Creates a default bean definition.
- * @return
- */
- protected static RootBeanDefinition createAndRegisterBeanDefinitionWithDefaults(ParserContext parserContext) {
- RootBeanDefinition beanDefinition = new RootBeanDefinition(ProviderManager.class);
- ManagedList providers = new ManagedList();
- // create authentication-repository (DaoAuthenticationProvider) and add
- // that to list
- RootBeanDefinition authRepo = AuthenticationRepositoryBeanDefinitionParser.createBeanDefinitionWithDefaults();
- providers.add(authRepo);
- beanDefinition.getPropertyValues().addPropertyValue("providers", providers);
- parserContext.getReaderContext().registerWithGeneratedName(beanDefinition);
- return beanDefinition;
- }
-
- protected static RootBeanDefinition createLdapAuthencticationProviderBeanDefinition(Element element,
- ParserContext parserContext) {
- // element ldap
- RootBeanDefinition ldapAuthProvider = new RootBeanDefinition(LdapAuthenticationProvider.class);
- RootBeanDefinition initialDirContextFactory = createInitialDirContextFactoryBeanDefinition(element);
- RootBeanDefinition ldapAuthoritiesPopulator = new RootBeanDefinition(DefaultLdapAuthoritiesPopulator.class);
-
- RootBeanDefinition bindAuthenticator = new RootBeanDefinition(BindAuthenticator.class);
- Element property = DomUtils.getChildElementByTagName(element, "property");
- Assert.notNull(property);
- parserContext.getDelegate().parsePropertyElement(property, bindAuthenticator);
- bindAuthenticator.getConstructorArgumentValues().addIndexedArgumentValue(0, initialDirContextFactory);
-
- // LdapAuthenticator
- ldapAuthProvider.getConstructorArgumentValues().addIndexedArgumentValue(0, bindAuthenticator);
-
- ldapAuthoritiesPopulator.getConstructorArgumentValues().addIndexedArgumentValue(0, initialDirContextFactory);
- BeanDefinitionParserUtils.setConstructorArgumentIfAvailable(1, element, "groupSearchBase", false,
- ldapAuthoritiesPopulator);
- BeanDefinitionParserUtils.setPropertyIfAvailable(element, "groupRoleAttribute", "groupRoleAttribute", false,
- ldapAuthoritiesPopulator);
-
- // LdapAuthoritiesPopulator
- ldapAuthProvider.getConstructorArgumentValues().addIndexedArgumentValue(1, ldapAuthoritiesPopulator);
-
- return ldapAuthProvider;
-
- }
-
- private static RootBeanDefinition createInitialDirContextFactoryBeanDefinition(Element element) {
- RootBeanDefinition initialDirContextFactory = new RootBeanDefinition(DefaultInitialDirContextFactory.class);
- BeanDefinitionParserUtils.setConstructorArgumentIfAvailable(0, element, "ldapUrl", false,
- initialDirContextFactory);
- BeanDefinitionParserUtils.setPropertyIfAvailable(element, "managerDn", "managerDn", false,
- initialDirContextFactory);
- BeanDefinitionParserUtils.setPropertyIfAvailable(element, "managerPassword", "managerPassword", false,
- initialDirContextFactory);
- return initialDirContextFactory;
- }
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationProcessingFilterBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationProcessingFilterBeanDefinitionParser.java
deleted file mode 100644
index 7425685ffe..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationProcessingFilterBeanDefinitionParser.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices;
-import org.acegisecurity.ui.webapp.AuthenticationProcessingFilter;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-
-/**
- * @author vpuri
- *
- */
-public class AuthenticationProcessingFilterBeanDefinitionParser extends AbstractBeanDefinitionParser implements
- BeanDefinitionParser {
-
- // ~ Instance fields
- // ================================================================================================
-
- private static final String AUTHENTICATION_URL = "authenticationUrl";
-
- private static final String ERROR_FORM_URL = "errorFormUrl";
-
- private static final String DEFAULT_TARGET_URL = "defaultTargetUrl";
-
- // ~ Methods
- // ================================================================================================
-
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
-
- RootBeanDefinition definition = new RootBeanDefinition(AuthenticationProcessingFilter.class);
-
- setPropertyIfAvailable(element, AUTHENTICATION_URL, "filterProcessesUrl", definition);
- setPropertyIfAvailable(element, ERROR_FORM_URL, "authenticationFailureUrl", definition);
- setPropertyIfAvailable(element, DEFAULT_TARGET_URL, "defaultTargetUrl", definition);
-
- return definition;
- }
-
- private void setPropertyIfAvailable(Element element, String attribute, String property,
- RootBeanDefinition definition) {
- String propertyValue = element.getAttribute(attribute);
- if (StringUtils.hasText(propertyValue)) {
- definition.getPropertyValues().addPropertyValue(property, propertyValue);
- }
- }
-
- protected static RootBeanDefinition createBeandefinitionWithDefaults(ParserContext parserContext, RootBeanDefinition authenticationManager, RootBeanDefinition rememberMeServices) {
- RootBeanDefinition definition = new RootBeanDefinition(AuthenticationProcessingFilter.class);
- definition.getPropertyValues().addPropertyValue("authenticationManager",authenticationManager);
- definition.getPropertyValues().addPropertyValue("rememberMeServices",rememberMeServices);
-// RootBeanDefinition beanDefinition = AuthenticationMechanismBeanDefinitionParser.createAndRegisterBeanDefinitionWithDefaults(parserContext);
-// definition.getPropertyValues().addPropertyValue("authenticationManager",
-// parserContext.getReaderContext().getRegistry().getBeanDefinition(beanDefinition.getBeanClassName()));
-// definition.getPropertyValues().addPropertyValue("rememberMeServices",
-// RememberMeServicesBeanDefinitionParser.createAndRegisterBeanDefintionWithDefaults(parserContext));
- /* TODO: There should not be any defaults for these urls ?!?! */
- definition.getPropertyValues().addPropertyValue("authenticationFailureUrl", "/acegilogin.jsp?login_error=1");
- definition.getPropertyValues().addPropertyValue("defaultTargetUrl", "/");
-
- return definition;
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationProviderOrderResolver.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationProviderOrderResolver.java
deleted file mode 100644
index 635f863a8c..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/AuthenticationProviderOrderResolver.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.acegisecurity.config;
-
-import java.util.Collections;
-
-import org.acegisecurity.AuthenticationManager;
-import org.acegisecurity.providers.AuthenticationProvider;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.core.OrderComparator;
-
-public class AuthenticationProviderOrderResolver implements BeanFactoryPostProcessor {
-
- /**
- *
- */
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
- // retrieve all the AuthenticationProvider instances
- ManagedList providers = retrieveAllAuthenticationProviders(beanFactory);
- String[] names = beanFactory.getBeanNamesForType(AuthenticationManager.class);
- RootBeanDefinition definition = (RootBeanDefinition)beanFactory.getBeanDefinition(names[0]);
- definition.getPropertyValues().addPropertyValue("providers",providers);
- }
- /**
- *
- * @param beanFactory
- * @return
- */
- private ManagedList retrieveAllAuthenticationProviders(ConfigurableListableBeanFactory beanFactory) {
- String[] m = beanFactory.getBeanNamesForType(AuthenticationProvider.class);
- ManagedList l = new ManagedList();
- for(int i=0;i
- * The valid configuration example:
<security:url-mapping
- * source="custom" sourceBeanId="referenceToObjectDefinitionSource"/>
- *
BeanDefinition
s with their default configurations. It also
- * resolves their dependencies and wire them together.
- *
- * @author Vishal Puri
- *
- */
-public class AutoConfigBeanDefinitionParser implements BeanDefinitionParser {
-
- // ~ instance fields
- // ================================================================================================
-
- private RootBeanDefinition authenticationManager;
-
- private RootBeanDefinition rememberMeServices;
-
- private ManagedList decisionVoters = new ManagedList();
-
- // ~ Method
- // ================================================================================================
-
- public BeanDefinition parse(Element element, ParserContext parserContext) {
- // authentication manager
- this.authenticationManager = AuthenticationMechanismBeanDefinitionParser
- .createAndRegisterBeanDefinitionWithDefaults(parserContext);
- // remembermeServices
- this.rememberMeServices = RememberMeServicesBeanDefinitionParser
- .createAndRegisterBeanDefintionWithDefaults(parserContext);
- // flters
- createAndRegisterBeanDefinitionForHttpSessionContextIntegrationFilter(parserContext);
- createAndRegisterBeanDefinitionForLogoutFilter(parserContext, rememberMeServices);
- createAndRegisterBeanDefinitionForAuthenticationProcessingFilter(parserContext, authenticationManager,
- rememberMeServices);
- createAndRegisterBeanDefinitionForRememberMeProcessingFilter(parserContext, authenticationManager);
- createAndRegisterBeanDefinitionForExceptionTranslationFilter(parserContext);
- createAndRegisterBeanDefintionForSecurityContextHolderAwareRequestFilter(parserContext);
-
- // method interceptor
- createAndRegisterBeanDefinitinoForMethodDefinitionSourceAdvisor(parserContext, authenticationManager);
- createAndRegisterDefaultAdvisorAutoProxyCreator(parserContext);
-
- // filter security interceptor
- createAndRegisterBeanDefinitionForFilterSecurityInterceptor(parserContext, authenticationManager);
-
- // create userDetailsService
- return null;
- }
-
- private void createAndRegisterBeanDefintionForSecurityContextHolderAwareRequestFilter(ParserContext parserContext) {
- RootBeanDefinition beanDefinition = new RootBeanDefinition(SecurityContextHolderAwareRequestFilter.class);
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, beanDefinition);
- }
-
- /**
- * Creates FilterSecurityInterceptor
bean definition and
- * register it with the ParserContext
- *
- * @param parserContext To register the bean definition with
- * @param authenticationManager The AuthenticationManager
to
- * set as a property in the bean definition
- */
- private void createAndRegisterBeanDefinitionForFilterSecurityInterceptor(ParserContext parserContext,
- RootBeanDefinition authenticationManager) {
- RootBeanDefinition filterInvocationInterceptor = new RootBeanDefinition(FilterSecurityInterceptor.class);
- filterInvocationInterceptor.getPropertyValues()
- .addPropertyValue("authenticationManager", authenticationManager);
- RootBeanDefinition accessDecisionManager = createAccessDecisionManagerAffirmativeBased();
- filterInvocationInterceptor.getPropertyValues()
- .addPropertyValue("accessDecisionManager", accessDecisionManager);
-
- FilterInvocationDefinitionDecorator source = new FilterInvocationDefinitionDecorator();
- source.setDecorated(new PathBasedFilterInvocationDefinitionMap());
-
- FilterInvocationDefinitionSourceMapping mapping = new FilterInvocationDefinitionSourceMapping();
-
- String url1 = "/acegilogin.jsp";
- String value1 = "IS_AUTHENTICATED_ANONYMOUSLY";
-
- String url2 = "/**";
- String value2 = "IS_AUTHENTICATED_REMEMBERED";
-
- mapping.setUrl(url1);
- mapping.addConfigAttribute(value1);
-
- mapping.setUrl(url2);
- mapping.addConfigAttribute(value2);
-
- List mappings = new ArrayList();
- mappings.add(mapping);
- source.setMappings(mappings);
- filterInvocationInterceptor.getPropertyValues().addPropertyValue("objectDefinitionSource",
- source.getDecorated());
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, filterInvocationInterceptor);
- }
-
- private RootBeanDefinition createAccessDecisionManagerAffirmativeBased() {
- RootBeanDefinition accessDecisionManager = new RootBeanDefinition(AffirmativeBased.class);
- accessDecisionManager.getPropertyValues().addPropertyValue("allowIfAllAbstainDecisions", Boolean.FALSE);
- RootBeanDefinition authenticatedVoter = new RootBeanDefinition(AuthenticatedVoter.class);
- this.decisionVoters.add(authenticatedVoter);
- accessDecisionManager.getPropertyValues().addPropertyValue("decisionVoters", decisionVoters);
- return accessDecisionManager;
- }
-
- private void createAndRegisterDefaultAdvisorAutoProxyCreator(ParserContext parserContext) {
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, new RootBeanDefinition(
- DefaultAdvisorAutoProxyCreator.class));
- }
-
- private void createAndRegisterBeanDefinitinoForMethodDefinitionSourceAdvisor(ParserContext parserContext,
- RootBeanDefinition authenticationManager) {
- RootBeanDefinition methodSecurityAdvisor = new RootBeanDefinition(MethodDefinitionSourceAdvisor.class);
-
- RootBeanDefinition securityInterceptor = createMethodSecurityInterceptor(authenticationManager);
- methodSecurityAdvisor.getConstructorArgumentValues().addIndexedArgumentValue(0, securityInterceptor);
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, methodSecurityAdvisor);
-
- }
-
- private RootBeanDefinition createAccessDecisionManagerUnanimousBased() {
- RootBeanDefinition accessDecisionManager = new RootBeanDefinition(UnanimousBased.class);
- accessDecisionManager.getPropertyValues().addPropertyValue("allowIfAllAbstainDecisions", Boolean.FALSE);
- decisionVoters.add(new RootBeanDefinition(RoleVoter.class));
- accessDecisionManager.getPropertyValues().addPropertyValue("decisionVoters", decisionVoters);
- return accessDecisionManager;
- }
-
- private RootBeanDefinition createMethodSecurityInterceptor(RootBeanDefinition authenticationManager) {
- RootBeanDefinition securityInterceptor = new RootBeanDefinition(MethodSecurityInterceptor.class);
- securityInterceptor.getPropertyValues().addPropertyValue("authenticationManager", authenticationManager);
- RootBeanDefinition accessDecisionManager = createAccessDecisionManagerUnanimousBased();
- securityInterceptor.getPropertyValues().addPropertyValue("accessDecisionManager", accessDecisionManager);
- securityInterceptor.getPropertyValues().addPropertyValue("validateConfigAttributes", Boolean.FALSE);
- RootBeanDefinition runAsManager = createRunAsManager();
- securityInterceptor.getPropertyValues().addPropertyValue("runAsManager", runAsManager);
- RootBeanDefinition objectDefinitionSource = createMethodDefinitionAttributes();
- securityInterceptor.getPropertyValues().addPropertyValue("objectDefinitionSource", objectDefinitionSource);
- return securityInterceptor;
- }
-
- private RootBeanDefinition createMethodDefinitionAttributes() {
- RootBeanDefinition objectDefinitionSource = new RootBeanDefinition(MethodDefinitionAttributes.class);
- RootBeanDefinition attributes = createSecurityAnnotationAttributes();
- objectDefinitionSource.getPropertyValues().addPropertyValue("attributes", attributes);
- return objectDefinitionSource;
- }
-
- private RootBeanDefinition createSecurityAnnotationAttributes() {
- return new RootBeanDefinition(SecurityAnnotationAttributes.class);
- }
-
- private RootBeanDefinition createRunAsManager() {
- RootBeanDefinition runAsManager = new RootBeanDefinition(RunAsManagerImpl.class);
- runAsManager.getPropertyValues().addPropertyValue("key", "my_run_as_password");
- return runAsManager;
- }
-
- private void createAndRegisterBeanDefinitionForExceptionTranslationFilter(ParserContext parserContext) {
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, ExceptionTranslationFilterBeanDefinitionParser
- .createBeanDefinitionWithDefaults());
- }
-
- private void createAndRegisterBeanDefinitionForRememberMeProcessingFilter(ParserContext parserContext,
- RootBeanDefinition authenticationManager) {
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, RememberMeFilterBeanDefinitionParser
- .createBeanDefinitionWithDefaults(parserContext, authenticationManager));
- }
-
- private void createAndRegisterBeanDefinitionForAuthenticationProcessingFilter(ParserContext parserContext,
- RootBeanDefinition authenticationManager, RootBeanDefinition rememberMeServices) {
- RootBeanDefinition defintion = AuthenticationProcessingFilterBeanDefinitionParser
- .createBeandefinitionWithDefaults(parserContext, authenticationManager, rememberMeServices);
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, defintion);
- }
-
- private void createAndRegisterBeanDefinitionForLogoutFilter(ParserContext parserContext,
- RootBeanDefinition rememberMeServices) {
- RootBeanDefinition defintion = LogoutFilterBeanDefinitionParser
- .createBeanDefinitionWithDefaults(rememberMeServices);
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, defintion);
- }
-
- private void createAndRegisterBeanDefinitionForHttpSessionContextIntegrationFilter(ParserContext parserContext) {
- RootBeanDefinition defintion = ContextIntegrationBeanDefinitionParser.createBeanDefinitionWithDefaults();
- BeanDefinitionParserUtils.registerBeanDefinition(parserContext, defintion);
- // retrieveBeanDefinition(parserContext, o)
- }
-
- /**
- * Returns a BeanDefinition
of the specified type.
- *
- * @param parserContext
- * @param type
- * @return
- */
- private RootBeanDefinition retrieveBeanDefinition(ParserContext parserContext, Class type) {
- String[] names = parserContext.getRegistry().getBeanDefinitionNames();
- for (String name : names) {
- BeanDefinition beanDefinition = parserContext.getRegistry().getBeanDefinition(name);
- if (type.isInstance(beanDefinition)) {
- return (RootBeanDefinition) beanDefinition;
- }
- }
- return null;
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/ContextIntegrationBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/ContextIntegrationBeanDefinitionParser.java
deleted file mode 100644
index 7b8787a929..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/ContextIntegrationBeanDefinitionParser.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import org.acegisecurity.context.HttpSessionContextIntegrationFilter;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.core.Conventions;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-/**
- *
- * @author vpuri
- *
- */
-public class ContextIntegrationBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
-
- // ~ Static fields/initializers
- // =====================================================================================
-
- private static final String HTTP_SESSION_CONTEXT_INTEGRATION = "session-context-integration";
-
- private static final String SESSION_CREATION = "sessionCreation";
-
- private static final String IF_REQUIRED = "ifRequired";
-
- private static final String ALWAYS = "always";
-
- private static final String NEVER = "never";
-
- private static final String ALLOW_SESSION_CREATION = "allowSessionCreation";
-
- // ~ Methods
- // ========================================================================================================
-
- protected Class getBeanClass(Element element) {
- return HttpSessionContextIntegrationFilter.class;
- }
-
- protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
-
- NamedNodeMap attributes = element.getAttributes();
-
- for (int x = 0; x < attributes.getLength(); x++) {
- Attr attribute = (Attr) attributes.item(x);
- String attributeName = attribute.getLocalName();
- if (!ID_ATTRIBUTE.equals(attributeName)) {
- if (attributeName.equals(SESSION_CREATION)) {
- String sessionCreation = element.getAttribute(SESSION_CREATION);
- createBeanDefinition(builder, sessionCreation);
- }
- else {
- String propertyName = Conventions.attributeNameToPropertyName(attributeName);
- Assert
- .state(StringUtils.hasText(propertyName),
- "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty.");
- builder.addPropertyValue(propertyName, attribute.getValue());
- }
- }
- }
- }
-
- private void createBeanDefinition(BeanDefinitionBuilder builder, String attribute) {
- if (attribute.equals(IF_REQUIRED)) {
- builder.addPropertyValue(ALLOW_SESSION_CREATION, Boolean.TRUE);
- }
- else if (attribute.equals(ALWAYS)) {
- builder.addPropertyValue(ALLOW_SESSION_CREATION, Boolean.TRUE);
- }
- else if (attribute.equals(NEVER)) {
- builder.addPropertyValue(ALLOW_SESSION_CREATION, Boolean.FALSE);
- }
- else {
- createBeanDefinitionWithDefaults();
- }
- }
-
- protected static RootBeanDefinition createBeanDefinitionWithDefaults() {
- RootBeanDefinition definition = new RootBeanDefinition(HttpSessionContextIntegrationFilter.class);
- definition.getPropertyValues().addPropertyValue(ALLOW_SESSION_CREATION, Boolean.TRUE);
- return definition;
- }
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/ExceptionTranslationFilterBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/ExceptionTranslationFilterBeanDefinitionParser.java
deleted file mode 100644
index b77a8c0a72..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/ExceptionTranslationFilterBeanDefinitionParser.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import org.acegisecurity.ui.AccessDeniedHandlerImpl;
-import org.acegisecurity.ui.ExceptionTranslationFilter;
-import org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-
-/**
- *
- * This class parses the ExceptionTranslationFilter
. The
- * '<security:access-denied .. />' tag is optional and if not specified
- * ExceptionTranslationFilter
will autodetect the instance
- * of AccessDeniedHandler
; alternately if there are > 1 such
- * handlers,
we can nominate the one to use via 'accessDeniedBeanRef'.
- *
- * The 'entryPointBeanRef' and 'accessDeniedBeanRef' can be specified as
- * attributes or inner bean definitions.
See following sample showing both
- * ways.
- *
- * Sample:
BeanDefintion
for
- * ExceptionTranslationFilter
with it's default properties.
- * @return beanDefinition The bean defintion configured with default
- * properties
- */
- protected static RootBeanDefinition createBeanDefinitionWithDefaults() {
- RootBeanDefinition beanDefinition = new RootBeanDefinition(ExceptionTranslationFilter.class);
- beanDefinition.getPropertyValues().addPropertyValue("authenticationEntryPoint",
- createBeanDefintionForAuthenticationProcessingFilterEntryPoint());
- return beanDefinition;
- }
-
- /**
- * Creates BeanDefintion
for
- * AuthenticationProcessingFilterEntryPoint
with it's default
- * properties.
- * @return beanDefinition The bean defintion configured with default
- */
- protected static RootBeanDefinition createBeanDefintionForAuthenticationProcessingFilterEntryPoint() {
- RootBeanDefinition beanDefinition = new RootBeanDefinition(AuthenticationProcessingFilterEntryPoint.class);
- beanDefinition.getPropertyValues().addPropertyValue(LOGIN_FORM_URL, LOGIN_FORM_URL_VALUE);
- return beanDefinition;
- }
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/FilterSecurityInterceptorBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/FilterSecurityInterceptorBeanDefinitionParser.java
deleted file mode 100644
index 9f7ba89279..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/FilterSecurityInterceptorBeanDefinitionParser.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.acegisecurity.config;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.acegisecurity.AccessDecisionManager;
-import org.acegisecurity.intercept.web.FilterInvocationDefinitionDecorator;
-import org.acegisecurity.intercept.web.FilterInvocationDefinitionSourceMapping;
-import org.acegisecurity.intercept.web.FilterSecurityInterceptor;
-import org.acegisecurity.intercept.web.PathBasedFilterInvocationDefinitionMap;
-import org.acegisecurity.intercept.web.RegExpBasedFilterInvocationDefinitionMap;
-import org.acegisecurity.util.BeanDefinitionParserUtils;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.Assert;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * @author Vishal Puri
- *
- */
-public class FilterSecurityInterceptorBeanDefinitionParser extends AbstractBeanDefinitionParser {
- // ~ static initializers
- // ================================================================================================
-
- private static final String OBJECT_DEFINITION_SOURCE_PROPERTY = "objectDefinitionSource";
-
- private static final String OBJECT_DEFINITION_SOURCE_REF_ATTRIBUTE = "sourceBeanId";
-
- private static final String PATH_ATTRIBUTE = "path";
-
- private static final String REG_EX_ATTRIBUTE = "regularExpression";
-
- private static final String CONFIGURATION_ATTRIB_ATTRIBUTE = "attribute";
-
- // ~ Methods
- // ================================================================================================
-
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- return createBeanDefinitionForFilterSecurityInterceptor(element, parserContext);
- }
-
- protected static RootBeanDefinition createBeanDefinitionForFilterSecurityInterceptor(Element element,
- ParserContext parserContext) {
- RootBeanDefinition filterInvocationInterceptor = new RootBeanDefinition(FilterSecurityInterceptor.class);
-
- RootBeanDefinition accessDecisionManager = AuthorizationManagerBeanDefinitionParser
- .createAccessDecisionManagerAffirmativeBased();
- filterInvocationInterceptor.getPropertyValues()
- .addPropertyValue("accessDecisionManager", accessDecisionManager);
-
- FilterInvocationDefinitionDecorator source = new FilterInvocationDefinitionDecorator();
- FilterInvocationDefinitionSourceMapping mapping = new FilterInvocationDefinitionSourceMapping();
- ListBeanDefintion
as required by 'autoconfig' tag
- *
- * @param definition The BeanDefinition for Logoutfilter
- * @param element
- * @param parserContext
- * @param isAutoconfig
- * @return definition
- */
- protected static RootBeanDefinition createBeanDefinitionWithDefaults(RootBeanDefinition rememberMeServices) {
- RootBeanDefinition definition = new RootBeanDefinition(LogoutFilter.class);
- definition.getConstructorArgumentValues().addIndexedArgumentValue(0, REDIRECT_AFTER_LOGOUT_URL_VALUE);
- // create BeanDefinitions for LogoutHandlers
- // (TokenBasedRememberMeServices) and (SecuritycontextLogoutHandler)
- ManagedList handlers = new ManagedList();
- //RootBeanDefinition rememberMeServices = RememberMeServicesBeanDefinitionParser.doCreateBeanDefintionWithDefaults();
- handlers.add(rememberMeServices);
- handlers.add(new RootBeanDefinition(SecurityContextLogoutHandler.class));
- definition.getConstructorArgumentValues().addIndexedArgumentValue(1, handlers);
- return definition;
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/LogoutHandlerOrderResolver.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/LogoutHandlerOrderResolver.java
deleted file mode 100644
index 2fd55b5b05..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/LogoutHandlerOrderResolver.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.acegisecurity.ui.logout.LogoutFilter;
-import org.acegisecurity.ui.logout.LogoutHandler;
-import org.acegisecurity.ui.logout.SecurityContextLogoutHandler;
-import org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.core.OrderComparator;
-import org.springframework.core.Ordered;
-
-/**
- * @author vpuri
- * @since
- */
-public class LogoutHandlerOrderResolver implements BeanFactoryPostProcessor {
-
- // ~ Methods
- // ================================================================================================
-
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
- // If LogoutFilter does not have setHandlers populated, introspect app
- // ctx for LogoutHandlers, using Ordered (if present, otherwise assume
- // Integer.MAX_VALUE)
- String[] names = beanFactory.getBeanNamesForType(LogoutFilter.class);
- RootBeanDefinition definition = (RootBeanDefinition) beanFactory.getBeanDefinition(names[0]);
- ValueHolder holder = getHandlersIfConfigured(beanFactory, definition);
- if (holder == null) {
- // intropect the appcontext for registerd LogoutHandler
- List logoutHandlers = retrieveAllLogoutHandlers(beanFactory);
- definition.getConstructorArgumentValues().addIndexedArgumentValue(1, logoutHandlers);
- }
- }
-
- /**
- *
- * @param beanFactory
- * @param definition
- * @return
- */
- private ValueHolder getHandlersIfConfigured(ConfigurableListableBeanFactory beanFactory,
- RootBeanDefinition definition) {
- // there should be only one LogoutFilter
- return definition.getConstructorArgumentValues().getArgumentValue(1, null);
-
- }
-
- /**
- *
- * @param beanFactory
- * @return
- */
- private List retrieveAllLogoutHandlers(ConfigurableListableBeanFactory beanFactory) {
- String[] names = beanFactory.getBeanNamesForType(LogoutHandler.class);
- ManagedList list = new ManagedList();
-
- for (int i = 0, n = names.length; i < n; i++) {
- RootBeanDefinition definition = (RootBeanDefinition) beanFactory.getBeanDefinition(names[i]);
-
- if (definition.hasBeanClass()) {
- if (Ordered.class.isAssignableFrom(definition.getBeanClass())) {
- definition.getPropertyValues().addPropertyValue("order",
- Integer.valueOf(getOrder(definition.getBeanClass())));
- }
- else {
- definition.getPropertyValues().addPropertyValue("order", Integer.valueOf(Integer.MAX_VALUE));
- }
- }
- list.add(definition);
- }
- Collections.sort(list, new OrderComparator());
- return list;
- }
-
- private int getOrder(Class clazz) {
- if (clazz.getName().equals(TokenBasedRememberMeServices.class.getName())) {
- return 100;
- }
- if (clazz.getName().equals(SecurityContextLogoutHandler.class.getName())) {
- return 200;
- }
- return Integer.MAX_VALUE;
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/PrincipalRepositoryBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/PrincipalRepositoryBeanDefinitionParser.java
deleted file mode 100644
index 1796f3ba07..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/PrincipalRepositoryBeanDefinitionParser.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.acegisecurity.GrantedAuthority;
-import org.acegisecurity.GrantedAuthorityImpl;
-import org.acegisecurity.userdetails.User;
-import org.acegisecurity.userdetails.UserDetails;
-import org.acegisecurity.userdetails.jdbc.JdbcDaoImpl;
-import org.acegisecurity.userdetails.memory.InMemoryDaoImpl;
-import org.acegisecurity.userdetails.memory.UserAttribute;
-import org.acegisecurity.userdetails.memory.UserMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author vpuri
- *
- */
-public class PrincipalRepositoryBeanDefinitionParser extends AbstractBeanDefinitionParser implements
- BeanDefinitionParser {
-
- // ~ Static fields/initializers
- // =====================================================================================
-
- private static final Log logger = LogFactory.getLog(PrincipalRepositoryBeanDefinitionParser.class);
-
- // ~ Instance fields
- // ================================================================================================
- private static final String JDBC = "jdbc";
-
- private static final String DATASOURCE_REF = "dataSourceBeanRef";
-
- private static final String DATASOURCE = "dataSource";
-
- private static final String JDBCTEMPLATE_REF = "jdbcTemplateBeanRef";
-
- private static final String JDBCTEMPLATE = "jdbcTemplate";
-
- private static final String AUTHORITIES_BY_USERNAME_QUERY = "authoritiesByUsernameQuery";
-
- private static final String ROLE_PREFIX = "rolePrefix";
-
- private static final String USERNAME_BASED_PRIMARY_KEY = "usernameBasedPrimaryKey";
-
- private static final String PROPERTIES = "properties";
-
- private static final String RESOURCE = "resource";
-
- private static final String USER_PROPERTIES = "userProperties";
-
- private static final String USER_DEFINITION = "user-definition";
-
- private static final Object GRANTED_AUTHORITY = "granted-authority";
-
- private static final String USERNAME = "username";
-
- private static final String PASSWORD = "password";
-
- private static final String ENABLED = "enabled";
-
- private static final String GRANTED_AUTHORITY_REF = "granted-authority-ref";
-
- private static final String AUTHORITY = "authority";
-
- private static final String AUTHORITY_BEAN_REF = "authorityBeanRef";
-
- // ~ Method
- // ================================================================================================
- /**
- *
- */
-
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- NodeList userDetailsServiceChildren = element.getChildNodes();
- RootBeanDefinition userDetailsServiceDefinition = null;
- for (int i = 0, n = userDetailsServiceChildren.getLength(); i < n; i++) {
- Node userDetailsService = userDetailsServiceChildren.item(i);
-
- if (JDBC.equals(userDetailsService.getLocalName()) && userDetailsService.getNodeType() == Node.ELEMENT_NODE) {
- Element ele = (Element) userDetailsService;
- userDetailsServiceDefinition = parseUserDetailsServiceJdbcDefinition(ele);
- userDetailsServiceDefinition.setSource(parserContext.extractSource(element));
- }
- if (PROPERTIES.equals(userDetailsService.getLocalName())
- && userDetailsService.getNodeType() == Node.ELEMENT_NODE) {
- Element ele = (Element) userDetailsService;
-
- userDetailsServiceDefinition = new RootBeanDefinition(InMemoryDaoImpl.class);
- userDetailsServiceDefinition.getPropertyValues().addPropertyValue(USER_PROPERTIES,
- new RuntimeBeanReference(createPropertiesBeanDefinition(ele, parserContext)));
- userDetailsServiceDefinition.setSource(parserContext.extractSource(element));
- }
- if (USER_DEFINITION.equals(userDetailsService.getLocalName())
- && userDetailsService.getNodeType() == Node.ELEMENT_NODE) {
- Element ele = (Element) userDetailsService;
-
- // create a UserMap which interns uses UserMapEditor
- userDetailsServiceDefinition = createUserDefinition(ele, parserContext);
- }
- }
- return userDetailsServiceDefinition;
- }
-
- private RootBeanDefinition createUserDefinition(Element ele, ParserContext parserContext) {
- RootBeanDefinition definition = new RootBeanDefinition(InMemoryDaoImpl.class);
-
- UserAttribute userAttribute = new UserAttribute();
- UserMap userMap = new UserMap();
-
- setPassword(ele, userAttribute);
- setEnabled(ele, userAttribute);
- setAuthorities(ele, userAttribute);
-
- UserDetails user = new User(ele.getAttribute(USERNAME), userAttribute.getPassword(), userAttribute.isEnabled(),
- true, true, true, userAttribute.getAuthorities());
- userMap.addUser(user);
- definition.getPropertyValues().addPropertyValue("userMap", userMap);
- return definition;
- }
-
- private String createPropertiesBeanDefinition(Element ele, ParserContext parserContext) {
- // properties element
- RootBeanDefinition defintion = new RootBeanDefinition(PropertiesFactoryBean.class);
- String propertyValue = ele.getAttribute(RESOURCE);
- defintion.getPropertyValues().addPropertyValue("location", propertyValue);
- defintion.setSource(parserContext.extractSource(ele));
- return parserContext.getReaderContext().registerWithGeneratedName(defintion);
- }
-
- protected static RootBeanDefinition createSampleUsersUsingProperties() {
- // properties element
- RootBeanDefinition defintion = new RootBeanDefinition(PropertiesFactoryBean.class);
- String location = "classpath:org/acegisecurity/config/user.properties";
- defintion.getPropertyValues().addPropertyValue("location", location);
- return defintion;
- }
-
-
- /**
- *
- * @param elementToParse
- * @return
- */
- private RootBeanDefinition parseUserDetailsServiceJdbcDefinition(Element elementToParse) {
- // parse attributes
- RootBeanDefinition definition = new RootBeanDefinition(JdbcDaoImpl.class);
- setPropertyIfAvailable(elementToParse, DATASOURCE_REF, DATASOURCE, definition);
- setPropertyIfAvailable(elementToParse, JDBCTEMPLATE_REF, JDBCTEMPLATE, definition);
- setPropertyIfAvailable(elementToParse, AUTHORITIES_BY_USERNAME_QUERY, AUTHORITIES_BY_USERNAME_QUERY, definition);
- setPropertyIfAvailable(elementToParse, ROLE_PREFIX, ROLE_PREFIX, definition);
- setPropertyIfAvailable(elementToParse, USERNAME_BASED_PRIMARY_KEY, USERNAME_BASED_PRIMARY_KEY, definition);
- return definition;
- }
-
- protected void doParseProperties(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
- Properties parsedProps = parserContext.getDelegate().parsePropsElement(element);
- builder.addPropertyValue(PROPERTIES, parsedProps);
- }
-
- /**
- *
- * @param element
- * @param attribute
- * @param property
- * @param definition
- */
- private void setPropertyIfAvailable(Element element, String attribute, String property,
- RootBeanDefinition definition) {
- String propertyValue = element.getAttribute(attribute);
- if (StringUtils.hasText(propertyValue)) {
- if (propertyValue.equals(DATASOURCE_REF) || propertyValue.equals(JDBCTEMPLATE_REF)) {
- definition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(propertyValue));
- }
- else {
- definition.getPropertyValues().addPropertyValue(property, propertyValue);
- }
- }
- }
-
- private void setPassword(Element element, UserAttribute userAttribute) {
- String propertyValue = element.getAttribute(PASSWORD);
- if (StringUtils.hasText(propertyValue)) {
- userAttribute.setPassword(propertyValue);
- }
- }
-
- private void setEnabled(Element element, UserAttribute userAttribute) {
- String propertyValue = element.getAttribute(ENABLED);
- if (StringUtils.hasText(propertyValue)) {
- if (propertyValue.equals("true")) {
- userAttribute.setEnabled(true);
- }
- else {
- userAttribute.setEnabled(false);
- }
- }
- }
-
- private void setAuthorities(Element ele, UserAttribute userAttribute) {
- // get authorities
- NodeList childNodes = ele.getChildNodes();
-
- ManagedList authorities = new ManagedList();
-
- for (int i = 0, n = childNodes.getLength(); i < n; i++) {
- Node authorityNode = childNodes.item(i);
-
- if (GRANTED_AUTHORITY.equals(authorityNode.getLocalName())
- && authorityNode.getNodeType() == Element.ELEMENT_NODE) {
- Element propertyValue = (Element) authorityNode;
- authorities.add(new GrantedAuthorityImpl(propertyValue.getAttribute(AUTHORITY)));
- }
-
- if (GRANTED_AUTHORITY_REF.equals(authorityNode.getLocalName())
- && authorityNode.getNodeType() == Element.ELEMENT_NODE) {
- Element propertyValue = (Element) authorityNode;
- String attribute = propertyValue.getAttribute(AUTHORITY_BEAN_REF);
- if (StringUtils.hasLength(attribute)) {
- authorities.add(new RuntimeBeanReference(attribute));
- }
- }
- }
- userAttribute.setAuthorities(authorities);
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/RememberMeFilterBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/RememberMeFilterBeanDefinitionParser.java
deleted file mode 100644
index 68027a0a1f..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/RememberMeFilterBeanDefinitionParser.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import org.acegisecurity.ui.rememberme.RememberMeProcessingFilter;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-
-/**
- * @author vpuri
- *
- *@since
- */
-public class RememberMeFilterBeanDefinitionParser extends AbstractBeanDefinitionParser {
-
- private static final String REMEMBER_ME_SERVICES_REF = "rememberMeServicesBeanRef";
-
- private static final String REMEMBER_ME_SERVICES = "rememberMeServices";
-
-
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- Assert.notNull(parserContext, "ParserContext must not be null");
-
- RootBeanDefinition rememberMeFilterBeanDef = new RootBeanDefinition(RememberMeProcessingFilter.class);
- // check if rememberMeServicesBeanRef is defined and if it's specified use its referred bean
- String rememberMeServicesRef = element.getAttribute(REMEMBER_ME_SERVICES_REF);
- if (StringUtils.hasLength(rememberMeServicesRef)) {
- rememberMeFilterBeanDef.getPropertyValues().addPropertyValue(REMEMBER_ME_SERVICES,
- new RuntimeBeanReference(rememberMeServicesRef));
- }
- return rememberMeFilterBeanDef;
- }
-
- protected static RootBeanDefinition createBeanDefinitionWithDefaults(ParserContext parserContext, RootBeanDefinition authenticationManager) {
- RootBeanDefinition definition= new RootBeanDefinition(RememberMeProcessingFilter.class);
- definition.getPropertyValues().addPropertyValue("authenticationManager",authenticationManager);
- return definition;
- }
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/RememberMeServicesBeanDefinitionParser.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/RememberMeServicesBeanDefinitionParser.java
deleted file mode 100644
index 879a5f0b90..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/RememberMeServicesBeanDefinitionParser.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-
-/**
- * Parses
- * @author vpuri
- *
- */
-public class RememberMeServicesBeanDefinitionParser extends AbstractBeanDefinitionParser implements
- BeanDefinitionParser {
-
- private static final String PRINCIPAL_REPOSITORY_BEAN_REF = "principalRepositoryBeanRef";
-
- private static final String USER_DETAILS_SERVICE_PROPERTY = "userDetailsService";
-
- /*
- * key is optional; if unspecified, pick a rnd int and use for all
- * unspecified key properties for acegi beans
- */
- private static final String KEY = "key";
-
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- RootBeanDefinition rememberMeServicesBeanDef = createBeanDefinition(element, parserContext);
- return rememberMeServicesBeanDef;
- }
-
- private RootBeanDefinition createBeanDefinition(Element element, ParserContext parserContext) {
- Assert.notNull(parserContext, "ParserContext must not be null");
-
- RootBeanDefinition rememberMeServicesBeanDef = new RootBeanDefinition(TokenBasedRememberMeServices.class);
-
- String keyValue = "";
- String rememberMeServicesRef = "";
-
- if (element != null) {
- keyValue = element.getAttribute(KEY);
-
- if (StringUtils.hasLength(keyValue)) {
- rememberMeServicesBeanDef.getPropertyValues().addPropertyValue(KEY, keyValue);
- }
- else {
- /*
- * TODO: pick a rnd int and apply it whenver required in
- * applicationcontext
- */
-
- }
-
- // check if rememberMeServicesBeanRef is defined and if it's
- // specified
- // use its referred bean
- rememberMeServicesRef = element.getAttribute(PRINCIPAL_REPOSITORY_BEAN_REF);
- if (StringUtils.hasLength(rememberMeServicesRef)) {
- rememberMeServicesBeanDef.getPropertyValues().addPropertyValue(USER_DETAILS_SERVICE_PROPERTY,
- new RuntimeBeanReference(rememberMeServicesRef));
- }
- }
-
- return rememberMeServicesBeanDef;
- }
-
- protected static RootBeanDefinition createAndRegisterBeanDefintionWithDefaults(ParserContext parserContext){
- RootBeanDefinition beanDefinition = new RootBeanDefinition(TokenBasedRememberMeServices.class);
- beanDefinition.getPropertyValues().addPropertyValue(KEY, "key");
- parserContext.getReaderContext().registerWithGeneratedName(beanDefinition);
- return beanDefinition;
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/SecurityAutoDetectNamepsaceHandler.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/SecurityAutoDetectNamepsaceHandler.java
deleted file mode 100644
index 98d3bf7271..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/SecurityAutoDetectNamepsaceHandler.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
-/**
- * @author Vishal Puri
- *
- */
-public class SecurityAutoDetectNamepsaceHandler extends NamespaceHandlerSupport {
-
- /* (non-Javadoc)
- * @see org.springframework.beans.factory.xml.NamespaceHandler#init()
- */
- public void init() {
- registerBeanDefinitionParser("autoconfig", new AutoConfigBeanDefinitionParser());
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/SecurityNamespaceHandler.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/SecurityNamespaceHandler.java
deleted file mode 100644
index c694e59f4f..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/config/SecurityNamespaceHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- */
-package org.acegisecurity.config;
-
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
-/**
- * {@link org.springframework.beans.factory.xml.NamespaceHandler} for the 'security
' namespace.
- * @author vpuri
- *
- * @since
- */
-public class SecurityNamespaceHandler extends NamespaceHandlerSupport {
-
- /**
- * Register the {@link BeanDefinitionParser BeanDefinitionParsers} for the
- * 'context-integration
', ' and '
' elements.
- */
- public void init() {
- registerBeanDefinitionParser("principal-repository", new PrincipalRepositoryBeanDefinitionParser());
- registerBeanDefinitionParser("session-context-integration", new ContextIntegrationBeanDefinitionParser());
- registerBeanDefinitionParser("authentication-repository", new AuthenticationRepositoryBeanDefinitionParser());
- registerBeanDefinitionParser("authentication-mechanism", new AuthenticationMechanismBeanDefinitionParser());
- registerBeanDefinitionParser("authentication-remember-me-services", new RememberMeServicesBeanDefinitionParser());
- registerBeanDefinitionParser("authentication-remember-me-filter", new RememberMeFilterBeanDefinitionParser());
- registerBeanDefinitionParser("logout-support", new LogoutFilterBeanDefinitionParser());
- registerBeanDefinitionParser("exception-translation", new ExceptionTranslationFilterBeanDefinitionParser());
- registerBeanDefinitionParser("authentication-form", new AuthenticationProcessingFilterBeanDefinitionParser());
- registerBeanDefinitionParser("authorization-manager", new AuthorizationManagerBeanDefinitionParser());
- registerBeanDefinitionParser("authorization-http-url", new FilterSecurityInterceptorBeanDefinitionParser());
- registerBeanDefinitionParser("authorization-joinpoint", new AuthorizationMethodBeanDefinitionParser());
- registerBeanDefinitionParser("autoconfig", new AutoConfigBeanDefinitionParser());
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/ui/basicauth/BasicProcessingFilter.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/ui/basicauth/BasicProcessingFilter.java
deleted file mode 100644
index 6a226d53ed..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/ui/basicauth/BasicProcessingFilter.java
+++ /dev/null
@@ -1,239 +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.acegisecurity.ui.basicauth;
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.acegisecurity.Authentication;
-import org.acegisecurity.AuthenticationException;
-import org.acegisecurity.AuthenticationManager;
-import org.acegisecurity.context.SecurityContextHolder;
-import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
-import org.acegisecurity.ui.AuthenticationDetailsSource;
-import org.acegisecurity.ui.AuthenticationDetailsSourceImpl;
-import org.acegisecurity.ui.AuthenticationEntryPoint;
-import org.acegisecurity.ui.rememberme.RememberMeServices;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.Ordered;
-import org.springframework.util.Assert;
-
-
-/**
- * Processes a HTTP request's BASIC authorization headers, putting the result into the
- * SecurityContextHolder
.For a detailed background on what this filter is designed to process, - * refer to RFC 1945, Section 11.1. Any realm name presented in - * the HTTP request is ignored.
- *In summary, this filter is responsible for processing any request that has a HTTP request header of
- * Authorization
with an authentication scheme of Basic
and a Base64-encoded
- * username:password
token. For example, to authenticate user "Aladdin" with password "open sesame" the
- * following header would be presented:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
.
This filter can be used to provide BASIC authentication services to both remoting protocol clients (such as - * Hessian and SOAP) as well as standard user agents (such as Internet Explorer and Netscape).
- *If authentication is successful, the resulting {@link Authentication} object will be placed into the
- * SecurityContextHolder
.
If authentication fails and ignoreFailure
is false
(the default), an {@link
- * AuthenticationEntryPoint} implementation is called. Usually this should be {@link BasicProcessingFilterEntryPoint},
- * which will prompt the user to authenticate again via BASIC authentication.
Basic authentication is an attractive protocol because it is simple and widely deployed. However, it still - * transmits a password in clear text and as such is undesirable in many situations. Digest authentication is also - * provided by Acegi Security and should be used instead of Basic authentication wherever possible. See {@link - * org.acegisecurity.ui.digestauth.DigestProcessingFilter}.
- *Note that if a {@link #rememberMeServices} is set, this filter will automatically send back remember-me - * details to the client. Therefore, subsequent requests will not need to present a BASIC authentication header as - * they will be authenticated using the remember-me mechanism.
- *Do not use this class directly. Instead configure web.xml
to use the {@link
- * org.acegisecurity.util.FilterToBeanProxy}.
SecurityEnforcementFilter
to commence authentication via the {@link
- * BasicProcessingFilter}.Once a user agent is authenticated using BASIC authentication, logout requires that - * the browser be closed or an unauthorized (401) header be sent. The simplest way of achieving the latter is to call - * the {@link #commence(ServletRequest, ServletResponse, AuthenticationException)} method below. This will indicate to - * the browser its credentials are no longer authorized, causing it to prompt the user to login again.
- * - * @author Ben Alex - * @version $Id: BasicProcessingFilterEntryPoint.java 1822 2007-05-17 12:20:16Z vishalpuri $ - */ -public class BasicProcessingFilterEntryPoint implements AuthenticationEntryPoint, InitializingBean, Ordered, ApplicationContextAware { - //~ Instance fields ================================================================================================ - - private static final int DEFAULT_ORDER = Integer.MAX_VALUE; - private String realmName; - private int order = DEFAULT_ORDER; - private ApplicationContext applicationContext; - - //~ Methods ======================================================================================================== - - public int getOrder() { - return order; - } - - public void setOrder(int order) { - this.order = order; - } - - public void afterPropertiesSet() throws Exception { - Assert.hasText(realmName, "realmName must be specified"); - if (order == DEFAULT_ORDER) { - OrderedUtils.copyOrderFromOtherClass(BasicProcessingFilter.class, applicationContext, this, true); - } - } - - public void commence(ServletRequest request, ServletResponse response, AuthenticationException authException) - throws IOException, ServletException { - HttpServletResponse httpResponse = (HttpServletResponse) response; - httpResponse.addHeader("WWW-Authenticate", "Basic realm=\"" + realmName + "\""); - httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); - } - - public String getRealmName() { - return realmName; - } - - public void setRealmName(String realmName) { - this.realmName = realmName; - } - - public void setApplicationContext(ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - } -} diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/ui/basicauth/package.html b/sandbox/spring-security-config/src/main/java/org/acegisecurity/ui/basicauth/package.html deleted file mode 100644 index dcd7c31c91..0000000000 --- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/ui/basicauth/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -Authenticates HTTP BASIC authentication requests. - - diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/util/BeanDefinitionParserUtils.java b/sandbox/spring-security-config/src/main/java/org/acegisecurity/util/BeanDefinitionParserUtils.java deleted file mode 100644 index cf3141a3d6..0000000000 --- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/util/BeanDefinitionParserUtils.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * - */ -package org.acegisecurity.util; - -import org.springframework.beans.factory.config.RuntimeBeanNameReference; -import org.springframework.beans.factory.config.RuntimeBeanReference; -import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.util.StringUtils; -import org.w3c.dom.Element; - -/** - * The convenience methods for the parsing of bean definition xml file. - * - * @author Vishal Puri - * - */ -public class BeanDefinitionParserUtils { - // ~ Constructor - // ================================================================================================ - - /** - * Prevents instantiation - */ - private BeanDefinitionParserUtils() { - } - - // ~ Method - // ================================================================================================ - - public static void setConstructorArgumentIfAvailable(int index, Element element, String attribute, - boolean isRunTimeBeanReference, RootBeanDefinition definition) { - String propertyValue = element.getAttribute(attribute); - if (StringUtils.hasText(propertyValue)) { - if (!isRunTimeBeanReference) { - definition.getConstructorArgumentValues().addIndexedArgumentValue(index, propertyValue); - } - else { - definition.getConstructorArgumentValues().addIndexedArgumentValue(index, - new RuntimeBeanNameReference(propertyValue)); - } - } - } - - /** - *
- * Configure a BeanDefinition
with the property value
- * retrieved from xml attribute. If the attribute is like a standard spring
- * 'ref' attribute as indicated by 'isRunTimeBeanReference', the property
- * will be resolved as a reference to the spring bean.
- *
sourceClass
. If found, the order from the source
- * class instance is copied into the destinationObject
. If more than one instance of sourceClass
- * is found, the method throws IllegalStateException
.
- *
- * The destinationObject
is required to provide a public setOrder(int)
method to permit
- * mutation of the order property.
- *
- * @param sourceClass to locate in the application context (must be assignable to Ordered)
- * @param applicationContext to locate the class
- * @param destinationObject to copy the order into (must provide public setOrder(int) method)
- * @param skipIfMoreThanOneCandidateSourceClassInstance if the application context provides more than one potential source, skip modifications (if false, the first located matching source will be used)
- * @return whether or not the destination class was updated
- */
- public static boolean copyOrderFromOtherClass(Class sourceClass, ApplicationContext applicationContext, Object destinationObject, boolean skipIfMoreThanOneCandidateSourceClassInstance) {
- Assert.notNull(sourceClass, "Source class required");
- Assert.notNull(applicationContext, "ApplicationContext required");
- Assert.notNull(destinationObject, "Destination object required");
- Assert.isAssignable(Ordered.class, sourceClass, "Source class " + sourceClass + " must be assignable to Ordered");
- Map map = applicationContext.getBeansOfType(sourceClass);
- if (map.size() == 0) {
- return false;
- } else if (map.size() > 1 && skipIfMoreThanOneCandidateSourceClassInstance) {
- return false;
- } else {
- copyOrderFromOtherObject((Ordered)map.values().iterator().next(), destinationObject);
- return true;
- }
- }
-
- /**
- * Copies the order property from the sourceObject
into the destinationObject
.
- *
- *
The destinationObject
is required to provide a public setOrder(int)
method to permit
- * mutation of the order property.
- *
- * @param sourceObject to copy the order from
- * @param destinationObject to copy the order into (must provide public setOrder(int) method)
- */
- public static void copyOrderFromOtherObject(Ordered sourceObject, Object destinationObject) {
- Assert.notNull(sourceObject, "Source object required");
- Assert.notNull(destinationObject, "Destination object required");
- Method m = ReflectionUtils.findMethod(destinationObject.getClass(), "setOrder", new Class[] {int.class});
- Assert.notNull(m, "Method setOrder(int) not found on " + destinationObject.getClass());
- ReflectionUtils.invokeMethod(m, destinationObject, new Object[] { Integer.valueOf((sourceObject.getOrder()))});
- }
-
-}
diff --git a/sandbox/spring-security-config/src/main/java/org/acegisecurity/util/package.html b/sandbox/spring-security-config/src/main/java/org/acegisecurity/util/package.html
deleted file mode 100644
index d845e7485f..0000000000
--- a/sandbox/spring-security-config/src/main/java/org/acegisecurity/util/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
HttpSession
. In most normal environments this does not
- represent an issue, as changes to the security identity in one thread is
- allowed to affect the security identitiy in other threads associated with
- the same 'HttpSession'.
- ]]>
-