mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-09 06:50:05 +00:00
Reduce method visibility when possible
Reduce method visibility for package private classes when possible. In the case of abstract classes that will eventually be made public, the class has been made public and a package-private constructor has been added. Issue gh-8945
This commit is contained in:
parent
ec6a4cb3f0
commit
8d3f039f76
@ -142,7 +142,7 @@ class AclClassIdUtils {
|
||||
return object.getClass().isAssignableFrom(String.class);
|
||||
}
|
||||
|
||||
public void setConversionService(ConversionService conversionService) {
|
||||
void setConversionService(ConversionService conversionService) {
|
||||
Assert.notNull(conversionService, "conversionService must not be null");
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
@ -655,15 +655,15 @@ public class BasicLookupStrategy implements LookupStrategy {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccessControlEntry> getEntries() {
|
||||
throw new UnsupportedOperationException("Stub only");
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdentity getObjectIdentity() {
|
||||
throw new UnsupportedOperationException("Stub only");
|
||||
|
@ -175,29 +175,29 @@ public class JdbcAclServiceTests {
|
||||
.isEqualTo(UUID.fromString("25d93b3f-c3aa-4814-9d5e-c7c96ced7762"));
|
||||
}
|
||||
|
||||
private class MockLongIdDomainObject {
|
||||
class MockLongIdDomainObject {
|
||||
|
||||
private Object id;
|
||||
|
||||
public Object getId() {
|
||||
Object getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Object id) {
|
||||
void setId(Object id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MockUntypedIdDomainObject {
|
||||
class MockUntypedIdDomainObject {
|
||||
|
||||
private Object id;
|
||||
|
||||
public Object getId() {
|
||||
Object getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Object id) {
|
||||
void setId(Object id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
|
||||
abstract static class BaseLdapServerConfig extends BaseLdapProviderConfig {
|
||||
|
||||
@Bean
|
||||
public ApacheDSContainer ldapServer() throws Exception {
|
||||
ApacheDSContainer ldapServer() throws Exception {
|
||||
ApacheDSContainer apacheDSContainer = new ApacheDSContainer("dc=springframework,dc=org",
|
||||
"classpath:/test-server.ldif");
|
||||
apacheDSContainer.setPort(getPort());
|
||||
@ -288,7 +288,7 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
|
||||
abstract static class BaseLdapProviderConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public BaseLdapPathContextSource contextSource() throws Exception {
|
||||
BaseLdapPathContextSource contextSource() throws Exception {
|
||||
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
|
||||
"ldap://127.0.0.1:" + getPort() + "/dc=springframework,dc=org");
|
||||
contextSource.setUserDn("uid=admin,ou=system");
|
||||
@ -298,7 +298,7 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationManagerBuilder auth) throws Exception {
|
||||
AuthenticationManager authenticationManager(AuthenticationManagerBuilder auth) throws Exception {
|
||||
configure(auth);
|
||||
return auth.build();
|
||||
}
|
||||
|
@ -116,19 +116,19 @@ public class HelloRSocketITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ServerController controller() {
|
||||
ServerController controller() {
|
||||
return new ServerController();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setRSocketStrategies(rsocketStrategies());
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketStrategies rsocketStrategies() {
|
||||
RSocketStrategies rsocketStrategies() {
|
||||
return RSocketStrategies.builder().encoder(new BasicAuthenticationEncoder()).build();
|
||||
}
|
||||
|
||||
|
@ -137,19 +137,19 @@ public class JwtITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ServerController controller() {
|
||||
ServerController controller() {
|
||||
return new ServerController();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setRSocketStrategies(rsocketStrategies());
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketStrategies rsocketStrategies() {
|
||||
RSocketStrategies rsocketStrategies() {
|
||||
return RSocketStrategies.builder().encoder(new BearerTokenAuthenticationEncoder()).build();
|
||||
}
|
||||
|
||||
|
@ -204,19 +204,19 @@ public class RSocketMessageHandlerConnectionITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ServerController controller() {
|
||||
ServerController controller() {
|
||||
return new ServerController();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setRSocketStrategies(rsocketStrategies());
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketStrategies rsocketStrategies() {
|
||||
RSocketStrategies rsocketStrategies() {
|
||||
return RSocketStrategies.builder().encoder(new BasicAuthenticationEncoder()).build();
|
||||
}
|
||||
|
||||
|
@ -186,19 +186,19 @@ public class RSocketMessageHandlerITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ServerController controller() {
|
||||
ServerController controller() {
|
||||
return new ServerController();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setRSocketStrategies(rsocketStrategies());
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketStrategies rsocketStrategies() {
|
||||
RSocketStrategies rsocketStrategies() {
|
||||
return RSocketStrategies.builder().encoder(new BasicAuthenticationEncoder()).build();
|
||||
}
|
||||
|
||||
|
@ -121,19 +121,19 @@ public class SimpleAuthenticationITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ServerController controller() {
|
||||
ServerController controller() {
|
||||
return new ServerController();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler messageHandler() {
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setRSocketStrategies(rsocketStrategies());
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RSocketStrategies rsocketStrategies() {
|
||||
RSocketStrategies rsocketStrategies() {
|
||||
return RSocketStrategies.builder().encoder(new SimpleAuthenticationEncoder()).build();
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
* @author Rob Winch
|
||||
* @since 3.2
|
||||
*/
|
||||
abstract class AbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuilder<B>, C extends AbstractDaoAuthenticationConfigurer<B, C, U>, U extends UserDetailsService>
|
||||
public abstract class AbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuilder<B>, C extends AbstractDaoAuthenticationConfigurer<B, C, U>, U extends UserDetailsService>
|
||||
extends UserDetailsAwareConfigurer<B, U> {
|
||||
|
||||
private DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
@ -44,7 +44,7 @@ abstract class AbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuil
|
||||
* Creates a new instance
|
||||
* @param userDetailsService
|
||||
*/
|
||||
protected AbstractDaoAuthenticationConfigurer(U userDetailsService) {
|
||||
AbstractDaoAuthenticationConfigurer(U userDetailsService) {
|
||||
this.userDetailsService = userDetailsService;
|
||||
this.provider.setUserDetailsService(userDetailsService);
|
||||
if (userDetailsService instanceof UserDetailsPasswordService) {
|
||||
|
@ -28,7 +28,7 @@ class Jsr250MetadataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public Jsr250MethodSecurityMetadataSource jsr250MethodSecurityMetadataSource() {
|
||||
Jsr250MethodSecurityMetadataSource jsr250MethodSecurityMetadataSource() {
|
||||
return new Jsr250MethodSecurityMetadataSource();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class ReactiveMethodSecurityConfiguration implements ImportAware {
|
||||
|
||||
@Bean
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public MethodSecurityMetadataSourceAdvisor methodSecurityInterceptor(AbstractMethodSecurityMetadataSource source) {
|
||||
MethodSecurityMetadataSourceAdvisor methodSecurityInterceptor(AbstractMethodSecurityMetadataSource source) {
|
||||
MethodSecurityMetadataSourceAdvisor advisor = new MethodSecurityMetadataSourceAdvisor(
|
||||
"securityMethodInterceptor", source, "methodMetadataSource");
|
||||
advisor.setOrder(this.advisorOrder);
|
||||
@ -60,7 +60,7 @@ class ReactiveMethodSecurityConfiguration implements ImportAware {
|
||||
|
||||
@Bean
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public DelegatingMethodSecurityMetadataSource methodMetadataSource(
|
||||
DelegatingMethodSecurityMetadataSource methodMetadataSource(
|
||||
MethodSecurityExpressionHandler methodSecurityExpressionHandler) {
|
||||
ExpressionBasedAnnotationAttributeFactory attributeFactory = new ExpressionBasedAnnotationAttributeFactory(
|
||||
methodSecurityExpressionHandler);
|
||||
@ -70,7 +70,7 @@ class ReactiveMethodSecurityConfiguration implements ImportAware {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PrePostAdviceReactiveMethodInterceptor securityMethodInterceptor(AbstractMethodSecurityMetadataSource source,
|
||||
PrePostAdviceReactiveMethodInterceptor securityMethodInterceptor(AbstractMethodSecurityMetadataSource source,
|
||||
MethodSecurityExpressionHandler handler) {
|
||||
|
||||
ExpressionBasedPostInvocationAdvice postAdvice = new ExpressionBasedPostInvocationAdvice(handler);
|
||||
@ -82,7 +82,7 @@ class ReactiveMethodSecurityConfiguration implements ImportAware {
|
||||
|
||||
@Bean
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public DefaultMethodSecurityExpressionHandler methodSecurityExpressionHandler() {
|
||||
DefaultMethodSecurityExpressionHandler methodSecurityExpressionHandler() {
|
||||
DefaultMethodSecurityExpressionHandler handler = new DefaultMethodSecurityExpressionHandler();
|
||||
if (this.grantedAuthorityDefaults != null) {
|
||||
handler.setDefaultRolePrefix(this.grantedAuthorityDefaults.getRolePrefix());
|
||||
|
@ -60,7 +60,7 @@ class RSocketSecurityConfiguration {
|
||||
|
||||
@Bean(name = RSOCKET_SECURITY_BEAN_NAME)
|
||||
@Scope("prototype")
|
||||
public RSocketSecurity rsocketSecurity(ApplicationContext context) {
|
||||
RSocketSecurity rsocketSecurity(ApplicationContext context) {
|
||||
RSocketSecurity security = new RSocketSecurity().authenticationManager(authenticationManager());
|
||||
security.setApplicationContext(context);
|
||||
return security;
|
||||
|
@ -235,6 +235,9 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
||||
*/
|
||||
private static final class RequestMatchers {
|
||||
|
||||
private RequestMatchers() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link List} of {@link AntPathRequestMatcher} instances.
|
||||
* @param httpMethod the {@link HttpMethod} to use or {@code null} for any
|
||||
@ -243,7 +246,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
||||
* from
|
||||
* @return a {@link List} of {@link AntPathRequestMatcher} instances
|
||||
*/
|
||||
public static List<RequestMatcher> antMatchers(HttpMethod httpMethod, String... antPatterns) {
|
||||
static List<RequestMatcher> antMatchers(HttpMethod httpMethod, String... antPatterns) {
|
||||
String method = httpMethod == null ? null : httpMethod.toString();
|
||||
List<RequestMatcher> matchers = new ArrayList<>();
|
||||
for (String pattern : antPatterns) {
|
||||
@ -259,7 +262,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
||||
* from
|
||||
* @return a {@link List} of {@link AntPathRequestMatcher} instances
|
||||
*/
|
||||
public static List<RequestMatcher> antMatchers(String... antPatterns) {
|
||||
static List<RequestMatcher> antMatchers(String... antPatterns) {
|
||||
return antMatchers(null, antPatterns);
|
||||
}
|
||||
|
||||
@ -271,7 +274,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
||||
* {@link RegexRequestMatcher} from
|
||||
* @return a {@link List} of {@link RegexRequestMatcher} instances
|
||||
*/
|
||||
public static List<RequestMatcher> regexMatchers(HttpMethod httpMethod, String... regexPatterns) {
|
||||
static List<RequestMatcher> regexMatchers(HttpMethod httpMethod, String... regexPatterns) {
|
||||
String method = httpMethod == null ? null : httpMethod.toString();
|
||||
List<RequestMatcher> matchers = new ArrayList<>();
|
||||
for (String pattern : regexPatterns) {
|
||||
@ -287,13 +290,10 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
||||
* {@link RegexRequestMatcher} from
|
||||
* @return a {@link List} of {@link RegexRequestMatcher} instances
|
||||
*/
|
||||
public static List<RequestMatcher> regexMatchers(String... regexPatterns) {
|
||||
static List<RequestMatcher> regexMatchers(String... regexPatterns) {
|
||||
return regexMatchers(null, regexPatterns);
|
||||
}
|
||||
|
||||
private RequestMatchers() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
* @param filter
|
||||
* @return
|
||||
*/
|
||||
public boolean isRegistered(Class<? extends Filter> filter) {
|
||||
boolean isRegistered(Class<? extends Filter> filter) {
|
||||
return getOrder(filter) != null;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
* @param afterFilter the {@link Filter} that is already registered and that
|
||||
* {@code filter} should be placed after.
|
||||
*/
|
||||
public void registerAfter(Class<? extends Filter> filter, Class<? extends Filter> afterFilter) {
|
||||
void registerAfter(Class<? extends Filter> filter, Class<? extends Filter> afterFilter) {
|
||||
Integer position = getOrder(afterFilter);
|
||||
if (position == null) {
|
||||
throw new IllegalArgumentException("Cannot register after unregistered Filter " + afterFilter);
|
||||
@ -151,7 +151,7 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
* @param atFilter the {@link Filter} that is already registered and that
|
||||
* {@code filter} should be placed at.
|
||||
*/
|
||||
public void registerAt(Class<? extends Filter> filter, Class<? extends Filter> atFilter) {
|
||||
void registerAt(Class<? extends Filter> filter, Class<? extends Filter> atFilter) {
|
||||
Integer position = getOrder(atFilter);
|
||||
if (position == null) {
|
||||
throw new IllegalArgumentException("Cannot register after unregistered Filter " + atFilter);
|
||||
@ -167,7 +167,7 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
* @param beforeFilter the {@link Filter} that is already registered and that
|
||||
* {@code filter} should be placed before.
|
||||
*/
|
||||
public void registerBefore(Class<? extends Filter> filter, Class<? extends Filter> beforeFilter) {
|
||||
void registerBefore(Class<? extends Filter> filter, Class<? extends Filter> beforeFilter) {
|
||||
Integer position = getOrder(beforeFilter);
|
||||
if (position == null) {
|
||||
throw new IllegalArgumentException("Cannot register after unregistered Filter " + beforeFilter);
|
||||
|
@ -35,9 +35,8 @@ import org.springframework.util.Assert;
|
||||
* {@link ApplicationContext} but ignoring the parent.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*
|
||||
*/
|
||||
final class AutowiredWebSecurityConfigurersIgnoreParents {
|
||||
public final class AutowiredWebSecurityConfigurersIgnoreParents {
|
||||
|
||||
private final ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
|
@ -56,7 +56,7 @@ class HttpSecurityConfiguration {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
|
||||
void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
|
||||
this.objectPostProcessor = objectPostProcessor;
|
||||
}
|
||||
|
||||
@ -66,18 +66,18 @@ class HttpSecurityConfiguration {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setAuthenticationConfiguration(AuthenticationConfiguration authenticationConfiguration) {
|
||||
void setAuthenticationConfiguration(AuthenticationConfiguration authenticationConfiguration) {
|
||||
this.authenticationConfiguration = authenticationConfiguration;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setApplicationContext(ApplicationContext context) {
|
||||
void setApplicationContext(ApplicationContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Bean(HTTPSECURITY_BEAN_NAME)
|
||||
@Scope("prototype")
|
||||
public HttpSecurity httpSecurity() throws Exception {
|
||||
HttpSecurity httpSecurity() throws Exception {
|
||||
WebSecurityConfigurerAdapter.LazyPasswordEncoder passwordEncoder = new WebSecurityConfigurerAdapter.LazyPasswordEncoder(
|
||||
this.context);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class WebMvcSecurityConfiguration implements WebMvcConfigurer, ApplicationContex
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RequestDataValueProcessor requestDataValueProcessor() {
|
||||
RequestDataValueProcessor requestDataValueProcessor() {
|
||||
return new CsrfRequestDataValueProcessor();
|
||||
}
|
||||
|
||||
|
@ -122,20 +122,20 @@ public abstract class AbstractConfigAttributeRequestMatcherRegistry<C> extends A
|
||||
*/
|
||||
static final class UrlMapping {
|
||||
|
||||
private RequestMatcher requestMatcher;
|
||||
private final RequestMatcher requestMatcher;
|
||||
|
||||
private Collection<ConfigAttribute> configAttrs;
|
||||
private final Collection<ConfigAttribute> configAttrs;
|
||||
|
||||
UrlMapping(RequestMatcher requestMatcher, Collection<ConfigAttribute> configAttrs) {
|
||||
this.requestMatcher = requestMatcher;
|
||||
this.configAttrs = configAttrs;
|
||||
}
|
||||
|
||||
public RequestMatcher getRequestMatcher() {
|
||||
RequestMatcher getRequestMatcher() {
|
||||
return this.requestMatcher;
|
||||
}
|
||||
|
||||
public Collection<ConfigAttribute> getConfigAttrs() {
|
||||
Collection<ConfigAttribute> getConfigAttrs() {
|
||||
return this.configAttrs;
|
||||
}
|
||||
|
||||
|
@ -61,13 +61,16 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
|
||||
* @see ExpressionUrlAuthorizationConfigurer
|
||||
* @see UrlAuthorizationConfigurer
|
||||
*/
|
||||
abstract class AbstractInterceptUrlConfigurer<C extends AbstractInterceptUrlConfigurer<C, H>, H extends HttpSecurityBuilder<H>>
|
||||
public abstract class AbstractInterceptUrlConfigurer<C extends AbstractInterceptUrlConfigurer<C, H>, H extends HttpSecurityBuilder<H>>
|
||||
extends AbstractHttpConfigurer<C, H> {
|
||||
|
||||
private Boolean filterSecurityInterceptorOncePerRequest;
|
||||
|
||||
private AccessDecisionManager accessDecisionManager;
|
||||
|
||||
AbstractInterceptUrlConfigurer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(H http) throws Exception {
|
||||
FilterInvocationSecurityMetadataSource metadataSource = createMetadataSource(http);
|
||||
@ -145,9 +148,12 @@ abstract class AbstractInterceptUrlConfigurer<C extends AbstractInterceptUrlConf
|
||||
return securityInterceptor;
|
||||
}
|
||||
|
||||
abstract class AbstractInterceptUrlRegistry<R extends AbstractInterceptUrlRegistry<R, T>, T>
|
||||
public abstract class AbstractInterceptUrlRegistry<R extends AbstractInterceptUrlRegistry<R, T>, T>
|
||||
extends AbstractConfigAttributeRequestMatcherRegistry<T> {
|
||||
|
||||
AbstractInterceptUrlRegistry() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows setting the {@link AccessDecisionManager}. If none is provided, a
|
||||
* default {@link AccessDecisionManager} is created.
|
||||
|
@ -338,7 +338,7 @@ public final class CsrfConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
return mvcMatchers(null, mvcPatterns);
|
||||
}
|
||||
|
||||
public CsrfConfigurer<H> and() {
|
||||
CsrfConfigurer<H> and() {
|
||||
return CsrfConfigurer.this;
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ public final class CsrfConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
this.mvcMatchers = mvcMatchers;
|
||||
}
|
||||
|
||||
public IgnoreCsrfProtectionRegistry servletPath(String servletPath) {
|
||||
IgnoreCsrfProtectionRegistry servletPath(String servletPath) {
|
||||
for (MvcRequestMatcher matcher : this.mvcMatchers) {
|
||||
matcher.setServletPath(servletPath);
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||
*/
|
||||
final class PermitAllSupport {
|
||||
|
||||
public static void permitAll(HttpSecurityBuilder<? extends HttpSecurityBuilder<?>> http, String... urls) {
|
||||
private PermitAllSupport() {
|
||||
}
|
||||
|
||||
static void permitAll(HttpSecurityBuilder<? extends HttpSecurityBuilder<?>> http, String... urls) {
|
||||
for (String url : urls) {
|
||||
if (url != null) {
|
||||
permitAll(http, new ExactUrlRequestMatcher(url));
|
||||
@ -40,7 +43,7 @@ final class PermitAllSupport {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void permitAll(HttpSecurityBuilder<? extends HttpSecurityBuilder<?>> http,
|
||||
static void permitAll(HttpSecurityBuilder<? extends HttpSecurityBuilder<?>> http,
|
||||
RequestMatcher... requestMatchers) {
|
||||
ExpressionUrlAuthorizationConfigurer<?> configurer = http
|
||||
.getConfigurer(ExpressionUrlAuthorizationConfigurer.class);
|
||||
@ -90,7 +93,4 @@ final class PermitAllSupport {
|
||||
|
||||
}
|
||||
|
||||
private PermitAllSupport() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ public final class OAuth2ResourceServerConfigurer<H extends HttpSecurityBuilder<
|
||||
}
|
||||
}
|
||||
|
||||
public void setBearerTokenResolver(BearerTokenResolver tokenResolver) {
|
||||
void setBearerTokenResolver(BearerTokenResolver tokenResolver) {
|
||||
Assert.notNull(tokenResolver, "resolver cannot be null");
|
||||
this.bearerTokenResolver = tokenResolver;
|
||||
}
|
||||
|
@ -78,17 +78,17 @@ final class ReactiveOAuth2ClientImportSelector implements ImportSelector {
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setClientRegistrationRepository(ReactiveClientRegistrationRepository clientRegistrationRepository) {
|
||||
void setClientRegistrationRepository(ReactiveClientRegistrationRepository clientRegistrationRepository) {
|
||||
this.clientRegistrationRepository = clientRegistrationRepository;
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setAuthorizedClientRepository(ServerOAuth2AuthorizedClientRepository authorizedClientRepository) {
|
||||
void setAuthorizedClientRepository(ServerOAuth2AuthorizedClientRepository authorizedClientRepository) {
|
||||
this.authorizedClientRepository = authorizedClientRepository;
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setAuthorizedClientService(List<ReactiveOAuth2AuthorizedClientService> authorizedClientService) {
|
||||
void setAuthorizedClientService(List<ReactiveOAuth2AuthorizedClientService> authorizedClientService) {
|
||||
if (authorizedClientService.size() == 1) {
|
||||
this.authorizedClientService = authorizedClientService.get(0);
|
||||
}
|
||||
|
@ -89,18 +89,20 @@ class ServerHttpSecurityConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebFluxConfigurer authenticationPrincipalArgumentResolverConfigurer(
|
||||
WebFluxConfigurer authenticationPrincipalArgumentResolverConfigurer(
|
||||
ObjectProvider<AuthenticationPrincipalArgumentResolver> authenticationPrincipalArgumentResolver) {
|
||||
return new WebFluxConfigurer() {
|
||||
|
||||
@Override
|
||||
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
|
||||
configurer.addCustomResolver(authenticationPrincipalArgumentResolver.getObject());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationPrincipalArgumentResolver authenticationPrincipalArgumentResolver() {
|
||||
AuthenticationPrincipalArgumentResolver authenticationPrincipalArgumentResolver() {
|
||||
AuthenticationPrincipalArgumentResolver resolver = new AuthenticationPrincipalArgumentResolver(
|
||||
this.adapterRegistry);
|
||||
if (this.beanFactory != null) {
|
||||
@ -110,7 +112,7 @@ class ServerHttpSecurityConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CurrentSecurityContextArgumentResolver reactiveCurrentSecurityContextArgumentResolver() {
|
||||
CurrentSecurityContextArgumentResolver reactiveCurrentSecurityContextArgumentResolver() {
|
||||
CurrentSecurityContextArgumentResolver resolver = new CurrentSecurityContextArgumentResolver(
|
||||
this.adapterRegistry);
|
||||
if (this.beanFactory != null) {
|
||||
@ -121,7 +123,7 @@ class ServerHttpSecurityConfiguration {
|
||||
|
||||
@Bean(HTTPSECURITY_BEAN_NAME)
|
||||
@Scope("prototype")
|
||||
public ServerHttpSecurity httpSecurity() {
|
||||
ServerHttpSecurity httpSecurity() {
|
||||
ContextAwareServerHttpSecurity http = new ContextAwareServerHttpSecurity();
|
||||
return http.authenticationManager(authenticationManager()).headers().and().logout().and();
|
||||
}
|
||||
|
@ -65,17 +65,17 @@ class WebFluxSecurityConfiguration {
|
||||
|
||||
@Bean(SPRING_SECURITY_WEBFILTERCHAINFILTER_BEAN_NAME)
|
||||
@Order(WEB_FILTER_CHAIN_FILTER_ORDER)
|
||||
public WebFilterChainProxy springSecurityWebFilterChainFilter() {
|
||||
WebFilterChainProxy springSecurityWebFilterChainFilter() {
|
||||
return new WebFilterChainProxy(getSecurityWebFilterChains());
|
||||
}
|
||||
|
||||
@Bean(name = AbstractView.REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME)
|
||||
public CsrfRequestDataValueProcessor requestDataValueProcessor() {
|
||||
CsrfRequestDataValueProcessor requestDataValueProcessor() {
|
||||
return new CsrfRequestDataValueProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static BeanFactoryPostProcessor conversionServicePostProcessor() {
|
||||
static BeanFactoryPostProcessor conversionServicePostProcessor() {
|
||||
return new RsaKeyConversionServicePostProcessor();
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
|
||||
* cannot determine if it should be on or off).
|
||||
* @return
|
||||
*/
|
||||
public boolean isEraseCredentialsAfterAuthentication() {
|
||||
boolean isEraseCredentialsAfterAuthentication() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
public Map<String, String> getLoginLinks() {
|
||||
Map<String, String> getLoginLinks() {
|
||||
Iterable<ClientRegistration> clientRegistrations = null;
|
||||
ClientRegistrationRepository clientRegistrationRepository = this.context
|
||||
.getBean(ClientRegistrationRepository.class);
|
||||
|
@ -27,17 +27,18 @@ import org.springframework.util.StringUtils;
|
||||
* @author Luke Taylor
|
||||
* @author Ben Alex
|
||||
*/
|
||||
abstract class WebConfigUtils {
|
||||
final class WebConfigUtils {
|
||||
|
||||
public static int countNonEmpty(String[] objects) {
|
||||
private WebConfigUtils() {
|
||||
}
|
||||
|
||||
static int countNonEmpty(String[] objects) {
|
||||
int nonNulls = 0;
|
||||
|
||||
for (String object : objects) {
|
||||
if (StringUtils.hasText(object)) {
|
||||
nonNulls++;
|
||||
}
|
||||
}
|
||||
|
||||
return nonNulls;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Luke Taylor
|
||||
* @since 3.0
|
||||
*/
|
||||
class ContextSourceSettingPostProcessor implements BeanFactoryPostProcessor, Ordered {
|
||||
public class ContextSourceSettingPostProcessor implements BeanFactoryPostProcessor, Ordered {
|
||||
|
||||
private static final String REQUIRED_CONTEXT_SOURCE_CLASS_NAME = "org.springframework.ldap.core.support.BaseLdapPathContextSource";
|
||||
|
||||
@ -45,6 +45,9 @@ class ContextSourceSettingPostProcessor implements BeanFactoryPostProcessor, Ord
|
||||
*/
|
||||
private boolean defaultNameRequired;
|
||||
|
||||
ContextSourceSettingPostProcessor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory bf) throws BeansException {
|
||||
Class<?> contextSourceClass;
|
||||
|
@ -514,7 +514,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
|
||||
private Jsr250MethodSecurityMetadataSource source = new Jsr250MethodSecurityMetadataSource();
|
||||
|
||||
public Jsr250MethodSecurityMetadataSource getBean() {
|
||||
Jsr250MethodSecurityMetadataSource getBean() {
|
||||
this.source.setDefaultRolePrefix(this.rolePrefix);
|
||||
return this.source;
|
||||
}
|
||||
@ -525,7 +525,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
|
||||
private DefaultMethodSecurityExpressionHandler handler = new DefaultMethodSecurityExpressionHandler();
|
||||
|
||||
public DefaultMethodSecurityExpressionHandler getBean() {
|
||||
DefaultMethodSecurityExpressionHandler getBean() {
|
||||
this.handler.setDefaultRolePrefix(this.rolePrefix);
|
||||
return this.handler;
|
||||
}
|
||||
|
@ -28,7 +28,10 @@ import org.springframework.security.web.server.util.matcher.ServerWebExchangeMat
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
abstract class AbstractServerWebExchangeMatcherRegistry<T> {
|
||||
public abstract class AbstractServerWebExchangeMatcherRegistry<T> {
|
||||
|
||||
AbstractServerWebExchangeMatcherRegistry() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps any request.
|
||||
|
@ -32,7 +32,7 @@ class ConcereteSecurityConfigurerAdapter extends SecurityConfigurerAdapter<Objec
|
||||
this.list = postProcess(this.list);
|
||||
}
|
||||
|
||||
public ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
this.list = l;
|
||||
return this;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class ObjectPostProcessorTests {
|
||||
|
||||
static class PerformConversion {
|
||||
|
||||
public static List<?> perform(ArrayList<?> l) {
|
||||
static List<?> perform(ArrayList<?> l) {
|
||||
return new ListToLinkedListObjectPostProcessor().postProcess(l);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class SecurityConfigurerAdapterClosureTests {
|
||||
this.list = postProcess(this.list);
|
||||
}
|
||||
|
||||
public ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
this.list = l;
|
||||
return this;
|
||||
}
|
||||
|
@ -235,19 +235,19 @@ public class AuthenticationManagerBuilderTests {
|
||||
Resource users;
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager() throws Exception {
|
||||
AuthenticationManager authenticationManager() throws Exception {
|
||||
return new ProviderManager(Arrays.asList(authenticationProvider()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() throws Exception {
|
||||
AuthenticationProvider authenticationProvider() throws Exception {
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setUserDetailsService(userDetailsService());
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() throws Exception {
|
||||
UserDetailsService userDetailsService() throws Exception {
|
||||
Properties properties = new Properties();
|
||||
properties.load(this.users.getInputStream());
|
||||
return new InMemoryUserDetailsManager(properties);
|
||||
|
@ -81,7 +81,7 @@ public class NamespaceAuthenticationManagerTests {
|
||||
static class EraseCredentialsTrueDefaultConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -110,7 +110,7 @@ public class NamespaceAuthenticationManagerTests {
|
||||
static class GlobalEraseCredentialsFalseConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.eraseCredentials(false)
|
||||
|
@ -73,7 +73,7 @@ public class NamespaceAuthenticationProviderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DaoAuthenticationProvider authenticationProvider() {
|
||||
DaoAuthenticationProvider authenticationProvider() {
|
||||
DaoAuthenticationProvider result = new DaoAuthenticationProvider();
|
||||
result.setUserDetailsService(new InMemoryUserDetailsManager(PasswordEncodedUser.user()));
|
||||
return result;
|
||||
|
@ -87,7 +87,7 @@ public class NamespaceJdbcUserServiceTests {
|
||||
static class DataSourceConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
|
||||
return builder.setType(EmbeddedDatabaseType.HSQL).build();
|
||||
}
|
||||
@ -144,7 +144,7 @@ public class NamespaceJdbcUserServiceTests {
|
||||
static class CustomDataSourceConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
|
||||
// simulate that the DB already has the schema loaded and users in it
|
||||
.addScript("CustomJdbcUserServiceSampleConfig.sql");
|
||||
|
@ -104,7 +104,7 @@ public class NamespacePasswordEncoderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
|
||||
return builder.setType(EmbeddedDatabaseType.HSQL).build();
|
||||
}
|
||||
@ -133,7 +133,7 @@ public class NamespacePasswordEncoderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
|
||||
return builder.setType(EmbeddedDatabaseType.HSQL).build();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class PasswordEncoderConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder passwordEncoder() {
|
||||
BCryptPasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class PasswordEncoderConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder passwordEncoder() {
|
||||
BCryptPasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ public class AuthenticationConfigurationTests {
|
||||
AuthenticationManager authenticationManager = mock(AuthenticationManager.class);
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager() {
|
||||
AuthenticationManager authenticationManager() {
|
||||
return this.authenticationManager;
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ public class AuthenticationConfigurationTests {
|
||||
static class ServicesConfig {
|
||||
|
||||
@Bean
|
||||
public Service service() {
|
||||
Service service() {
|
||||
return new ServiceImpl();
|
||||
}
|
||||
|
||||
@ -466,12 +466,12 @@ public class AuthenticationConfigurationTests {
|
||||
static class Sec2531Config {
|
||||
|
||||
@Bean
|
||||
public ObjectPostProcessor objectPostProcessor() {
|
||||
ObjectPostProcessor objectPostProcessor() {
|
||||
return mock(ObjectPostProcessor.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager manager() {
|
||||
AuthenticationManager manager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ public class AuthenticationConfigurationTests {
|
||||
static class Sec2822WebSecurity extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication();
|
||||
}
|
||||
|
||||
@ -498,14 +498,14 @@ public class AuthenticationConfigurationTests {
|
||||
static class Sec2822UseAuth {
|
||||
|
||||
@Autowired
|
||||
public void useAuthenticationManager(AuthenticationConfiguration auth) throws Exception {
|
||||
void useAuthenticationManager(AuthenticationConfiguration auth) throws Exception {
|
||||
auth.getAuthenticationManager();
|
||||
}
|
||||
|
||||
// Ensures that Sec2822UseAuth is initialized before Sec2822WebSecurity
|
||||
// must have additional GlobalAuthenticationConfigurerAdapter to trigger SEC-2822
|
||||
@Bean
|
||||
public static GlobalAuthenticationConfigurerAdapter bootGlobalAuthenticationConfigurerAdapter() {
|
||||
static GlobalAuthenticationConfigurerAdapter bootGlobalAuthenticationConfigurerAdapter() {
|
||||
return new BootGlobalAuthenticationConfigurerAdapter();
|
||||
}
|
||||
|
||||
@ -621,12 +621,12 @@ public class AuthenticationConfigurationTests {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public AuthenticationManager manager1() {
|
||||
AuthenticationManager manager1() {
|
||||
return mock(AuthenticationManager.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager manager2() {
|
||||
AuthenticationManager manager2() {
|
||||
return mock(AuthenticationManager.class);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class EnableGlobalAuthenticationTests {
|
||||
static class Config {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
|
||||
}
|
||||
|
||||
@ -81,12 +81,12 @@ public class EnableGlobalAuthenticationTests {
|
||||
static class BeanProxyEnabledByDefaultConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@ -97,12 +97,12 @@ public class EnableGlobalAuthenticationTests {
|
||||
static class BeanProxyDisabledConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class EnableGlobalAuthenticationTests {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
Child getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
return new AutowireBeanFactoryObjectPostProcessor(beanFactory);
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
||||
SmartInitializingSingleton toTest = mock(SmartInitializingSingleton.class);
|
||||
|
||||
@Autowired
|
||||
public void configure(ObjectPostProcessor<Object> p) {
|
||||
void configure(ObjectPostProcessor<Object> p) {
|
||||
p.postProcess(this.toTest);
|
||||
}
|
||||
|
||||
@ -172,12 +172,12 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
|
||||
static class WithBeanNameAutoProxyCreatorConfig {
|
||||
|
||||
@Bean
|
||||
public ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
ObjectPostProcessor objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
|
||||
return new AutowireBeanFactoryObjectPostProcessor(beanFactory);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configure(ObjectPostProcessor<Object> p) {
|
||||
void configure(ObjectPostProcessor<Object> p) {
|
||||
p.postProcess(new Object());
|
||||
}
|
||||
|
||||
|
@ -470,12 +470,12 @@ public class EnableReactiveMethodSecurityTests {
|
||||
ReactiveMessageService delegate = mock(ReactiveMessageService.class);
|
||||
|
||||
@Bean
|
||||
public DelegatingReactiveMessageService defaultMessageService() {
|
||||
DelegatingReactiveMessageService defaultMessageService() {
|
||||
return new DelegatingReactiveMessageService(this.delegate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Authz authz() {
|
||||
Authz authz() {
|
||||
return new Authz();
|
||||
}
|
||||
|
||||
|
@ -340,12 +340,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class CustomTrustResolverConfig {
|
||||
|
||||
@Bean
|
||||
public AuthenticationTrustResolver trustResolver() {
|
||||
AuthenticationTrustResolver trustResolver() {
|
||||
return mock(AuthenticationTrustResolver.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl service() {
|
||||
MethodSecurityServiceImpl service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@ -355,12 +355,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class ExpressionHandlerHasBeanResolverSetConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl service() {
|
||||
MethodSecurityServiceImpl service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Authz authz() {
|
||||
Authz authz() {
|
||||
return new Authz();
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class MethodSecurityServiceConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@ -380,12 +380,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
public static class AutowirePermissionEvaluatorConfig {
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return mock(PermissionEvaluator.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@ -395,12 +395,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
public static class MultiPermissionEvaluatorConfig {
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return mock(PermissionEvaluator.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator2() {
|
||||
PermissionEvaluator permissionEvaluator2() {
|
||||
return mock(PermissionEvaluator.class);
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class ParentConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec2479ParentConfig {
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager am() {
|
||||
AuthenticationManager am() {
|
||||
return mock(AuthenticationManager.class);
|
||||
}
|
||||
|
||||
@ -435,7 +435,7 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec2479ChildConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@ -445,17 +445,17 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec2815Config {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MockBeanPostProcessor mockBeanPostProcessor() {
|
||||
MockBeanPostProcessor mockBeanPostProcessor() {
|
||||
return new MockBeanPostProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource dataSource() {
|
||||
return mock(DataSource.class);
|
||||
}
|
||||
|
||||
@ -499,12 +499,12 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class Sec3005Config {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService service() {
|
||||
MethodSecurityService service() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication();
|
||||
}
|
||||
|
||||
@ -548,24 +548,24 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class CustomGrantedAuthorityConfig {
|
||||
|
||||
@Bean
|
||||
public GrantedAuthorityDefaults ga() {
|
||||
GrantedAuthorityDefaults ga() {
|
||||
return new GrantedAuthorityDefaults("ROLE:");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomAuthorityService service() {
|
||||
CustomAuthorityService service() {
|
||||
return new CustomAuthorityService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl methodSecurityService() {
|
||||
MethodSecurityServiceImpl methodSecurityService() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
static class CustomAuthorityService {
|
||||
|
||||
@PreAuthorize("hasRole('ROLE:USER')")
|
||||
public void customPrefixRoleUser() {
|
||||
void customPrefixRoleUser() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -576,24 +576,24 @@ public class GlobalMethodSecurityConfigurationTests {
|
||||
static class EmptyRolePrefixGrantedAuthorityConfig {
|
||||
|
||||
@Bean
|
||||
public GrantedAuthorityDefaults ga() {
|
||||
GrantedAuthorityDefaults ga() {
|
||||
return new GrantedAuthorityDefaults("");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomAuthorityService service() {
|
||||
CustomAuthorityService service() {
|
||||
return new CustomAuthorityService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityServiceImpl methodSecurityService() {
|
||||
MethodSecurityServiceImpl methodSecurityService() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
static class CustomAuthorityService {
|
||||
|
||||
@Secured("USER")
|
||||
public void emptyPrefixRoleUser() {
|
||||
void emptyPrefixRoleUser() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class ReactiveMethodSecurityConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
private static class Foo {
|
||||
static class Foo {
|
||||
|
||||
public void bar(String param) {
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class SampleEnableGlobalMethodSecurityTests {
|
||||
static class SampleWebSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public MethodSecurityService methodSecurityService() {
|
||||
MethodSecurityService methodSecurityService() {
|
||||
return new MethodSecurityServiceImpl();
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class Sec2758Tests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Service service() {
|
||||
Service service() {
|
||||
return new Service();
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ public class Sec2758Tests {
|
||||
static class RootController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String ok() {
|
||||
String ok() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@ -123,11 +123,11 @@ public class Sec2758Tests {
|
||||
static class Service {
|
||||
|
||||
@PreAuthorize("hasRole('CUSTOM')")
|
||||
public void doPreAuthorize() {
|
||||
void doPreAuthorize() {
|
||||
}
|
||||
|
||||
@RolesAllowed("CUSTOM")
|
||||
public void doJsr250() {
|
||||
void doJsr250() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
static class InMemoryConfigureGlobalConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -308,7 +308,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
private ContentNegotiationStrategy contentNegotiationStrategySharedObject;
|
||||
|
||||
@Bean
|
||||
public ContentNegotiationStrategy contentNegotiationStrategy() {
|
||||
ContentNegotiationStrategy contentNegotiationStrategy() {
|
||||
return CONTENT_NEGOTIATION_STRATEGY_BEAN;
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
static class RequiresUserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public MyFilter myFilter(UserDetailsService userDetailsService) {
|
||||
MyFilter myFilter(UserDetailsService userDetailsService) {
|
||||
return new MyFilter(userDetailsService);
|
||||
}
|
||||
|
||||
@ -408,7 +408,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
private AuthenticationTrustResolver authenticationTrustResolverSharedObject;
|
||||
|
||||
@Bean
|
||||
public AuthenticationTrustResolver authenticationTrustResolver() {
|
||||
AuthenticationTrustResolver authenticationTrustResolver() {
|
||||
return AUTHENTICATION_TRUST_RESOLVER_BEAN;
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ public class WebSecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationEventPublisher authenticationEventPublisher() {
|
||||
AuthenticationEventPublisher authenticationEventPublisher() {
|
||||
return mock(AuthenticationEventPublisher.class);
|
||||
}
|
||||
|
||||
|
@ -613,7 +613,7 @@ public class NamespaceHttpTests {
|
||||
static Class<? extends HttpServletRequest> HTTP_SERVLET_REQUEST_TYPE;
|
||||
|
||||
@GetMapping("/")
|
||||
public String index(HttpServletRequest request) {
|
||||
String index(HttpServletRequest request) {
|
||||
HTTP_SERVLET_REQUEST_TYPE = request.getClass();
|
||||
return "index";
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class WebSecurityTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ public class WebSecurityTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
@ -192,12 +192,12 @@ public class EnableWebSecurityTests {
|
||||
static class BeanProxyEnabledByDefaultConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@ -208,12 +208,12 @@ public class EnableWebSecurityTests {
|
||||
static class BeanProxyDisabledConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ public class EnableWebSecurityTests {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
Child getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class NameController {
|
||||
|
||||
@GetMapping("/name")
|
||||
public Callable<String> name() {
|
||||
Callable<String> name() {
|
||||
return () -> SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class DefaultWithFilterChainConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class AuthorizeRequestsConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
return http.authorizeRequests((authorize) -> authorize.anyRequest().permitAll()).build();
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class SecurityEnabledConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
return http.authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
.formLogin(withDefaults()).build();
|
||||
}
|
||||
@ -209,7 +209,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class UserDetailsConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER")
|
||||
.build();
|
||||
return new InMemoryUserDetailsManager(user);
|
||||
@ -221,7 +221,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class BaseController {
|
||||
|
||||
@GetMapping("/")
|
||||
public void index() {
|
||||
void index() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -230,7 +230,7 @@ public class HttpSecurityConfigurationTests {
|
||||
static class UserController {
|
||||
|
||||
@GetMapping("/user")
|
||||
public void user(HttpServletRequest request) {
|
||||
void user(HttpServletRequest request) {
|
||||
if (!request.isUserInRole("USER")) {
|
||||
throw new AccessDeniedException("This resource is only available to users");
|
||||
}
|
||||
|
@ -217,25 +217,25 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return CLIENT_REGISTRATION_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return AUTHORIZED_CLIENT_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
return ACCESS_TOKEN_RESPONSE_CLIENT;
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class Controller {
|
||||
class Controller {
|
||||
|
||||
@GetMapping("/authorized-client")
|
||||
public String authorizedClient(
|
||||
String authorizedClient(
|
||||
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
||||
}
|
||||
@ -260,22 +260,22 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository1() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository1() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository2() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository2() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@ -314,22 +314,22 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository1() {
|
||||
ClientRegistrationRepository clientRegistrationRepository1() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository2() {
|
||||
ClientRegistrationRepository clientRegistrationRepository2() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@ -351,22 +351,22 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return mock(ClientRegistrationRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return mock(OAuth2AuthorizedClientRepository.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient1() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient1() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient2() {
|
||||
OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> accessTokenResponseClient2() {
|
||||
return mock(OAuth2AccessTokenResponseClient.class);
|
||||
}
|
||||
|
||||
@ -385,25 +385,25 @@ public class OAuth2ClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return CLIENT_REGISTRATION_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return AUTHORIZED_CLIENT_REPOSITORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientManager authorizedClientManager() {
|
||||
OAuth2AuthorizedClientManager authorizedClientManager() {
|
||||
return AUTHORIZED_CLIENT_MANAGER;
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class Controller {
|
||||
class Controller {
|
||||
|
||||
@GetMapping("/authorized-client")
|
||||
public String authorizedClient(
|
||||
String authorizedClient(
|
||||
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class SecurityReactorContextConfigurationResourceServerTests {
|
||||
}
|
||||
|
||||
@GetMapping("/token")
|
||||
public String token() {
|
||||
String token() {
|
||||
return this.rest.get().uri(this.uri).retrieve().bodyToMono(String.class)
|
||||
.flatMap((result) -> this.rest.get().uri(this.uri).retrieve().bodyToMono(String.class)).block();
|
||||
}
|
||||
|
@ -106,18 +106,18 @@ public class WebMvcSecurityConfigurationTests {
|
||||
static class TestController {
|
||||
|
||||
@RequestMapping("/authentication-principal")
|
||||
public ModelAndView authenticationPrincipal(@AuthenticationPrincipal String principal) {
|
||||
ModelAndView authenticationPrincipal(@AuthenticationPrincipal String principal) {
|
||||
return new ModelAndView("authentication-principal-view", "result", principal);
|
||||
}
|
||||
|
||||
@RequestMapping("/deprecated-authentication-principal")
|
||||
public ModelAndView deprecatedAuthenticationPrincipal(
|
||||
ModelAndView deprecatedAuthenticationPrincipal(
|
||||
@org.springframework.security.web.bind.annotation.AuthenticationPrincipal String principal) {
|
||||
return new ModelAndView("deprecated-authentication-principal-view", "result", principal);
|
||||
}
|
||||
|
||||
@RequestMapping("/csrf")
|
||||
public ModelAndView csrf(CsrfToken token) {
|
||||
ModelAndView csrf(CsrfToken token) {
|
||||
return new ModelAndView("view", "result", token);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class WebMvcSecurityConfigurationTests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public TestController testController() {
|
||||
TestController testController() {
|
||||
return new TestController();
|
||||
}
|
||||
|
||||
|
@ -516,7 +516,7 @@ public class WebSecurityConfigurationTests {
|
||||
};
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return PERMIT_ALL_PERMISSION_EVALUATOR;
|
||||
}
|
||||
|
||||
@ -564,10 +564,10 @@ public class WebSecurityConfigurationTests {
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class HomeController {
|
||||
class HomeController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String home() {
|
||||
String home() {
|
||||
return "home";
|
||||
}
|
||||
|
||||
@ -591,7 +591,7 @@ public class WebSecurityConfigurationTests {
|
||||
static class ParentConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication();
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ public class AuthorizeRequestsTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RoleHierarchy roleHiearchy() {
|
||||
RoleHierarchy roleHiearchy() {
|
||||
RoleHierarchyImpl result = new RoleHierarchyImpl();
|
||||
result.setHierarchy("ROLE_USER > ROLE_ADMIN");
|
||||
return result;
|
||||
@ -515,7 +515,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -552,7 +552,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -587,7 +587,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -624,7 +624,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -696,7 +696,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -731,7 +731,7 @@ public class AuthorizeRequestsTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class CsrfConfigurerNoWebMvcTests {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public RequestDataValueProcessor requestDataValueProcessor() {
|
||||
RequestDataValueProcessor requestDataValueProcessor() {
|
||||
return mock(RequestDataValueProcessor.class);
|
||||
}
|
||||
|
||||
|
@ -738,11 +738,11 @@ public class CsrfConfigurerTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public void rootGet() {
|
||||
void rootGet() {
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public void rootPost() {
|
||||
void rootPost() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class DefaultFiltersTests {
|
||||
static class FilterChainProxyBuilderMissingConfig {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -153,7 +153,7 @@ public class DefaultFiltersTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(PasswordEncodedUser.user(), PasswordEncodedUser.admin());
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ public class ExceptionHandlingConfigurerTests {
|
||||
static class DefaultSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsManager() {
|
||||
InMemoryUserDetailsManager userDetailsManager() {
|
||||
// @formatter:off
|
||||
return new InMemoryUserDetailsManager(User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
@ -310,7 +310,7 @@ public class ExceptionHandlingConfigurerTests {
|
||||
static ContentNegotiationStrategy CNS = mock(ContentNegotiationStrategy.class);
|
||||
|
||||
@Bean
|
||||
public static ContentNegotiationStrategy cns() {
|
||||
static ContentNegotiationStrategy cns() {
|
||||
return CNS;
|
||||
}
|
||||
|
||||
|
@ -805,7 +805,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationListener<AuthorizedEvent> applicationListener() {
|
||||
ApplicationListener<AuthorizedEvent> applicationListener() {
|
||||
return AL;
|
||||
}
|
||||
|
||||
@ -827,7 +827,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Checker permission() {
|
||||
Checker permission() {
|
||||
return new Checker();
|
||||
}
|
||||
|
||||
@ -858,7 +858,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CustomExpressionHandler expressionHandler() {
|
||||
CustomExpressionHandler expressionHandler() {
|
||||
return new CustomExpressionHandler();
|
||||
}
|
||||
|
||||
@ -937,8 +937,9 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PermissionEvaluator permissionEvaluator() {
|
||||
PermissionEvaluator permissionEvaluator() {
|
||||
return new PermissionEvaluator() {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Authentication authentication, Object targetDomainObject,
|
||||
Object permission) {
|
||||
@ -950,6 +951,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
Object permission) {
|
||||
return "ID".equals(targetId) && "TYPE".equals(targetType) && "PERMISSION".equals(permission);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@ -970,7 +972,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RoleHierarchy roleHierarchy() {
|
||||
RoleHierarchy roleHierarchy() {
|
||||
RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl();
|
||||
roleHierarchy.setHierarchy("ROLE_USER > ROLE_MEMBER");
|
||||
return roleHierarchy;
|
||||
@ -982,11 +984,11 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public void rootGet() {
|
||||
void rootGet() {
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public void rootPost() {
|
||||
void rootPost() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -995,7 +997,7 @@ public class ExpressionUrlAuthorizationConfigurerTests {
|
||||
static class WildcardController {
|
||||
|
||||
@GetMapping("/{path}")
|
||||
public void wildcard(@PathVariable String path) {
|
||||
void wildcard(@PathVariable String path) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class NamespaceHttpBasicTests {
|
||||
static class UserConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
|
@ -192,15 +192,9 @@ public class NamespaceHttpCustomFilterTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build());
|
||||
// @formatter:on
|
||||
User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class NamespaceHttpFormLoginTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
|
@ -152,27 +152,27 @@ public class NamespaceHttpInterceptUrlTests {
|
||||
static class BaseController {
|
||||
|
||||
@GetMapping("/users")
|
||||
public String users() {
|
||||
String users() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/sessions")
|
||||
public String sessions() {
|
||||
String sessions() {
|
||||
return "sessions";
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/post")
|
||||
public String adminPost() {
|
||||
String adminPost() {
|
||||
return "adminPost";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/another-post")
|
||||
public String adminAnotherPost() {
|
||||
String adminAnotherPost() {
|
||||
return "adminAnotherPost";
|
||||
}
|
||||
|
||||
@GetMapping("/signup")
|
||||
public String signup() {
|
||||
String signup() {
|
||||
return "signup";
|
||||
}
|
||||
|
||||
|
@ -147,12 +147,12 @@ public class NamespaceHttpJeeTests {
|
||||
static class BaseController {
|
||||
|
||||
@GetMapping("/authenticated")
|
||||
public String authenticated(Authentication authentication) {
|
||||
String authenticated(Authentication authentication) {
|
||||
return authentication.getName();
|
||||
}
|
||||
|
||||
@GetMapping("/roles")
|
||||
public String roles(Authentication authentication) {
|
||||
String roles(Authentication authentication) {
|
||||
return authentication.getAuthorities().stream().map(Object::toString).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
|
@ -293,15 +293,9 @@ public class NamespaceHttpOpenIDLoginTests {
|
||||
static class UserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return new InMemoryUserDetailsManager(
|
||||
// @formatter:off
|
||||
User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build());
|
||||
// @formatter:on
|
||||
User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class NamespaceHttpRequestCacheTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RequestCache requestCache() {
|
||||
RequestCache requestCache() {
|
||||
return mock(RequestCache.class);
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ public class NamespaceSessionManagementTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MockEventListener eventListener() {
|
||||
MockEventListener eventListener() {
|
||||
return spy(new MockEventListener());
|
||||
}
|
||||
|
||||
@ -425,12 +425,12 @@ public class NamespaceSessionManagementTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String ok() {
|
||||
String ok() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/auth")
|
||||
public String auth(Principal principal) {
|
||||
String auth(Principal principal) {
|
||||
return principal.getName();
|
||||
}
|
||||
|
||||
@ -444,17 +444,17 @@ public class NamespaceSessionManagementTests {
|
||||
|
||||
private Boolean exists = true;
|
||||
|
||||
public ResultMatcher exists(boolean exists) {
|
||||
ResultMatcher exists(boolean exists) {
|
||||
this.exists = exists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultMatcher valid(boolean valid) {
|
||||
ResultMatcher valid(boolean valid) {
|
||||
this.valid = valid;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
||||
public ResultMatcher id(String id) {
|
||||
ResultMatcher id(String id) {
|
||||
this.id = id;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -344,7 +344,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -372,7 +372,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -402,7 +402,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -434,7 +434,7 @@ public class RememberMeConfigurerTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
|
@ -387,7 +387,7 @@ public class RequestCacheConfigurerTests {
|
||||
static class DefaultSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsManager() {
|
||||
InMemoryUserDetailsManager userDetailsManager() {
|
||||
// @formatter:off
|
||||
return new InMemoryUserDetailsManager(User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
|
@ -256,7 +256,7 @@ public class ServletApiConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager customAuthenticationManager() throws Exception {
|
||||
AuthenticationManager customAuthenticationManager() throws Exception {
|
||||
return super.authenticationManagerBean();
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ public class ServletApiConfigurerTests {
|
||||
static class AdminController {
|
||||
|
||||
@GetMapping("/admin")
|
||||
public void admin(HttpServletRequest request) {
|
||||
void admin(HttpServletRequest request) {
|
||||
if (!request.isUserInRole("ADMIN")) {
|
||||
throw new AccessDeniedException("This resource is only available to admins");
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class SessionManagementConfigurerSessionCreationPolicyTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String root() {
|
||||
String root() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ public class SessionManagementConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionRegistry sessionRegistry() {
|
||||
SessionRegistry sessionRegistry() {
|
||||
return SESSION_REGISTRY;
|
||||
}
|
||||
|
||||
@ -538,12 +538,12 @@ public class SessionManagementConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionRegistry sessionRegistryOne() {
|
||||
SessionRegistry sessionRegistryOne() {
|
||||
return SESSION_REGISTRY_ONE;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionRegistry sessionRegistryTwo() {
|
||||
SessionRegistry sessionRegistryTwo() {
|
||||
return SESSION_REGISTRY_TWO;
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class UrlAuthorizationConfigurerTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ public class UrlAuthorizationConfigurerTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
|
@ -265,20 +265,20 @@ public class OAuth2ClientConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return clientRegistrationRepository;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return authorizedClientRepository;
|
||||
}
|
||||
|
||||
@RestController
|
||||
public class ResourceController {
|
||||
class ResourceController {
|
||||
|
||||
@GetMapping("/resource1")
|
||||
public String resource1(
|
||||
String resource1(
|
||||
@RegisteredOAuth2AuthorizedClient("registration-1") OAuth2AuthorizedClient authorizedClient) {
|
||||
return "resource1";
|
||||
}
|
||||
@ -304,12 +304,12 @@ public class OAuth2ClientConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientRegistrationRepository clientRegistrationRepository() {
|
||||
ClientRegistrationRepository clientRegistrationRepository() {
|
||||
return clientRegistrationRepository;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
OAuth2AuthorizedClientRepository authorizedClientRepository() {
|
||||
return authorizedClientRepository;
|
||||
}
|
||||
|
||||
|
@ -1907,7 +1907,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JwtDecoder decoder() {
|
||||
JwtDecoder decoder() {
|
||||
return mock(JwtDecoder.class);
|
||||
}
|
||||
|
||||
@ -1930,7 +1930,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
AuthenticationProvider authenticationProvider() {
|
||||
return mock(AuthenticationProvider.class);
|
||||
}
|
||||
|
||||
@ -1955,7 +1955,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
public OAuth2TokenValidator<Jwt> getJwtValidator() {
|
||||
OAuth2TokenValidator<Jwt> getJwtValidator() {
|
||||
return this.jwtValidator;
|
||||
}
|
||||
|
||||
@ -2122,7 +2122,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
AuthenticationProvider authenticationProvider() {
|
||||
return mock(AuthenticationProvider.class);
|
||||
}
|
||||
|
||||
@ -2150,7 +2150,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
AuthenticationProvider authenticationProvider() {
|
||||
return mock(AuthenticationProvider.class);
|
||||
}
|
||||
|
||||
@ -2234,7 +2234,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
static class JwtDecoderConfig {
|
||||
|
||||
@Bean
|
||||
public JwtDecoder jwtDecoder() {
|
||||
JwtDecoder jwtDecoder() {
|
||||
return mock(JwtDecoder.class);
|
||||
}
|
||||
|
||||
@ -2244,35 +2244,35 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String get() {
|
||||
String get() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@PostMapping("/post")
|
||||
public String post() {
|
||||
String post() {
|
||||
return "post";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/authenticated", method = { RequestMethod.GET, RequestMethod.POST })
|
||||
public String authenticated(Authentication authentication) {
|
||||
String authenticated(Authentication authentication) {
|
||||
return authentication.getName();
|
||||
}
|
||||
|
||||
@GetMapping("/requires-read-scope")
|
||||
public String requiresReadScope(JwtAuthenticationToken token) {
|
||||
String requiresReadScope(JwtAuthenticationToken token) {
|
||||
return token.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@GetMapping("/ms-requires-read-scope")
|
||||
@PreAuthorize("hasAuthority('SCOPE_message:read')")
|
||||
public String msRequiresReadScope(JwtAuthenticationToken token) {
|
||||
String msRequiresReadScope(JwtAuthenticationToken token) {
|
||||
return requiresReadScope(token);
|
||||
}
|
||||
|
||||
@GetMapping("/ms-deny")
|
||||
@PreAuthorize("denyAll")
|
||||
public String deny() {
|
||||
String deny() {
|
||||
return "hmm, that's odd";
|
||||
}
|
||||
|
||||
@ -2284,7 +2284,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
private final MockWebServer server = new MockWebServer();
|
||||
|
||||
@PreDestroy
|
||||
public void shutdown() throws IOException {
|
||||
void shutdown() throws IOException {
|
||||
this.server.shutdown();
|
||||
}
|
||||
|
||||
@ -2297,7 +2297,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MockWebServer web() {
|
||||
MockWebServer web() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
@ -2354,7 +2354,7 @@ public class OAuth2ResourceServerConfigurerTests {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public BearerTokenRequestPostProcessor asParam() {
|
||||
BearerTokenRequestPostProcessor asParam() {
|
||||
this.asRequestParameter = true;
|
||||
return this;
|
||||
}
|
||||
|
@ -270,13 +270,13 @@ public class EnableWebFluxSecurityTests {
|
||||
static class CustomPasswordEncoderConfig {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsService userDetailsService(PasswordEncoder encoder) {
|
||||
ReactiveUserDetailsService userDetailsService(PasswordEncoder encoder) {
|
||||
return new MapReactiveUserDetailsService(
|
||||
User.withUsername("user").password(encoder.encode("password")).roles("USER").build());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PasswordEncoder passwordEncoder() {
|
||||
static PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ public class EnableWebFluxSecurityTests {
|
||||
static class MapReactiveUserDetailsServiceConfig {
|
||||
|
||||
@Bean
|
||||
public MapReactiveUserDetailsService userDetailsService() {
|
||||
MapReactiveUserDetailsService userDetailsService() {
|
||||
// @formatter:off
|
||||
return new MapReactiveUserDetailsService(User.withUsername("user")
|
||||
.password("{noop}password")
|
||||
@ -304,14 +304,14 @@ public class EnableWebFluxSecurityTests {
|
||||
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
@Bean
|
||||
public SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
||||
http.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**")).authorizeExchange()
|
||||
.anyExchange().denyAll();
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain httpSecurity(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain httpSecurity(ServerHttpSecurity http) {
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ public class EnableWebFluxSecurityTests {
|
||||
static class AuthenticationPrincipalConfig {
|
||||
|
||||
@Bean
|
||||
public PrincipalBean principalBean() {
|
||||
PrincipalBean principalBean() {
|
||||
return new PrincipalBean();
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ public class EnableWebFluxSecurityTests {
|
||||
}
|
||||
|
||||
@RestController
|
||||
public static class AuthenticationPrincipalResolver {
|
||||
static class AuthenticationPrincipalResolver {
|
||||
|
||||
@GetMapping("/spel")
|
||||
String username(@AuthenticationPrincipal(expression = "@principalBean.username(#this)") String username) {
|
||||
@ -352,12 +352,12 @@ public class EnableWebFluxSecurityTests {
|
||||
static class BeanProxyEnabledByDefaultConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@ -369,12 +369,12 @@ public class EnableWebFluxSecurityTests {
|
||||
static class BeanProxyDisabledConfig {
|
||||
|
||||
@Bean
|
||||
public Child child() {
|
||||
Child child() {
|
||||
return new Child();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Parent parent() {
|
||||
Parent parent() {
|
||||
return new Parent(child());
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ public class EnableWebFluxSecurityTests {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
Child getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
|
||||
static class MyController {
|
||||
|
||||
@MessageMapping("/authentication")
|
||||
public void authentication(@AuthenticationPrincipal String un) {
|
||||
void authentication(@AuthenticationPrincipal String un) {
|
||||
// ... do something ...
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MyController myController() {
|
||||
MyController myController() {
|
||||
return new MyController();
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
|
||||
static class SyncExecutorConfig {
|
||||
|
||||
@Bean
|
||||
public static SyncExecutorSubscribableChannelPostProcessor postProcessor() {
|
||||
static SyncExecutorSubscribableChannelPostProcessor postProcessor() {
|
||||
return new SyncExecutorSubscribableChannelPostProcessor();
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestHandshakeHandler testHandshakeHandler() {
|
||||
TestHandshakeHandler testHandshakeHandler() {
|
||||
return new TestHandshakeHandler();
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestHandshakeHandler testHandshakeHandler() {
|
||||
TestHandshakeHandler testHandshakeHandler() {
|
||||
return new TestHandshakeHandler();
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestHandshakeHandler testHandshakeHandler() {
|
||||
TestHandshakeHandler testHandshakeHandler() {
|
||||
return new TestHandshakeHandler();
|
||||
}
|
||||
|
||||
@ -545,18 +545,22 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
|
||||
// @formatter:on
|
||||
|
||||
@Bean
|
||||
public static SecurityExpressionHandler<Message<Object>> messageSecurityExpressionHandler() {
|
||||
static SecurityExpressionHandler<Message<Object>> messageSecurityExpressionHandler() {
|
||||
return new DefaultMessageSecurityExpressionHandler<Object>() {
|
||||
|
||||
@Override
|
||||
protected SecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication,
|
||||
Message<Object> invocation) {
|
||||
return new MessageSecurityExpressionRoot(authentication, invocation) {
|
||||
|
||||
public boolean denyRob() {
|
||||
Authentication auth = getAuthentication();
|
||||
return auth != null && !"rob".equals(auth.getName());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class AuthenticationConfigurationGh3935Tests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetailsService userDetailsService() {
|
||||
return mock(UserDetailsService.class);
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ public class GrantedAuthorityDefaultsJcTests {
|
||||
static class Config extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// @formatter:off
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
@ -184,12 +184,12 @@ public class GrantedAuthorityDefaultsJcTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageService messageService() {
|
||||
MessageService messageService() {
|
||||
return new HelloWorldMessageService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static GrantedAuthorityDefaults grantedAuthorityDefaults() {
|
||||
static GrantedAuthorityDefaults grantedAuthorityDefaults() {
|
||||
return new GrantedAuthorityDefaults("");
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBeanPropertiesResourceITes
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
return ReactiveUserDetailsServiceResourceFactoryBean
|
||||
.fromResource(new InMemoryResource("user=password,ROLE_USER"));
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBeanPropertiesResourceLoca
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
return ReactiveUserDetailsServiceResourceFactoryBean.fromResourceLocation("classpath:users.properties");
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBeanStringITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
ReactiveUserDetailsServiceResourceFactoryBean userDetailsService() {
|
||||
return ReactiveUserDetailsServiceResourceFactoryBean.fromString("user=password,ROLE_USER");
|
||||
}
|
||||
|
||||
|
@ -228,12 +228,12 @@ public class InterceptUrlConfigTests {
|
||||
static class PathController {
|
||||
|
||||
@RequestMapping("/path")
|
||||
public String path() {
|
||||
String path() {
|
||||
return "path";
|
||||
}
|
||||
|
||||
@RequestMapping("/path/{un}/path")
|
||||
public String path(@PathVariable("un") String name) {
|
||||
String path(@PathVariable("un") String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -751,12 +751,12 @@ public class MiscHttpConfigTests {
|
||||
static class BasicController {
|
||||
|
||||
@RequestMapping("/unprotected")
|
||||
public String unprotected() {
|
||||
String unprotected() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@RequestMapping("/protected")
|
||||
public String protectedMethod(@AuthenticationPrincipal String name) {
|
||||
String protectedMethod(@AuthenticationPrincipal String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -766,7 +766,7 @@ public class MiscHttpConfigTests {
|
||||
static class CustomKeyController {
|
||||
|
||||
@GetMapping("/customKey")
|
||||
public String customKey() {
|
||||
String customKey() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
if (authentication != null && authentication instanceof AnonymousAuthenticationToken) {
|
||||
@ -782,18 +782,18 @@ public class MiscHttpConfigTests {
|
||||
static class AuthenticationController {
|
||||
|
||||
@GetMapping("/password")
|
||||
public String password(@AuthenticationPrincipal Authentication authentication) {
|
||||
String password(@AuthenticationPrincipal Authentication authentication) {
|
||||
return (String) authentication.getCredentials();
|
||||
}
|
||||
|
||||
@GetMapping("/roles")
|
||||
public String roles(@AuthenticationPrincipal Authentication authentication) {
|
||||
String roles(@AuthenticationPrincipal Authentication authentication) {
|
||||
return authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
public String details(@AuthenticationPrincipal Authentication authentication) {
|
||||
String details(@AuthenticationPrincipal Authentication authentication) {
|
||||
return authentication.getDetails().getClass().getName();
|
||||
}
|
||||
|
||||
@ -803,7 +803,7 @@ public class MiscHttpConfigTests {
|
||||
static class JaasController {
|
||||
|
||||
@GetMapping("/username")
|
||||
public String username() {
|
||||
String username() {
|
||||
Subject subject = Subject.getSubject(AccessController.getContext());
|
||||
return subject.getPrincipals().iterator().next().getName();
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class MultiHttpBlockConfigTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/first")
|
||||
public String first() {
|
||||
String first() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ public class OpenIDConfigTests {
|
||||
static class CustomLoginController {
|
||||
|
||||
@GetMapping("/login")
|
||||
public String custom() {
|
||||
String custom() {
|
||||
return "a custom login page";
|
||||
}
|
||||
|
||||
|
@ -534,12 +534,12 @@ public class SessionManagementConfigTests {
|
||||
static class BasicController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String ok() {
|
||||
String ok() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@GetMapping("/auth")
|
||||
public String auth(Principal principal) {
|
||||
String auth(Principal principal) {
|
||||
return principal.getName();
|
||||
}
|
||||
|
||||
@ -553,17 +553,17 @@ public class SessionManagementConfigTests {
|
||||
|
||||
private Boolean exists = true;
|
||||
|
||||
public ResultMatcher exists(boolean exists) {
|
||||
ResultMatcher exists(boolean exists) {
|
||||
this.exists = exists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultMatcher valid(boolean valid) {
|
||||
ResultMatcher valid(boolean valid) {
|
||||
this.valid = valid;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
||||
public ResultMatcher id(String id) {
|
||||
ResultMatcher id(String id) {
|
||||
this.id = id;
|
||||
return this.exists(true);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class CustomHttpSecurityConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
// Typically externalize this as a properties file
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("permitAllPattern", "/public/**");
|
||||
@ -160,7 +160,7 @@ public class CustomHttpSecurityConfigurerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
// Typically externalize this as a properties file
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("permitAllPattern", "/public/**");
|
||||
|
@ -47,7 +47,7 @@ public class UserDetailsManagerResourceFactoryBeanPropertiesResourceITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
return UserDetailsManagerResourceFactoryBean.fromResource(new InMemoryResource("user=password,ROLE_USER"));
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class UserDetailsManagerResourceFactoryBeanPropertiesResourceLocationITes
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
return UserDetailsManagerResourceFactoryBean.fromResourceLocation("classpath:users.properties");
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class UserDetailsManagerResourceFactoryBeanStringITests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
UserDetailsManagerResourceFactoryBean userDetailsService() {
|
||||
return UserDetailsManagerResourceFactoryBean.fromString("user=password,ROLE_USER");
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class HttpsRedirectSpecTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PortMapper portMapper() {
|
||||
PortMapper portMapper() {
|
||||
return mock(PortMapper.class);
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ public class HttpsRedirectSpecTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PortMapper portMapper() {
|
||||
PortMapper portMapper() {
|
||||
return mock(PortMapper.class);
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ public class OAuth2ClientSpecTests {
|
||||
ServerRequestCache requestCache = mock(ServerRequestCache.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.oauth2Client()
|
||||
@ -284,7 +284,7 @@ public class OAuth2ClientSpecTests {
|
||||
ServerRequestCache requestCache = mock(ServerRequestCache.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.oauth2Client((oauth2Client) ->
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user