diff --git a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/ldap/LdapAuthenticationProviderConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/ldap/LdapAuthenticationProviderConfigurer.java index dec4fe9bc5..ab9b3aa364 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/ldap/LdapAuthenticationProviderConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/ldap/LdapAuthenticationProviderConfigurer.java @@ -20,8 +20,10 @@ import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.encoding.PasswordEncoder; import org.springframework.security.authentication.encoding.PlaintextPasswordEncoder; +import org.springframework.security.config.annotation.ObjectPostProcessor; import org.springframework.security.config.annotation.SecurityConfigurerAdapter; import org.springframework.security.config.annotation.authentication.ProviderManagerBuilder; +import org.springframework.security.config.annotation.web.configurers.ChannelSecurityConfigurer; import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; import org.springframework.security.ldap.DefaultSpringSecurityContextSource; import org.springframework.security.ldap.authentication.AbstractLdapAuthenticator; @@ -81,6 +83,17 @@ public class LdapAuthenticationProviderConfigurer withObjectPostProcessor(ObjectPostProcessor objectPostProcessor) { + addObjectPostProcessor(objectPostProcessor); + return this; + } + /** * Creates the {@link LdapAuthenticator} to use * diff --git a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/userdetails/AbstractDaoAuthenticationConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/userdetails/AbstractDaoAuthenticationConfigurer.java index 72b45963da..cc30dd96a2 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/userdetails/AbstractDaoAuthenticationConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/userdetails/AbstractDaoAuthenticationConfigurer.java @@ -16,6 +16,7 @@ package org.springframework.security.config.annotation.authentication.configurers.userdetails; import org.springframework.security.authentication.dao.DaoAuthenticationProvider; +import org.springframework.security.config.annotation.ObjectPostProcessor; import org.springframework.security.config.annotation.SecurityBuilder; import org.springframework.security.config.annotation.SecurityConfigurer; import org.springframework.security.config.annotation.authentication.ProviderManagerBuilder; @@ -47,6 +48,18 @@ abstract class AbstractDaoAuthenticationConfigurer objectPostProcessor) { + addObjectPostProcessor(objectPostProcessor); + return (C) this; + } + /** * Allows specifying the {@link PasswordEncoder} to use with the {@link DaoAuthenticationProvider}. The default is * is to use plain text. diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractAuthenticationFilterConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractAuthenticationFilterConfigurer.java index cd191c6c21..7496508a85 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractAuthenticationFilterConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractAuthenticationFilterConfigurer.java @@ -50,7 +50,7 @@ import org.springframework.web.accept.HeaderContentNegotiationStrategy; * @author Rob Winch * @since 3.2 */ -public abstract class AbstractAuthenticationFilterConfigurer,T extends AbstractAuthenticationFilterConfigurer, F extends AbstractAuthenticationProcessingFilter> extends AbstractHttpConfigurer { +public abstract class AbstractAuthenticationFilterConfigurer,T extends AbstractAuthenticationFilterConfigurer, F extends AbstractAuthenticationProcessingFilter> extends AbstractHttpConfigurer { private final F authFilter; diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractHttpConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractHttpConfigurer.java index bb7b21136d..4bd4d0479e 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractHttpConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractHttpConfigurer.java @@ -15,6 +15,7 @@ */ package org.springframework.security.config.annotation.web.configurers; +import org.springframework.security.config.annotation.ObjectPostProcessor; import org.springframework.security.config.annotation.SecurityConfigurer; import org.springframework.security.config.annotation.SecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; @@ -28,7 +29,7 @@ import org.springframework.security.web.DefaultSecurityFilterChain; * @author Rob Winch * */ -abstract class AbstractHttpConfigurer> extends SecurityConfigurerAdapter { +abstract class AbstractHttpConfigurer,B extends HttpSecurityBuilder> extends SecurityConfigurerAdapter { /** * Disables the {@link AbstractHttpConfigurer} by removing it. After doing @@ -41,4 +42,10 @@ abstract class AbstractHttpConfigurer> extends getBuilder().removeConfigurer(getClass()); return getBuilder(); } + + @SuppressWarnings("unchecked") + public T withObjectPostProcessor(ObjectPostProcessor objectPostProcessor) { + addObjectPostProcessor(objectPostProcessor); + return (T) this; + } } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java index 4a4dc01f57..19cfcc9185 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurer.java @@ -21,13 +21,11 @@ import java.util.UUID; import org.springframework.security.authentication.AnonymousAuthenticationProvider; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.config.annotation.SecurityConfigurer; -import org.springframework.security.config.annotation.SecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.web.DefaultSecurityFilterChain; import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; /** @@ -39,7 +37,7 @@ import org.springframework.security.web.authentication.AnonymousAuthenticationFi * @author Rob Winch * @since 3.2 */ -public final class AnonymousConfigurer> extends AbstractHttpConfigurer { +public final class AnonymousConfigurer> extends AbstractHttpConfigurer,H> { private String key; private AuthenticationProvider authenticationProvider; private AnonymousAuthenticationFilter authenticationFilter; diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java index 1a2547cf00..6f7b48894a 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java @@ -22,6 +22,7 @@ import java.util.List; import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.SecurityConfig; +import org.springframework.security.config.annotation.ObjectPostProcessor; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.web.DefaultSecurityFilterChain; @@ -99,6 +100,17 @@ public final class ChannelSecurityConfigurer> e http.addFilter(channelFilter); } + /** + * Adds an {@link ObjectPostProcessor} for this class. + * + * @param objectPostProcessor + * @return the {@link ChannelSecurityConfigurer} for further customizations + */ + public ChannelSecurityConfigurer withObjectPostProcessor(ObjectPostProcessor objectPostProcessor) { + addObjectPostProcessor(objectPostProcessor); + return this; + } + /** * Sets the {@link ChannelProcessor} instances to use in {@link ChannelDecisionManagerImpl} * @param channelProcessors diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java index 7879cf7440..bfe2cbccad 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java @@ -55,7 +55,7 @@ import org.springframework.util.Assert; * @author Rob Winch * @since 3.2 */ -public final class CsrfConfigurer> extends AbstractHttpConfigurer { +public final class CsrfConfigurer> extends AbstractHttpConfigurer,H> { private CsrfTokenRepository csrfTokenRepository = new HttpSessionCsrfTokenRepository(); private RequestMatcher requireCsrfProtectionMatcher; diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java index 19b7c3c026..a0e063f0a1 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/DefaultLoginPageConfigurer.java @@ -54,7 +54,7 @@ import org.springframework.security.web.authentication.ui.DefaultLoginPageViewFi * @since 3.2 */ public final class DefaultLoginPageConfigurer> extends - AbstractHttpConfigurer { + AbstractHttpConfigurer,H> { private DefaultLoginPageViewFilter loginPageGeneratingFilter = new DefaultLoginPageViewFilter(); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java index cfaf8e1eb2..dc54d94472 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurer.java @@ -59,7 +59,7 @@ import org.springframework.security.web.util.RequestMatcher; * @author Rob Winch * @since 3.2 */ -public final class ExceptionHandlingConfigurer> extends AbstractHttpConfigurer { +public final class ExceptionHandlingConfigurer> extends AbstractHttpConfigurer,H> { private AuthenticationEntryPoint authenticationEntryPoint; diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExpressionUrlAuthorizationConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExpressionUrlAuthorizationConfigurer.java index dc7529eca4..6e8673818f 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExpressionUrlAuthorizationConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExpressionUrlAuthorizationConfigurer.java @@ -24,6 +24,7 @@ import org.springframework.security.access.AccessDecisionVoter; import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.SecurityConfig; import org.springframework.security.access.expression.SecurityExpressionHandler; +import org.springframework.security.config.annotation.ObjectPostProcessor; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.web.FilterInvocation; @@ -95,6 +96,17 @@ public final class ExpressionUrlAuthorizationConfigurer withObjectPostProcessor(ObjectPostProcessor objectPostProcessor) { + addObjectPostProcessor(objectPostProcessor); + return this; + } + @Override protected final AuthorizedUrl chainRequestMatchersInternal(List requestMatchers) { return new AuthorizedUrl(requestMatchers); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java index fb4cfda84b..061ce79265 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java @@ -34,7 +34,7 @@ import org.springframework.util.Assert; * @since 3.2 * @see RememberMeConfigurer */ -public final class HeadersConfigurer> extends AbstractHttpConfigurer { +public final class HeadersConfigurer> extends AbstractHttpConfigurer,H> { private List headerWriters = new ArrayList(); /** diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java index 0b44872fee..3ea33b9969 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurer.java @@ -65,7 +65,7 @@ import org.springframework.web.accept.HeaderContentNegotiationStrategy; * @author Rob Winch * @since 3.2 */ -public final class HttpBasicConfigurer> extends AbstractHttpConfigurer { +public final class HttpBasicConfigurer> extends AbstractHttpConfigurer,B> { private static final String DEFAULT_REALM = "Spring Security Application"; private AuthenticationEntryPoint authenticationEntryPoint = new BasicAuthenticationEntryPoint(); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java index ba9c957d3c..cadbd5eb7e 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurer.java @@ -68,7 +68,7 @@ import org.springframework.security.web.authentication.preauth.j2ee.J2eePreAuthe * @author Rob Winch * @since 3.2 */ -public final class JeeConfigurer> extends AbstractHttpConfigurer { +public final class JeeConfigurer> extends AbstractHttpConfigurer,H> { private J2eePreAuthenticatedProcessingFilter j2eePreAuthenticatedProcessingFilter; private AuthenticationUserDetailsService authenticationUserDetailsService; private Set mappableRoles = new HashSet(); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java index ef5f918149..7e71ca5ff9 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java @@ -59,7 +59,7 @@ import org.springframework.security.web.util.RequestMatcher; * @since 3.2 * @see RememberMeConfigurer */ -public final class LogoutConfigurer> extends AbstractHttpConfigurer { +public final class LogoutConfigurer> extends AbstractHttpConfigurer,H> { private List logoutHandlers = new ArrayList(); private SecurityContextLogoutHandler contextLogoutHandler = new SecurityContextLogoutHandler(); private String logoutSuccessUrl = "/login?logout"; diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java index 33c5f65587..556ec2733e 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/PortMapperConfigurer.java @@ -33,7 +33,7 @@ import org.springframework.security.web.PortMapperImpl; * @author Rob Winch * @since 3.2 */ -public final class PortMapperConfigurer> extends SecurityConfigurerAdapter { +public final class PortMapperConfigurer> extends AbstractHttpConfigurer,H> { private PortMapper portMapper; private Map httpsPortMappings = new HashMap(); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java index 47defc4c15..b57e187e21 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java @@ -72,7 +72,7 @@ import org.springframework.security.web.authentication.ui.DefaultLoginPageViewFi * @author Rob Winch * @since 3.2 */ -public final class RememberMeConfigurer> extends AbstractHttpConfigurer { +public final class RememberMeConfigurer> extends AbstractHttpConfigurer,H> { private AuthenticationSuccessHandler authenticationSuccessHandler; private String key; private RememberMeServices rememberMeServices; diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java index 7d5747b6d9..52b4596fec 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurer.java @@ -55,7 +55,7 @@ import org.springframework.security.web.util.AntPathRequestMatcher; * @since 3.2 * @see RequestCache */ -public final class RequestCacheConfigurer> extends AbstractHttpConfigurer { +public final class RequestCacheConfigurer> extends AbstractHttpConfigurer,H> { public RequestCacheConfigurer() { } diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java index b06a7e3c3f..483a6e995c 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SecurityContextConfigurer.java @@ -58,7 +58,7 @@ import org.springframework.security.web.context.SecurityContextRepository; * @author Rob Winch * @since 3.2 */ -public final class SecurityContextConfigurer> extends AbstractHttpConfigurer { +public final class SecurityContextConfigurer> extends AbstractHttpConfigurer,H> { /** * Creates a new instance diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java index b343e4f3a5..e309923032 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/ServletApiConfigurer.java @@ -49,7 +49,7 @@ import org.springframework.security.web.servletapi.SecurityContextHolderAwareReq * @author Rob Winch * @since 3.2 */ -public final class ServletApiConfigurer> extends AbstractHttpConfigurer { +public final class ServletApiConfigurer> extends AbstractHttpConfigurer,H> { private SecurityContextHolderAwareRequestFilter securityContextRequestFilter = new SecurityContextHolderAwareRequestFilter(); /** diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java index de865a5d87..9eee4b0a53 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java @@ -78,7 +78,7 @@ import org.springframework.util.Assert; * @see SessionManagementFilter * @see ConcurrentSessionFilter */ -public final class SessionManagementConfigurer> extends AbstractHttpConfigurer { +public final class SessionManagementConfigurer> extends AbstractHttpConfigurer,H> { private SessionAuthenticationStrategy sessionFixationAuthenticationStrategy = createDefaultSessionFixationProtectionStrategy(); private SessionAuthenticationStrategy sessionAuthenticationStrategy; private List sessionAuthenticationStrategies = new ArrayList(); diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/UrlAuthorizationConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/UrlAuthorizationConfigurer.java index f6efedd0c2..d3c2d933ea 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/UrlAuthorizationConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/UrlAuthorizationConfigurer.java @@ -25,6 +25,7 @@ import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.SecurityConfig; import org.springframework.security.access.vote.AuthenticatedVoter; import org.springframework.security.access.vote.RoleVoter; +import org.springframework.security.config.annotation.ObjectPostProcessor; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource; import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource; @@ -68,6 +69,17 @@ import org.springframework.util.Assert; */ public final class UrlAuthorizationConfigurer, C> extends AbstractInterceptUrlConfigurer.AuthorizedUrl> { + /** + * Adds an {@link ObjectPostProcessor} for this class. + * + * @param objectPostProcessor + * @return the {@link UrlAuthorizationConfigurer} for further customizations + */ + public UrlAuthorizationConfigurer withObjectPostProcessor(ObjectPostProcessor objectPostProcessor) { + addObjectPostProcessor(objectPostProcessor); + return this; + } + /** * Creates the default {@link AccessDecisionVoter} instances used if an * {@link AccessDecisionManager} was not specified using diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java index d1a4ed0c80..66ab860b93 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/X509Configurer.java @@ -71,7 +71,7 @@ import org.springframework.security.web.authentication.preauth.x509.X509Authenti * @author Rob Winch * @since 3.2 */ -public final class X509Configurer> extends AbstractHttpConfigurer { +public final class X509Configurer> extends AbstractHttpConfigurer,H> { private X509AuthenticationFilter x509AuthenticationFilter; private AuthenticationUserDetailsService authenticationUserDetailsService; private String subjectPrincipalRegex;