Skip to content

Commit 57d5cf9

Browse files
committed
Restore Deprecated ObjectPostProcessor Usage
Closes gh-16174
1 parent 03fc573 commit 57d5cf9

14 files changed

+151
-7
lines changed

config/src/main/java/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ protected AbstractConfiguredSecurityBuilder(ObjectPostProcessor<Object> objectPo
7979
this(objectPostProcessor, false);
8080
}
8181

82+
/**
83+
* @deprecated
84+
*/
85+
@Deprecated(since = "6.4", forRemoval = true)
86+
protected AbstractConfiguredSecurityBuilder(
87+
org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor) {
88+
this(objectPostProcessor, false);
89+
}
90+
8291
/***
8392
* Creates a new instance with the provided {@link ObjectPostProcessor}. This post
8493
* processor must support Object since there are many types of objects that may be
@@ -94,6 +103,18 @@ protected AbstractConfiguredSecurityBuilder(ObjectPostProcessor<Object> objectPo
94103
this.allowConfigurersOfSameType = allowConfigurersOfSameType;
95104
}
96105

106+
/**
107+
* @deprecated
108+
*/
109+
@Deprecated(since = "6.4", forRemoval = true)
110+
protected AbstractConfiguredSecurityBuilder(
111+
org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor,
112+
boolean allowConfigurersOfSameType) {
113+
Assert.notNull(objectPostProcessor, "objectPostProcessor cannot be null");
114+
this.objectPostProcessor = objectPostProcessor;
115+
this.allowConfigurersOfSameType = allowConfigurersOfSameType;
116+
}
117+
97118
/**
98119
* Similar to {@link #build()} and {@link #getObject()} but checks the state to
99120
* determine if {@link #build()} needs to be called first.

config/src/main/java/org/springframework/security/config/annotation/SecurityConfigurerAdapter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ public void addObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor) {
9292
this.objectPostProcessor.addObjectPostProcessor(objectPostProcessor);
9393
}
9494

95+
/**
96+
* @deprecated
97+
*/
98+
@Deprecated(since = "6.4", forRemoval = true)
99+
public void addObjectPostProcessor(
100+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
101+
this.objectPostProcessor.addObjectPostProcessor(objectPostProcessor);
102+
}
103+
95104
/**
96105
* Sets the {@link SecurityBuilder} to be used. This is automatically set when using
97106
* {@link AbstractConfiguredSecurityBuilder#apply(SecurityConfigurerAdapter)}

config/src/main/java/org/springframework/security/config/annotation/authentication/builders/AuthenticationManagerBuilder.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,17 @@ public class AuthenticationManagerBuilder
7070
* @param objectPostProcessor the
7171
* {@link org.springframework.security.config.annotation.ObjectPostProcessor} instance
7272
* to use.
73-
* @deprecated
7473
*/
75-
@Deprecated(since = "6.4", forRemoval = true)
76-
public AuthenticationManagerBuilder(
77-
org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor) {
74+
public AuthenticationManagerBuilder(ObjectPostProcessor<Object> objectPostProcessor) {
7875
super(objectPostProcessor, true);
7976
}
8077

8178
/**
82-
* Creates a new instance
83-
* @param objectPostProcessor the {@link ObjectPostProcessor} instance to use.
79+
* @deprecated
8480
*/
85-
public AuthenticationManagerBuilder(ObjectPostProcessor<Object> objectPostProcessor) {
81+
@Deprecated(since = "6.4", forRemoval = true)
82+
public AuthenticationManagerBuilder(
83+
org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor) {
8684
super(objectPostProcessor, true);
8785
}
8886

config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/ldap/LdapAuthenticationProviderConfigurer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ public LdapAuthenticationProviderConfigurer<B> withObjectPostProcessor(ObjectPos
140140
return this;
141141
}
142142

143+
/**
144+
* @deprecated
145+
*/
146+
@Deprecated(since = "6.4", forRemoval = true)
147+
public LdapAuthenticationProviderConfigurer<B> withObjectPostProcessor(
148+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
149+
addObjectPostProcessor(objectPostProcessor);
150+
return this;
151+
}
152+
143153
/**
144154
* Gets the {@link LdapAuthoritiesPopulator} and defaults to
145155
* {@link DefaultLdapAuthoritiesPopulator}

config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/userdetails/AbstractDaoAuthenticationConfigurer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ public C withObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor) {
6363
return (C) this;
6464
}
6565

66+
/**
67+
* @deprecated
68+
*/
69+
@Deprecated(since = "6.4", forRemoval = true)
70+
@SuppressWarnings("unchecked")
71+
public C withObjectPostProcessor(
72+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
73+
addObjectPostProcessor(objectPostProcessor);
74+
return (C) this;
75+
}
76+
6677
/**
6778
* Allows specifying the {@link PasswordEncoder} to use with the
6879
* {@link DaoAuthenticationProvider}. The default is to use plain text.

config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,16 @@ public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcess
407407
this.objectPostProcessor = objectPostProcessor;
408408
}
409409

410+
/**
411+
* @deprecated
412+
*/
413+
@Deprecated(since = "6.4", forRemoval = true)
414+
@Autowired(required = false)
415+
public void setObjectPostProcessor(
416+
org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor) {
417+
this.objectPostProcessor = objectPostProcessor;
418+
}
419+
410420
@Autowired(required = false)
411421
public void setMethodSecurityExpressionHandler(List<MethodSecurityExpressionHandler> handlers) {
412422
if (handlers.size() != 1) {

config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ public HttpSecurity(ObjectPostProcessor<Object> objectPostProcessor,
188188
this.requestMatcherConfigurer = new RequestMatcherConfigurer(context);
189189
}
190190

191+
/**
192+
* @deprecated
193+
*/
194+
@Deprecated(since = "6.4", forRemoval = true)
195+
@SuppressWarnings("unchecked")
196+
public HttpSecurity(org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor,
197+
AuthenticationManagerBuilder authenticationBuilder, Map<Class<?>, Object> sharedObjects) {
198+
super(objectPostProcessor);
199+
Assert.notNull(authenticationBuilder, "authenticationBuilder cannot be null");
200+
setSharedObject(AuthenticationManagerBuilder.class, authenticationBuilder);
201+
for (Map.Entry<Class<?>, Object> entry : sharedObjects.entrySet()) {
202+
setSharedObject((Class<Object>) entry.getKey(), entry.getValue());
203+
}
204+
ApplicationContext context = (ApplicationContext) sharedObjects.get(ApplicationContext.class);
205+
this.requestMatcherConfigurer = new RequestMatcherConfigurer(context);
206+
}
207+
191208
private ApplicationContext getContext() {
192209
return getSharedObject(ApplicationContext.class);
193210
}

config/src/main/java/org/springframework/security/config/annotation/web/builders/WebSecurity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ public WebSecurity(ObjectPostProcessor<Object> objectPostProcessor) {
135135
super(objectPostProcessor);
136136
}
137137

138+
/**
139+
* @deprecated
140+
*/
141+
@Deprecated(since = "6.4", forRemoval = true)
142+
public WebSecurity(org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor) {
143+
super(objectPostProcessor);
144+
}
145+
138146
/**
139147
* <p>
140148
* Allows adding {@link RequestMatcher} instances that Spring Security should ignore.

config/src/main/java/org/springframework/security/config/annotation/web/configuration/HttpSecurityConfiguration.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ static class DefaultPasswordEncoderAuthenticationManagerBuilder extends Authenti
178178
this.defaultPasswordEncoder = defaultPasswordEncoder;
179179
}
180180

181+
/**
182+
* @deprecated
183+
*/
184+
@Deprecated(since = "6.4", forRemoval = true)
185+
DefaultPasswordEncoderAuthenticationManagerBuilder(
186+
org.springframework.security.config.annotation.ObjectPostProcessor<Object> objectPostProcessor,
187+
PasswordEncoder defaultPasswordEncoder) {
188+
super(objectPostProcessor);
189+
this.defaultPasswordEncoder = defaultPasswordEncoder;
190+
}
191+
181192
@Override
182193
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication()
183194
throws Exception {

config/src/main/java/org/springframework/security/config/annotation/web/configurers/AbstractHttpConfigurer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ public T withObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor) {
5454
return (T) this;
5555
}
5656

57+
/**
58+
* @deprecated
59+
*/
60+
@Deprecated(since = "6.4", forRemoval = true)
61+
@SuppressWarnings("unchecked")
62+
public T withObjectPostProcessor(
63+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
64+
addObjectPostProcessor(objectPostProcessor);
65+
return (T) this;
66+
}
67+
5768
protected SecurityContextHolderStrategy getSecurityContextHolderStrategy() {
5869
if (this.securityContextHolderStrategy != null) {
5970
return this.securityContextHolderStrategy;

config/src/main/java/org/springframework/security/config/annotation/web/configurers/AuthorizeHttpRequestsConfigurer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ public AuthorizationManagerRequestMatcherRegistry withObjectPostProcessor(
193193
return this;
194194
}
195195

196+
/**
197+
* @deprecated
198+
*/
199+
@Deprecated(since = "6.4", forRemoval = true)
200+
public AuthorizationManagerRequestMatcherRegistry withObjectPostProcessor(
201+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
202+
addObjectPostProcessor(objectPostProcessor);
203+
return this;
204+
}
205+
196206
/**
197207
* Sets whether all dispatcher types should be filtered.
198208
* @param shouldFilter should filter all dispatcher types. Default is {@code true}

config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ public ChannelRequestMatcherRegistry withObjectPostProcessor(ObjectPostProcessor
169169
return this;
170170
}
171171

172+
/**
173+
* @deprecated
174+
*/
175+
@Deprecated(since = "6.4", forRemoval = true)
176+
public ChannelRequestMatcherRegistry withObjectPostProcessor(
177+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
178+
addObjectPostProcessor(objectPostProcessor);
179+
return this;
180+
}
181+
172182
/**
173183
* Sets the {@link ChannelProcessor} instances to use in
174184
* {@link ChannelDecisionManagerImpl}

config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExpressionUrlAuthorizationConfigurer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@ public ExpressionInterceptUrlRegistry withObjectPostProcessor(ObjectPostProcesso
238238
return this;
239239
}
240240

241+
/**
242+
* @deprecated
243+
*/
244+
@Deprecated(since = "6.4", forRemoval = true)
245+
public ExpressionInterceptUrlRegistry withObjectPostProcessor(
246+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
247+
addObjectPostProcessor(objectPostProcessor);
248+
return this;
249+
}
250+
241251
public H and() {
242252
return ExpressionUrlAuthorizationConfigurer.this.and();
243253
}

config/src/main/java/org/springframework/security/config/annotation/web/configurers/UrlAuthorizationConfigurer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ public UrlAuthorizationConfigurer<H> withObjectPostProcessor(ObjectPostProcessor
117117
return this;
118118
}
119119

120+
@Deprecated(since = "6.4", forRemoval = true)
121+
@Override
122+
public UrlAuthorizationConfigurer<H> withObjectPostProcessor(
123+
org.springframework.security.config.annotation.ObjectPostProcessor<?> objectPostProcessor) {
124+
addObjectPostProcessor(objectPostProcessor);
125+
return this;
126+
}
127+
120128
/**
121129
* Creates the default {@link AccessDecisionVoter} instances used if an
122130
* {@link AccessDecisionManager} was not specified.

0 commit comments

Comments
 (0)