Always use 'this.' when accessing fields
Apply an Eclipse cleanup rules to ensure that fields are always accessed using `this.`. This aligns with the style used by Spring Framework and helps users quickly see the difference between a local and member variable. Issue gh-8945
This commit is contained in:
@@ -237,8 +237,8 @@ public class LdapAuthenticationProviderBuilderSecurityBuilderTests {
|
||||
}
|
||||
|
||||
private LdapAuthenticationProvider ldapProvider() {
|
||||
return ((List<LdapAuthenticationProvider>) ReflectionTestUtils.getField(authenticationManager, "providers"))
|
||||
.get(0);
|
||||
return ((List<LdapAuthenticationProvider>) ReflectionTestUtils.getField(this.authenticationManager,
|
||||
"providers")).get(0);
|
||||
}
|
||||
|
||||
private LdapAuthoritiesPopulator getAuthoritiesPopulator(LdapAuthenticationProvider provider) {
|
||||
|
||||
@@ -40,19 +40,19 @@ public class LdapProviderBeanDefinitionParserTests {
|
||||
|
||||
@After
|
||||
public void closeAppContext() {
|
||||
if (appCtx != null) {
|
||||
appCtx.close();
|
||||
appCtx = null;
|
||||
if (this.appCtx != null) {
|
||||
this.appCtx.close();
|
||||
this.appCtx = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleProviderAuthenticatesCorrectly() {
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
+ "<authentication-manager>" + " <ldap-authentication-provider group-search-filter='member={0}' />"
|
||||
+ "</authentication-manager>");
|
||||
|
||||
AuthenticationManager authenticationManager = appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager.class);
|
||||
Authentication auth = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken("ben", "benspassword"));
|
||||
@@ -62,12 +62,12 @@ public class LdapProviderBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
public void multipleProvidersAreSupported() {
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
+ "<authentication-manager>" + " <ldap-authentication-provider group-search-filter='member={0}' />"
|
||||
+ " <ldap-authentication-provider group-search-filter='uniqueMember={0}' />"
|
||||
+ "</authentication-manager>");
|
||||
|
||||
ProviderManager providerManager = appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER, ProviderManager.class);
|
||||
ProviderManager providerManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER, ProviderManager.class);
|
||||
assertThat(providerManager.getProviders()).hasSize(2);
|
||||
assertThat(providerManager.getProviders()).extracting("authoritiesPopulator.groupSearchFilter")
|
||||
.containsExactly("member={0}", "uniqueMember={0}");
|
||||
@@ -81,11 +81,11 @@ public class LdapProviderBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
public void supportsPasswordComparisonAuthentication() {
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
+ "<authentication-manager>" + " <ldap-authentication-provider user-dn-pattern='uid={0},ou=people'>"
|
||||
+ " <password-compare />" + " </ldap-authentication-provider>" + "</authentication-manager>");
|
||||
|
||||
AuthenticationManager authenticationManager = appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager.class);
|
||||
Authentication auth = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken("ben", "benspassword"));
|
||||
@@ -95,13 +95,13 @@ public class LdapProviderBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
public void supportsPasswordComparisonAuthenticationWithPasswordEncoder() {
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
+ "<authentication-manager>" + " <ldap-authentication-provider user-dn-pattern='uid={0},ou=people'>"
|
||||
+ " <password-compare password-attribute='uid'>" + " <password-encoder ref='passwordEncoder' />"
|
||||
+ " </password-compare>" + " </ldap-authentication-provider>" + "</authentication-manager>"
|
||||
+ "<b:bean id='passwordEncoder' class='org.springframework.security.crypto.password.NoOpPasswordEncoder' factory-method='getInstance' />");
|
||||
|
||||
AuthenticationManager authenticationManager = appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager.class);
|
||||
Authentication auth = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("ben", "ben"));
|
||||
|
||||
@@ -111,13 +111,13 @@ public class LdapProviderBeanDefinitionParserTests {
|
||||
// SEC-2472
|
||||
@Test
|
||||
public void supportsCryptoPasswordEncoder() {
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
||||
+ "<authentication-manager>" + " <ldap-authentication-provider user-dn-pattern='uid={0},ou=people'>"
|
||||
+ " <password-compare>" + " <password-encoder ref='pe' />" + " </password-compare>"
|
||||
+ " </ldap-authentication-provider>" + "</authentication-manager>"
|
||||
+ "<b:bean id='pe' class='org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' />");
|
||||
|
||||
AuthenticationManager authenticationManager = appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager authenticationManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER,
|
||||
AuthenticationManager.class);
|
||||
Authentication auth = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken("bcrypt", "password"));
|
||||
@@ -127,13 +127,13 @@ public class LdapProviderBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
public void inetOrgContextMapperIsSupported() {
|
||||
appCtx = new InMemoryXmlApplicationContext(
|
||||
this.appCtx = new InMemoryXmlApplicationContext(
|
||||
"<ldap-server url='ldap://127.0.0.1:343/dc=springframework,dc=org' port='0'/>"
|
||||
+ "<authentication-manager>"
|
||||
+ " <ldap-authentication-provider user-details-class='inetOrgPerson' />"
|
||||
+ "</authentication-manager>");
|
||||
|
||||
ProviderManager providerManager = appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER, ProviderManager.class);
|
||||
ProviderManager providerManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER, ProviderManager.class);
|
||||
assertThat(providerManager.getProviders()).hasSize(1);
|
||||
assertThat(providerManager.getProviders()).extracting("userDetailsContextMapper")
|
||||
.allSatisfy(contextMapper -> assertThat(contextMapper).isInstanceOf(InetOrgPersonContextMapper.class));
|
||||
@@ -143,12 +143,12 @@ public class LdapProviderBeanDefinitionParserTests {
|
||||
public void ldapAuthenticationProviderWorksWithPlaceholders() {
|
||||
System.setProperty("udp", "people");
|
||||
System.setProperty("gsf", "member");
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server />" + "<authentication-manager>"
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server />" + "<authentication-manager>"
|
||||
+ " <ldap-authentication-provider user-dn-pattern='uid={0},ou=${udp}' group-search-filter='${gsf}={0}' />"
|
||||
+ "</authentication-manager>"
|
||||
+ "<b:bean id='org.springframework.beans.factory.config.PropertyPlaceholderConfigurer' class='org.springframework.beans.factory.config.PropertyPlaceholderConfigurer' />");
|
||||
|
||||
ProviderManager providerManager = appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER, ProviderManager.class);
|
||||
ProviderManager providerManager = this.appCtx.getBean(BeanIds.AUTHENTICATION_MANAGER, ProviderManager.class);
|
||||
assertThat(providerManager.getProviders()).hasSize(1);
|
||||
|
||||
AuthenticationProvider authenticationProvider = providerManager.getProviders().get(0);
|
||||
|
||||
@@ -40,17 +40,17 @@ public class LdapServerBeanDefinitionParserTests {
|
||||
|
||||
@After
|
||||
public void closeAppContext() {
|
||||
if (appCtx != null) {
|
||||
appCtx.close();
|
||||
appCtx = null;
|
||||
if (this.appCtx != null) {
|
||||
this.appCtx.close();
|
||||
this.appCtx = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void embeddedServerCreationContainsExpectedContextSourceAndData() {
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>");
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>");
|
||||
|
||||
DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) appCtx
|
||||
DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) this.appCtx
|
||||
.getBean(BeanIds.CONTEXT_SOURCE);
|
||||
|
||||
// Check data is loaded
|
||||
@@ -62,14 +62,15 @@ public class LdapServerBeanDefinitionParserTests {
|
||||
public void useOfUrlAttributeCreatesCorrectContextSource() throws Exception {
|
||||
int port = getDefaultPort();
|
||||
// Create second "server" with a url pointing at embedded one
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='" + port
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='" + port
|
||||
+ "'/>" + "<ldap-server ldif='classpath:test-server.ldif' id='blah' url='ldap://127.0.0.1:" + port
|
||||
+ "/dc=springframework,dc=org' />");
|
||||
|
||||
// Check the default context source is still there.
|
||||
appCtx.getBean(BeanIds.CONTEXT_SOURCE);
|
||||
this.appCtx.getBean(BeanIds.CONTEXT_SOURCE);
|
||||
|
||||
DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) appCtx.getBean("blah");
|
||||
DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) this.appCtx
|
||||
.getBean("blah");
|
||||
|
||||
// Check data is loaded as before
|
||||
LdapTemplate template = new LdapTemplate(contextSource);
|
||||
@@ -78,9 +79,9 @@ public class LdapServerBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
public void loadingSpecificLdifFileIsSuccessful() {
|
||||
appCtx = new InMemoryXmlApplicationContext(
|
||||
this.appCtx = new InMemoryXmlApplicationContext(
|
||||
"<ldap-server ldif='classpath*:test-server2.xldif' root='dc=monkeymachine,dc=co,dc=uk' port='0'/>");
|
||||
DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) appCtx
|
||||
DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) this.appCtx
|
||||
.getBean(BeanIds.CONTEXT_SOURCE);
|
||||
|
||||
LdapTemplate template = new LdapTemplate(contextSource);
|
||||
@@ -89,8 +90,8 @@ public class LdapServerBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
public void defaultLdifFileIsSuccessful() {
|
||||
appCtx = new InMemoryXmlApplicationContext("<ldap-server/>");
|
||||
ApacheDSContainer dsContainer = appCtx.getBean(ApacheDSContainer.class);
|
||||
this.appCtx = new InMemoryXmlApplicationContext("<ldap-server/>");
|
||||
ApacheDSContainer dsContainer = this.appCtx.getBean(ApacheDSContainer.class);
|
||||
|
||||
assertThat(ReflectionTestUtils.getField(dsContainer, "ldifResources")).isEqualTo("classpath*:*.ldif");
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
|
||||
@After
|
||||
public void closeAppContext() {
|
||||
if (appCtx != null) {
|
||||
appCtx.close();
|
||||
appCtx = null;
|
||||
if (this.appCtx != null) {
|
||||
this.appCtx.close();
|
||||
this.appCtx = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
setContext(
|
||||
"<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
|
||||
|
||||
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
|
||||
UserDetailsService uds = (UserDetailsService) this.appCtx.getBean("ldapUDS");
|
||||
UserDetails ben = uds.loadUserByUsername("ben");
|
||||
|
||||
Set<String> authorities = AuthorityUtils.authorityListToSet(ben.getAuthorities());
|
||||
@@ -95,7 +95,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
+ " user-search-filter='(cn={0})' "
|
||||
+ " group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
|
||||
|
||||
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
|
||||
UserDetailsService uds = (UserDetailsService) this.appCtx.getBean("ldapUDS");
|
||||
UserDetails joe = uds.loadUserByUsername("Joe Smeth");
|
||||
|
||||
assertThat(joe.getUsername()).isEqualTo("Joe Smeth");
|
||||
@@ -108,11 +108,11 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
+ "<ldap-user-service id='ldapUDSNoPrefix' " + " user-search-filter='(uid={0})' "
|
||||
+ " group-search-filter='member={0}' role-prefix='none'/><ldap-server ldif='classpath:test-server.ldif'/>");
|
||||
|
||||
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
|
||||
UserDetailsService uds = (UserDetailsService) this.appCtx.getBean("ldapUDS");
|
||||
UserDetails ben = uds.loadUserByUsername("ben");
|
||||
assertThat(AuthorityUtils.authorityListToSet(ben.getAuthorities())).contains("PREFIX_DEVELOPERS");
|
||||
|
||||
uds = (UserDetailsService) appCtx.getBean("ldapUDSNoPrefix");
|
||||
uds = (UserDetailsService) this.appCtx.getBean("ldapUDSNoPrefix");
|
||||
ben = uds.loadUserByUsername("ben");
|
||||
assertThat(AuthorityUtils.authorityListToSet(ben.getAuthorities())).contains("DEVELOPERS");
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
setContext(
|
||||
"<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-role-attribute='ou' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
|
||||
|
||||
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
|
||||
UserDetailsService uds = (UserDetailsService) this.appCtx.getBean("ldapUDS");
|
||||
UserDetails ben = uds.loadUserByUsername("ben");
|
||||
|
||||
Set<String> authorities = AuthorityUtils.authorityListToSet(ben.getAuthorities());
|
||||
@@ -144,7 +144,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
public void personContextMapperIsSupported() {
|
||||
setContext("<ldap-server ldif='classpath:test-server.ldif'/>"
|
||||
+ "<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' user-details-class='person'/>");
|
||||
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
|
||||
UserDetailsService uds = (UserDetailsService) this.appCtx.getBean("ldapUDS");
|
||||
UserDetails ben = uds.loadUserByUsername("ben");
|
||||
assertThat(ben instanceof Person).isTrue();
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
public void inetOrgContextMapperIsSupported() {
|
||||
setContext("<ldap-server id='someServer' ldif='classpath:test-server.ldif'/>"
|
||||
+ "<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' user-details-class='inetOrgPerson'/>");
|
||||
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
|
||||
UserDetailsService uds = (UserDetailsService) this.appCtx.getBean("ldapUDS");
|
||||
UserDetails ben = uds.loadUserByUsername("ben");
|
||||
assertThat(ben instanceof InetOrgPerson).isTrue();
|
||||
}
|
||||
@@ -164,13 +164,13 @@ public class LdapUserServiceBeanDefinitionParserTests {
|
||||
+ "<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' user-context-mapper-ref='mapper'/>"
|
||||
+ "<b:bean id='mapper' class='" + InetOrgPersonContextMapper.class.getName() + "'/>");
|
||||
|
||||
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
|
||||
UserDetailsService uds = (UserDetailsService) this.appCtx.getBean("ldapUDS");
|
||||
UserDetails ben = uds.loadUserByUsername("ben");
|
||||
assertThat(ben instanceof InetOrgPerson).isTrue();
|
||||
}
|
||||
|
||||
private void setContext(String context) {
|
||||
appCtx = new InMemoryXmlApplicationContext(context);
|
||||
this.appCtx = new InMemoryXmlApplicationContext(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,15 +78,16 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
|
||||
Package pkg = SpringSecurityCoreVersion.class.getPackage();
|
||||
|
||||
if (pkg == null || coreVersion == null) {
|
||||
logger.info("Couldn't determine package version information.");
|
||||
this.logger.info("Couldn't determine package version information.");
|
||||
return;
|
||||
}
|
||||
|
||||
String version = pkg.getImplementationVersion();
|
||||
logger.info("Spring Security 'config' module version is " + version);
|
||||
this.logger.info("Spring Security 'config' module version is " + version);
|
||||
|
||||
if (version.compareTo(coreVersion) != 0) {
|
||||
logger.error("You are running with different versions of the Spring Security 'core' and 'config' modules");
|
||||
this.logger.error(
|
||||
"You are running with different versions of the Spring Security 'core' and 'config' modules");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
|
||||
element);
|
||||
}
|
||||
String name = pc.getDelegate().getLocalName(element);
|
||||
BeanDefinitionParser parser = parsers.get(name);
|
||||
BeanDefinitionParser parser = this.parsers.get(name);
|
||||
|
||||
if (parser == null) {
|
||||
// SEC-1455. Load parsers when required, not just on init().
|
||||
@@ -126,17 +127,17 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
|
||||
// We only handle elements
|
||||
if (node instanceof Element) {
|
||||
if (Elements.INTERCEPT_METHODS.equals(name)) {
|
||||
return interceptMethodsBDD.decorate(node, definition, pc);
|
||||
return this.interceptMethodsBDD.decorate(node, definition, pc);
|
||||
}
|
||||
|
||||
if (Elements.FILTER_CHAIN_MAP.equals(name)) {
|
||||
if (filterChainMapBDD == null) {
|
||||
if (this.filterChainMapBDD == null) {
|
||||
loadParsers();
|
||||
}
|
||||
if (filterChainMapBDD == null) {
|
||||
if (this.filterChainMapBDD == null) {
|
||||
reportMissingWebClasses(name, pc, node);
|
||||
}
|
||||
return filterChainMapBDD.decorate(node, definition, pc);
|
||||
return this.filterChainMapBDD.decorate(node, definition, pc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,29 +171,32 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
|
||||
|
||||
private void loadParsers() {
|
||||
// Parsers
|
||||
parsers.put(Elements.LDAP_PROVIDER, new LdapProviderBeanDefinitionParser());
|
||||
parsers.put(Elements.LDAP_SERVER, new LdapServerBeanDefinitionParser());
|
||||
parsers.put(Elements.LDAP_USER_SERVICE, new LdapUserServiceBeanDefinitionParser());
|
||||
parsers.put(Elements.USER_SERVICE, new UserServiceBeanDefinitionParser());
|
||||
parsers.put(Elements.JDBC_USER_SERVICE, new JdbcUserServiceBeanDefinitionParser());
|
||||
parsers.put(Elements.AUTHENTICATION_PROVIDER, new AuthenticationProviderBeanDefinitionParser());
|
||||
parsers.put(Elements.GLOBAL_METHOD_SECURITY, new GlobalMethodSecurityBeanDefinitionParser());
|
||||
parsers.put(Elements.AUTHENTICATION_MANAGER, new AuthenticationManagerBeanDefinitionParser());
|
||||
parsers.put(Elements.METHOD_SECURITY_METADATA_SOURCE, new MethodSecurityMetadataSourceBeanDefinitionParser());
|
||||
this.parsers.put(Elements.LDAP_PROVIDER, new LdapProviderBeanDefinitionParser());
|
||||
this.parsers.put(Elements.LDAP_SERVER, new LdapServerBeanDefinitionParser());
|
||||
this.parsers.put(Elements.LDAP_USER_SERVICE, new LdapUserServiceBeanDefinitionParser());
|
||||
this.parsers.put(Elements.USER_SERVICE, new UserServiceBeanDefinitionParser());
|
||||
this.parsers.put(Elements.JDBC_USER_SERVICE, new JdbcUserServiceBeanDefinitionParser());
|
||||
this.parsers.put(Elements.AUTHENTICATION_PROVIDER, new AuthenticationProviderBeanDefinitionParser());
|
||||
this.parsers.put(Elements.GLOBAL_METHOD_SECURITY, new GlobalMethodSecurityBeanDefinitionParser());
|
||||
this.parsers.put(Elements.AUTHENTICATION_MANAGER, new AuthenticationManagerBeanDefinitionParser());
|
||||
this.parsers.put(Elements.METHOD_SECURITY_METADATA_SOURCE,
|
||||
new MethodSecurityMetadataSourceBeanDefinitionParser());
|
||||
|
||||
// Only load the web-namespace parsers if the web classes are available
|
||||
if (ClassUtils.isPresent(FILTER_CHAIN_PROXY_CLASSNAME, getClass().getClassLoader())) {
|
||||
parsers.put(Elements.DEBUG, new DebugBeanDefinitionParser());
|
||||
parsers.put(Elements.HTTP, new HttpSecurityBeanDefinitionParser());
|
||||
parsers.put(Elements.HTTP_FIREWALL, new HttpFirewallBeanDefinitionParser());
|
||||
parsers.put(Elements.FILTER_SECURITY_METADATA_SOURCE, new FilterInvocationSecurityMetadataSourceParser());
|
||||
parsers.put(Elements.FILTER_CHAIN, new FilterChainBeanDefinitionParser());
|
||||
filterChainMapBDD = new FilterChainMapBeanDefinitionDecorator();
|
||||
parsers.put(Elements.CLIENT_REGISTRATIONS, new ClientRegistrationsBeanDefinitionParser());
|
||||
this.parsers.put(Elements.DEBUG, new DebugBeanDefinitionParser());
|
||||
this.parsers.put(Elements.HTTP, new HttpSecurityBeanDefinitionParser());
|
||||
this.parsers.put(Elements.HTTP_FIREWALL, new HttpFirewallBeanDefinitionParser());
|
||||
this.parsers.put(Elements.FILTER_SECURITY_METADATA_SOURCE,
|
||||
new FilterInvocationSecurityMetadataSourceParser());
|
||||
this.parsers.put(Elements.FILTER_CHAIN, new FilterChainBeanDefinitionParser());
|
||||
this.filterChainMapBDD = new FilterChainMapBeanDefinitionDecorator();
|
||||
this.parsers.put(Elements.CLIENT_REGISTRATIONS, new ClientRegistrationsBeanDefinitionParser());
|
||||
}
|
||||
|
||||
if (ClassUtils.isPresent(MESSAGE_CLASSNAME, getClass().getClassLoader())) {
|
||||
parsers.put(Elements.WEBSOCKET_MESSAGE_BROKER, new WebSocketMessageBrokerSecurityBeanDefinitionParser());
|
||||
this.parsers.put(Elements.WEBSOCKET_MESSAGE_BROKER,
|
||||
new WebSocketMessageBrokerSecurityBeanDefinitionParser());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
return build();
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.debug("Failed to perform build. Returning null", e);
|
||||
this.logger.debug("Failed to perform build. Returning null", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <C extends SecurityConfigurerAdapter<O, B>> C apply(C configurer) throws Exception {
|
||||
configurer.addObjectPostProcessor(objectPostProcessor);
|
||||
configurer.addObjectPostProcessor(this.objectPostProcessor);
|
||||
configurer.setBuilder((B) this);
|
||||
add(configurer);
|
||||
return configurer;
|
||||
@@ -179,17 +179,18 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
|
||||
Class<? extends SecurityConfigurer<O, B>> clazz = (Class<? extends SecurityConfigurer<O, B>>) configurer
|
||||
.getClass();
|
||||
synchronized (configurers) {
|
||||
if (buildState.isConfigured()) {
|
||||
synchronized (this.configurers) {
|
||||
if (this.buildState.isConfigured()) {
|
||||
throw new IllegalStateException("Cannot apply " + configurer + " to already built object");
|
||||
}
|
||||
List<SecurityConfigurer<O, B>> configs = allowConfigurersOfSameType ? this.configurers.get(clazz) : null;
|
||||
List<SecurityConfigurer<O, B>> configs = this.allowConfigurersOfSameType ? this.configurers.get(clazz)
|
||||
: null;
|
||||
if (configs == null) {
|
||||
configs = new ArrayList<>(1);
|
||||
}
|
||||
configs.add(configurer);
|
||||
this.configurers.put(clazz, configs);
|
||||
if (buildState.isInitializing()) {
|
||||
if (this.buildState.isInitializing()) {
|
||||
this.configurersAddedInInitializing.add(configurer);
|
||||
}
|
||||
}
|
||||
@@ -297,22 +298,22 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
*/
|
||||
@Override
|
||||
protected final O doBuild() throws Exception {
|
||||
synchronized (configurers) {
|
||||
buildState = BuildState.INITIALIZING;
|
||||
synchronized (this.configurers) {
|
||||
this.buildState = BuildState.INITIALIZING;
|
||||
|
||||
beforeInit();
|
||||
init();
|
||||
|
||||
buildState = BuildState.CONFIGURING;
|
||||
this.buildState = BuildState.CONFIGURING;
|
||||
|
||||
beforeConfigure();
|
||||
configure();
|
||||
|
||||
buildState = BuildState.BUILDING;
|
||||
this.buildState = BuildState.BUILDING;
|
||||
|
||||
O result = performBuild();
|
||||
|
||||
buildState = BuildState.BUILT;
|
||||
this.buildState = BuildState.BUILT;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -349,7 +350,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
configurer.init((B) this);
|
||||
}
|
||||
|
||||
for (SecurityConfigurer<O, B> configurer : configurersAddedInInitializing) {
|
||||
for (SecurityConfigurer<O, B> configurer : this.configurersAddedInInitializing) {
|
||||
configurer.init((B) this);
|
||||
}
|
||||
}
|
||||
@@ -376,8 +377,8 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
* @return true, if unbuilt else false
|
||||
*/
|
||||
private boolean isUnbuilt() {
|
||||
synchronized (configurers) {
|
||||
return buildState == BuildState.UNBUILT;
|
||||
synchronized (this.configurers) {
|
||||
return this.buildState == BuildState.UNBUILT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +428,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
}
|
||||
|
||||
public boolean isInitializing() {
|
||||
return INITIALIZING.order == order;
|
||||
return INITIALIZING.order == this.order;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,7 +436,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
|
||||
* @return
|
||||
*/
|
||||
public boolean isConfigured() {
|
||||
return order >= CONFIGURING.order;
|
||||
return this.order >= CONFIGURING.order;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ public abstract class SecurityConfigurerAdapter<O, B extends SecurityBuilder<O>>
|
||||
* @throws IllegalStateException if {@link SecurityBuilder} is null
|
||||
*/
|
||||
protected final B getBuilder() {
|
||||
if (securityBuilder == null) {
|
||||
if (this.securityBuilder == null) {
|
||||
throw new IllegalStateException("securityBuilder cannot be null");
|
||||
}
|
||||
return securityBuilder;
|
||||
return this.securityBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +108,7 @@ public abstract class SecurityConfigurerAdapter<O, B extends SecurityBuilder<O>>
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object postProcess(Object object) {
|
||||
for (ObjectPostProcessor opp : postProcessors) {
|
||||
for (ObjectPostProcessor opp : this.postProcessors) {
|
||||
Class<?> oppClass = opp.getClass();
|
||||
Class<?> oppType = GenericTypeResolver.resolveTypeArgument(oppClass, ObjectPostProcessor.class);
|
||||
if (oppType == null || oppType.isAssignableFrom(object.getClass())) {
|
||||
@@ -125,7 +125,7 @@ public abstract class SecurityConfigurerAdapter<O, B extends SecurityBuilder<O>>
|
||||
*/
|
||||
private boolean addObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor) {
|
||||
boolean result = this.postProcessors.add(objectPostProcessor);
|
||||
postProcessors.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
this.postProcessors.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,15 +220,16 @@ public class AuthenticationManagerBuilder
|
||||
@Override
|
||||
protected ProviderManager performBuild() throws Exception {
|
||||
if (!isConfigured()) {
|
||||
logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null.");
|
||||
this.logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null.");
|
||||
return null;
|
||||
}
|
||||
ProviderManager providerManager = new ProviderManager(authenticationProviders, parentAuthenticationManager);
|
||||
if (eraseCredentials != null) {
|
||||
providerManager.setEraseCredentialsAfterAuthentication(eraseCredentials);
|
||||
ProviderManager providerManager = new ProviderManager(this.authenticationProviders,
|
||||
this.parentAuthenticationManager);
|
||||
if (this.eraseCredentials != null) {
|
||||
providerManager.setEraseCredentialsAfterAuthentication(this.eraseCredentials);
|
||||
}
|
||||
if (eventPublisher != null) {
|
||||
providerManager.setAuthenticationEventPublisher(eventPublisher);
|
||||
if (this.eventPublisher != null) {
|
||||
providerManager.setAuthenticationEventPublisher(this.eventPublisher);
|
||||
}
|
||||
providerManager = postProcess(providerManager);
|
||||
return providerManager;
|
||||
@@ -250,7 +251,7 @@ public class AuthenticationManagerBuilder
|
||||
* false
|
||||
*/
|
||||
public boolean isConfigured() {
|
||||
return !authenticationProviders.isEmpty() || parentAuthenticationManager != null;
|
||||
return !this.authenticationProviders.isEmpty() || this.parentAuthenticationManager != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,18 +115,18 @@ public class AuthenticationConfiguration {
|
||||
return new AuthenticationManagerDelegator(authBuilder);
|
||||
}
|
||||
|
||||
for (GlobalAuthenticationConfigurerAdapter config : globalAuthConfigurers) {
|
||||
for (GlobalAuthenticationConfigurerAdapter config : this.globalAuthConfigurers) {
|
||||
authBuilder.apply(config);
|
||||
}
|
||||
|
||||
authenticationManager = authBuilder.build();
|
||||
this.authenticationManager = authBuilder.build();
|
||||
|
||||
if (authenticationManager == null) {
|
||||
authenticationManager = getAuthenticationManagerBean();
|
||||
if (this.authenticationManager == null) {
|
||||
this.authenticationManager = getAuthenticationManagerBean();
|
||||
}
|
||||
|
||||
this.authenticationManagerInitialized = true;
|
||||
return authenticationManager;
|
||||
return this.authenticationManager;
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
@@ -148,7 +148,7 @@ public class AuthenticationConfiguration {
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T lazyBean(Class<T> interfaceName) {
|
||||
LazyInitTargetSource lazyTargetSource = new LazyInitTargetSource();
|
||||
String[] beanNamesForType = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(applicationContext,
|
||||
String[] beanNamesForType = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.applicationContext,
|
||||
interfaceName);
|
||||
if (beanNamesForType.length == 0) {
|
||||
return null;
|
||||
@@ -168,20 +168,20 @@ public class AuthenticationConfiguration {
|
||||
}
|
||||
|
||||
lazyTargetSource.setTargetBeanName(beanName);
|
||||
lazyTargetSource.setBeanFactory(applicationContext);
|
||||
lazyTargetSource.setBeanFactory(this.applicationContext);
|
||||
ProxyFactoryBean proxyFactory = new ProxyFactoryBean();
|
||||
proxyFactory = objectPostProcessor.postProcess(proxyFactory);
|
||||
proxyFactory = this.objectPostProcessor.postProcess(proxyFactory);
|
||||
proxyFactory.setTargetSource(lazyTargetSource);
|
||||
return (T) proxyFactory.getObject();
|
||||
}
|
||||
|
||||
private List<String> getPrimaryBeanNames(String[] beanNamesForType) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (!(applicationContext instanceof ConfigurableApplicationContext)) {
|
||||
if (!(this.applicationContext instanceof ConfigurableApplicationContext)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
for (String beanName : beanNamesForType) {
|
||||
if (((ConfigurableApplicationContext) applicationContext).getBeanFactory().getBeanDefinition(beanName)
|
||||
if (((ConfigurableApplicationContext) this.applicationContext).getBeanFactory().getBeanDefinition(beanName)
|
||||
.isPrimary()) {
|
||||
list.add(beanName);
|
||||
}
|
||||
@@ -214,7 +214,8 @@ public class AuthenticationConfiguration {
|
||||
|
||||
@Override
|
||||
public void init(AuthenticationManagerBuilder auth) {
|
||||
Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(EnableGlobalAuthentication.class);
|
||||
Map<String, Object> beansWithAnnotation = this.context
|
||||
.getBeansWithAnnotation(EnableGlobalAuthentication.class);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Eagerly initializing " + beansWithAnnotation);
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(ldapAuthenticator,
|
||||
authoritiesPopulator);
|
||||
ldapAuthenticationProvider.setAuthoritiesMapper(getAuthoritiesMapper());
|
||||
if (userDetailsContextMapper != null) {
|
||||
ldapAuthenticationProvider.setUserDetailsContextMapper(userDetailsContextMapper);
|
||||
if (this.userDetailsContextMapper != null) {
|
||||
ldapAuthenticationProvider.setUserDetailsContextMapper(this.userDetailsContextMapper);
|
||||
}
|
||||
return ldapAuthenticationProvider;
|
||||
}
|
||||
@@ -132,15 +132,15 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
* @return the {@link LdapAuthoritiesPopulator}
|
||||
*/
|
||||
private LdapAuthoritiesPopulator getLdapAuthoritiesPopulator() {
|
||||
if (ldapAuthoritiesPopulator != null) {
|
||||
return ldapAuthoritiesPopulator;
|
||||
if (this.ldapAuthoritiesPopulator != null) {
|
||||
return this.ldapAuthoritiesPopulator;
|
||||
}
|
||||
|
||||
DefaultLdapAuthoritiesPopulator defaultAuthoritiesPopulator = new DefaultLdapAuthoritiesPopulator(contextSource,
|
||||
groupSearchBase);
|
||||
defaultAuthoritiesPopulator.setGroupRoleAttribute(groupRoleAttribute);
|
||||
defaultAuthoritiesPopulator.setGroupSearchFilter(groupSearchFilter);
|
||||
defaultAuthoritiesPopulator.setSearchSubtree(groupSearchSubtree);
|
||||
DefaultLdapAuthoritiesPopulator defaultAuthoritiesPopulator = new DefaultLdapAuthoritiesPopulator(
|
||||
this.contextSource, this.groupSearchBase);
|
||||
defaultAuthoritiesPopulator.setGroupRoleAttribute(this.groupRoleAttribute);
|
||||
defaultAuthoritiesPopulator.setGroupSearchFilter(this.groupSearchFilter);
|
||||
defaultAuthoritiesPopulator.setSearchSubtree(this.groupSearchSubtree);
|
||||
defaultAuthoritiesPopulator.setRolePrefix(this.rolePrefix);
|
||||
|
||||
this.ldapAuthoritiesPopulator = defaultAuthoritiesPopulator;
|
||||
@@ -169,8 +169,8 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
* @throws Exception if errors in {@link SimpleAuthorityMapper#afterPropertiesSet()}
|
||||
*/
|
||||
protected GrantedAuthoritiesMapper getAuthoritiesMapper() throws Exception {
|
||||
if (authoritiesMapper != null) {
|
||||
return authoritiesMapper;
|
||||
if (this.authoritiesMapper != null) {
|
||||
return this.authoritiesMapper;
|
||||
}
|
||||
|
||||
SimpleAuthorityMapper simpleAuthorityMapper = new SimpleAuthorityMapper();
|
||||
@@ -186,14 +186,14 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
* @return the {@link LdapAuthenticator} to use
|
||||
*/
|
||||
private LdapAuthenticator createLdapAuthenticator(BaseLdapPathContextSource contextSource) {
|
||||
AbstractLdapAuthenticator ldapAuthenticator = passwordEncoder == null ? createBindAuthenticator(contextSource)
|
||||
: createPasswordCompareAuthenticator(contextSource);
|
||||
AbstractLdapAuthenticator ldapAuthenticator = this.passwordEncoder == null
|
||||
? createBindAuthenticator(contextSource) : createPasswordCompareAuthenticator(contextSource);
|
||||
LdapUserSearch userSearch = createUserSearch();
|
||||
if (userSearch != null) {
|
||||
ldapAuthenticator.setUserSearch(userSearch);
|
||||
}
|
||||
if (userDnPatterns != null && userDnPatterns.length > 0) {
|
||||
ldapAuthenticator.setUserDnPatterns(userDnPatterns);
|
||||
if (this.userDnPatterns != null && this.userDnPatterns.length > 0) {
|
||||
ldapAuthenticator.setUserDnPatterns(this.userDnPatterns);
|
||||
}
|
||||
return postProcess(ldapAuthenticator);
|
||||
}
|
||||
@@ -206,10 +206,10 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
private PasswordComparisonAuthenticator createPasswordCompareAuthenticator(
|
||||
BaseLdapPathContextSource contextSource) {
|
||||
PasswordComparisonAuthenticator ldapAuthenticator = new PasswordComparisonAuthenticator(contextSource);
|
||||
if (passwordAttribute != null) {
|
||||
ldapAuthenticator.setPasswordAttributeName(passwordAttribute);
|
||||
if (this.passwordAttribute != null) {
|
||||
ldapAuthenticator.setPasswordAttributeName(this.passwordAttribute);
|
||||
}
|
||||
ldapAuthenticator.setPasswordEncoder(passwordEncoder);
|
||||
ldapAuthenticator.setPasswordEncoder(this.passwordEncoder);
|
||||
return ldapAuthenticator;
|
||||
}
|
||||
|
||||
@@ -223,10 +223,10 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
}
|
||||
|
||||
private LdapUserSearch createUserSearch() {
|
||||
if (userSearchFilter == null) {
|
||||
if (this.userSearchFilter == null) {
|
||||
return null;
|
||||
}
|
||||
return new FilterBasedLdapUserSearch(userSearchBase, userSearchFilter, contextSource);
|
||||
return new FilterBasedLdapUserSearch(this.userSearchBase, this.userSearchFilter, this.contextSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +247,7 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
* @return the {@link ContextSourceBuilder} for further customizations
|
||||
*/
|
||||
public ContextSourceBuilder contextSource() {
|
||||
return contextSourceBuilder;
|
||||
return this.contextSourceBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,12 +540,12 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
}
|
||||
|
||||
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(getProviderUrl());
|
||||
if (managerDn != null) {
|
||||
contextSource.setUserDn(managerDn);
|
||||
if (managerPassword == null) {
|
||||
if (this.managerDn != null) {
|
||||
contextSource.setUserDn(this.managerDn);
|
||||
if (this.managerPassword == null) {
|
||||
throw new IllegalStateException("managerPassword is required if managerDn is supplied");
|
||||
}
|
||||
contextSource.setPassword(managerPassword);
|
||||
contextSource.setPassword(this.managerPassword);
|
||||
}
|
||||
contextSource = postProcess(contextSource);
|
||||
return contextSource;
|
||||
@@ -570,10 +570,10 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
}
|
||||
|
||||
private int getPort() {
|
||||
if (port == null) {
|
||||
port = getDefaultPort();
|
||||
if (this.port == null) {
|
||||
this.port = getDefaultPort();
|
||||
}
|
||||
return port;
|
||||
return this.port;
|
||||
}
|
||||
|
||||
private int getDefaultPort() {
|
||||
@@ -586,10 +586,10 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
}
|
||||
|
||||
private String getProviderUrl() {
|
||||
if (url == null) {
|
||||
return "ldap://127.0.0.1:" + getPort() + "/" + root;
|
||||
if (this.url == null) {
|
||||
return "ldap://127.0.0.1:" + getPort() + "/" + this.root;
|
||||
}
|
||||
return url;
|
||||
return this.url;
|
||||
}
|
||||
|
||||
private ContextSourceBuilder() {
|
||||
@@ -598,10 +598,10 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||
}
|
||||
|
||||
private BaseLdapPathContextSource getContextSource() throws Exception {
|
||||
if (contextSource == null) {
|
||||
contextSource = contextSourceBuilder.build();
|
||||
if (this.contextSource == null) {
|
||||
this.contextSource = this.contextSourceBuilder.build();
|
||||
}
|
||||
return contextSource;
|
||||
return this.contextSource;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -150,7 +150,7 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
|
||||
|
||||
@Override
|
||||
protected void initUserDetailsService() throws Exception {
|
||||
if (!initScripts.isEmpty()) {
|
||||
if (!this.initScripts.isEmpty()) {
|
||||
getDataSourceInit().afterPropertiesSet();
|
||||
}
|
||||
super.initUserDetailsService();
|
||||
@@ -173,14 +173,14 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
|
||||
|
||||
protected DatabasePopulator getDatabasePopulator() {
|
||||
ResourceDatabasePopulator dbp = new ResourceDatabasePopulator();
|
||||
dbp.setScripts(initScripts.toArray(new Resource[0]));
|
||||
dbp.setScripts(this.initScripts.toArray(new Resource[0]));
|
||||
return dbp;
|
||||
}
|
||||
|
||||
private DataSourceInitializer getDataSourceInit() {
|
||||
DataSourceInitializer dsi = new DataSourceInitializer();
|
||||
dsi.setDatabasePopulator(getDatabasePopulator());
|
||||
dsi.setDataSource(dataSource);
|
||||
dsi.setDataSource(this.dataSource);
|
||||
return dsi;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>, C
|
||||
*/
|
||||
@Override
|
||||
protected void initUserDetailsService() throws Exception {
|
||||
for (UserDetailsBuilder userBuilder : userBuilders) {
|
||||
for (UserDetailsBuilder userBuilder : this.userBuilders) {
|
||||
getUserDetailsService().createUser(userBuilder.build());
|
||||
}
|
||||
for (UserDetails userDetails : this.users) {
|
||||
@@ -124,7 +124,7 @@ public class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>, C
|
||||
* @return the {@link UserDetailsManagerConfigurer} for method chaining
|
||||
*/
|
||||
public C and() {
|
||||
return builder;
|
||||
return this.builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract class AbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuil
|
||||
*/
|
||||
protected AbstractDaoAuthenticationConfigurer(U userDetailsService) {
|
||||
this.userDetailsService = userDetailsService;
|
||||
provider.setUserDetailsService(userDetailsService);
|
||||
this.provider.setUserDetailsService(userDetailsService);
|
||||
if (userDetailsService instanceof UserDetailsPasswordService) {
|
||||
this.provider.setUserDetailsPasswordService((UserDetailsPasswordService) userDetailsService);
|
||||
}
|
||||
@@ -70,19 +70,19 @@ abstract class AbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuil
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C passwordEncoder(PasswordEncoder passwordEncoder) {
|
||||
provider.setPasswordEncoder(passwordEncoder);
|
||||
this.provider.setPasswordEncoder(passwordEncoder);
|
||||
return (C) this;
|
||||
}
|
||||
|
||||
public C userDetailsPasswordManager(UserDetailsPasswordService passwordManager) {
|
||||
provider.setUserDetailsPasswordService(passwordManager);
|
||||
this.provider.setUserDetailsPasswordService(passwordManager);
|
||||
return (C) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(B builder) throws Exception {
|
||||
provider = postProcess(provider);
|
||||
builder.authenticationProvider(provider);
|
||||
this.provider = postProcess(this.provider);
|
||||
builder.authenticationProvider(this.provider);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ abstract class AbstractDaoAuthenticationConfigurer<B extends ProviderManagerBuil
|
||||
* {@link DaoAuthenticationProvider}
|
||||
*/
|
||||
public U getUserDetailsService() {
|
||||
return userDetailsService;
|
||||
return this.userDetailsService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ final class AutowireBeanFactoryObjectPostProcessor
|
||||
*/
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
for (SmartInitializingSingleton singleton : smartSingletons) {
|
||||
for (SmartInitializingSingleton singleton : this.smartSingletons) {
|
||||
singleton.afterSingletonsInstantiated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,12 +136,12 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
public MethodInterceptor methodSecurityInterceptor(MethodSecurityMetadataSource methodSecurityMetadataSource) {
|
||||
this.methodSecurityInterceptor = isAspectJ() ? new AspectJMethodSecurityInterceptor()
|
||||
: new MethodSecurityInterceptor();
|
||||
methodSecurityInterceptor.setAccessDecisionManager(accessDecisionManager());
|
||||
methodSecurityInterceptor.setAfterInvocationManager(afterInvocationManager());
|
||||
methodSecurityInterceptor.setSecurityMetadataSource(methodSecurityMetadataSource);
|
||||
this.methodSecurityInterceptor.setAccessDecisionManager(accessDecisionManager());
|
||||
this.methodSecurityInterceptor.setAfterInvocationManager(afterInvocationManager());
|
||||
this.methodSecurityInterceptor.setSecurityMetadataSource(methodSecurityMetadataSource);
|
||||
RunAsManager runAsManager = runAsManager();
|
||||
if (runAsManager != null) {
|
||||
methodSecurityInterceptor.setRunAsManager(runAsManager);
|
||||
this.methodSecurityInterceptor.setRunAsManager(runAsManager);
|
||||
}
|
||||
|
||||
return this.methodSecurityInterceptor;
|
||||
@@ -185,7 +185,7 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
|
||||
private <T> T getSingleBeanOrNull(Class<T> type) {
|
||||
try {
|
||||
return context.getBean(type);
|
||||
return this.context.getBean(type);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
* @return the {@link MethodSecurityExpressionHandler} to use
|
||||
*/
|
||||
protected MethodSecurityExpressionHandler createExpressionHandler() {
|
||||
return defaultMethodExpressionHandler;
|
||||
return this.defaultMethodExpressionHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,10 +288,10 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
* @return a non {@code null} {@link MethodSecurityExpressionHandler}
|
||||
*/
|
||||
protected final MethodSecurityExpressionHandler getExpressionHandler() {
|
||||
if (expressionHandler == null) {
|
||||
expressionHandler = createExpressionHandler();
|
||||
if (this.expressionHandler == null) {
|
||||
this.expressionHandler = createExpressionHandler();
|
||||
}
|
||||
return expressionHandler;
|
||||
return this.expressionHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,20 +313,20 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
* @return the {@link AuthenticationManager} to use
|
||||
*/
|
||||
protected AuthenticationManager authenticationManager() throws Exception {
|
||||
if (authenticationManager == null) {
|
||||
DefaultAuthenticationEventPublisher eventPublisher = objectPostProcessor
|
||||
if (this.authenticationManager == null) {
|
||||
DefaultAuthenticationEventPublisher eventPublisher = this.objectPostProcessor
|
||||
.postProcess(new DefaultAuthenticationEventPublisher());
|
||||
auth = new AuthenticationManagerBuilder(objectPostProcessor);
|
||||
auth.authenticationEventPublisher(eventPublisher);
|
||||
configure(auth);
|
||||
if (disableAuthenticationRegistry) {
|
||||
authenticationManager = getAuthenticationConfiguration().getAuthenticationManager();
|
||||
this.auth = new AuthenticationManagerBuilder(this.objectPostProcessor);
|
||||
this.auth.authenticationEventPublisher(eventPublisher);
|
||||
configure(this.auth);
|
||||
if (this.disableAuthenticationRegistry) {
|
||||
this.authenticationManager = getAuthenticationConfiguration().getAuthenticationManager();
|
||||
}
|
||||
else {
|
||||
authenticationManager = auth.build();
|
||||
this.authenticationManager = this.auth.build();
|
||||
}
|
||||
}
|
||||
return authenticationManager;
|
||||
return this.authenticationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,13 +405,13 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
public final void setImportMetadata(AnnotationMetadata importMetadata) {
|
||||
Map<String, Object> annotationAttributes = importMetadata
|
||||
.getAnnotationAttributes(EnableGlobalMethodSecurity.class.getName());
|
||||
enableMethodSecurity = AnnotationAttributes.fromMap(annotationAttributes);
|
||||
this.enableMethodSecurity = AnnotationAttributes.fromMap(annotationAttributes);
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
|
||||
this.objectPostProcessor = objectPostProcessor;
|
||||
this.defaultMethodExpressionHandler = objectPostProcessor.postProcess(defaultMethodExpressionHandler);
|
||||
this.defaultMethodExpressionHandler = objectPostProcessor.postProcess(this.defaultMethodExpressionHandler);
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
@@ -429,7 +429,7 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
}
|
||||
|
||||
private AuthenticationConfiguration getAuthenticationConfiguration() {
|
||||
return context.getBean(AuthenticationConfiguration.class);
|
||||
return this.context.getBean(AuthenticationConfiguration.class);
|
||||
}
|
||||
|
||||
private boolean prePostEnabled() {
|
||||
@@ -453,7 +453,7 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
|
||||
}
|
||||
|
||||
private AnnotationAttributes enableMethodSecurity() {
|
||||
if (enableMethodSecurity == null) {
|
||||
if (this.enableMethodSecurity == null) {
|
||||
// if it is null look at this instance (i.e. a subclass was used)
|
||||
EnableGlobalMethodSecurity methodSecurityAnnotation = AnnotationUtils.findAnnotation(getClass(),
|
||||
EnableGlobalMethodSecurity.class);
|
||||
|
||||
@@ -54,7 +54,7 @@ class ReactiveMethodSecurityConfiguration implements ImportAware {
|
||||
public MethodSecurityMetadataSourceAdvisor methodSecurityInterceptor(AbstractMethodSecurityMetadataSource source) {
|
||||
MethodSecurityMetadataSourceAdvisor advisor = new MethodSecurityMetadataSourceAdvisor(
|
||||
"securityMethodInterceptor", source, "methodMetadataSource");
|
||||
advisor.setOrder(advisorOrder);
|
||||
advisor.setOrder(this.advisorOrder);
|
||||
return advisor;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,27 +74,29 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
put(CorsFilter.class, order.next());
|
||||
put(CsrfFilter.class, order.next());
|
||||
put(LogoutFilter.class, order.next());
|
||||
filterToOrder.put("org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter",
|
||||
this.filterToOrder.put(
|
||||
"org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter",
|
||||
order.next());
|
||||
filterToOrder.put(
|
||||
this.filterToOrder.put(
|
||||
"org.springframework.security.saml2.provider.service.servlet.filter.Saml2WebSsoAuthenticationRequestFilter",
|
||||
order.next());
|
||||
put(X509AuthenticationFilter.class, order.next());
|
||||
put(AbstractPreAuthenticatedProcessingFilter.class, order.next());
|
||||
filterToOrder.put("org.springframework.security.cas.web.CasAuthenticationFilter", order.next());
|
||||
filterToOrder.put("org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter",
|
||||
this.filterToOrder.put("org.springframework.security.cas.web.CasAuthenticationFilter", order.next());
|
||||
this.filterToOrder.put("org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter",
|
||||
order.next());
|
||||
filterToOrder.put(
|
||||
this.filterToOrder.put(
|
||||
"org.springframework.security.saml2.provider.service.servlet.filter.Saml2WebSsoAuthenticationFilter",
|
||||
order.next());
|
||||
put(UsernamePasswordAuthenticationFilter.class, order.next());
|
||||
order.next(); // gh-8105
|
||||
filterToOrder.put("org.springframework.security.openid.OpenIDAuthenticationFilter", order.next());
|
||||
this.filterToOrder.put("org.springframework.security.openid.OpenIDAuthenticationFilter", order.next());
|
||||
put(DefaultLoginPageGeneratingFilter.class, order.next());
|
||||
put(DefaultLogoutPageGeneratingFilter.class, order.next());
|
||||
put(ConcurrentSessionFilter.class, order.next());
|
||||
put(DigestAuthenticationFilter.class, order.next());
|
||||
filterToOrder.put("org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationFilter",
|
||||
this.filterToOrder.put(
|
||||
"org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationFilter",
|
||||
order.next());
|
||||
put(BasicAuthenticationFilter.class, order.next());
|
||||
put(RequestCacheAwareFilter.class, order.next());
|
||||
@@ -102,7 +104,7 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
put(JaasApiIntegrationFilter.class, order.next());
|
||||
put(RememberMeAuthenticationFilter.class, order.next());
|
||||
put(AnonymousAuthenticationFilter.class, order.next());
|
||||
filterToOrder.put("org.springframework.security.oauth2.client.web.OAuth2AuthorizationCodeGrantFilter",
|
||||
this.filterToOrder.put("org.springframework.security.oauth2.client.web.OAuth2AuthorizationCodeGrantFilter",
|
||||
order.next());
|
||||
put(SessionManagementFilter.class, order.next());
|
||||
put(ExceptionTranslationFilter.class, order.next());
|
||||
@@ -174,7 +176,7 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
|
||||
private void put(Class<? extends Filter> filter, int position) {
|
||||
String className = filter.getName();
|
||||
filterToOrder.put(className, position);
|
||||
this.filterToOrder.put(className, position);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +187,7 @@ final class FilterComparator implements Comparator<Filter>, Serializable {
|
||||
*/
|
||||
private Integer getOrder(Class<?> clazz) {
|
||||
while (clazz != null) {
|
||||
Integer result = filterToOrder.get(clazz.getName());
|
||||
Integer result = this.filterToOrder.get(clazz.getName());
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2518,8 +2518,8 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
||||
|
||||
@Override
|
||||
protected DefaultSecurityFilterChain performBuild() {
|
||||
filters.sort(comparator);
|
||||
return new DefaultSecurityFilterChain(requestMatcher, filters);
|
||||
this.filters.sort(this.comparator);
|
||||
return new DefaultSecurityFilterChain(this.requestMatcher, this.filters);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2557,7 +2557,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
||||
* addFilterAfter(javax .servlet.Filter, java.lang.Class)
|
||||
*/
|
||||
public HttpSecurity addFilterAfter(Filter filter, Class<? extends Filter> afterFilter) {
|
||||
comparator.registerAfter(filter.getClass(), afterFilter);
|
||||
this.comparator.registerAfter(filter.getClass(), afterFilter);
|
||||
return addFilter(filter);
|
||||
}
|
||||
|
||||
@@ -2568,7 +2568,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
||||
* addFilterBefore( javax.servlet.Filter, java.lang.Class)
|
||||
*/
|
||||
public HttpSecurity addFilterBefore(Filter filter, Class<? extends Filter> beforeFilter) {
|
||||
comparator.registerBefore(filter.getClass(), beforeFilter);
|
||||
this.comparator.registerBefore(filter.getClass(), beforeFilter);
|
||||
return addFilter(filter);
|
||||
}
|
||||
|
||||
@@ -2581,7 +2581,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
||||
*/
|
||||
public HttpSecurity addFilter(Filter filter) {
|
||||
Class<? extends Filter> filterClass = filter.getClass();
|
||||
if (!comparator.isRegistered(filterClass)) {
|
||||
if (!this.comparator.isRegistered(filterClass)) {
|
||||
throw new IllegalArgumentException("The Filter class " + filterClass.getName()
|
||||
+ " does not have a registered order and cannot be added without a specified order. Consider using addFilterBefore or addFilterAfter instead.");
|
||||
}
|
||||
@@ -2720,7 +2720,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
||||
* @return the {@link RequestMatcherConfigurer} for further customizations
|
||||
*/
|
||||
public RequestMatcherConfigurer requestMatchers() {
|
||||
return requestMatcherConfigurer;
|
||||
return this.requestMatcherConfigurer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2819,7 +2819,7 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
||||
* @return the {@link HttpSecurity} for further customizations
|
||||
*/
|
||||
public HttpSecurity requestMatchers(Customizer<RequestMatcherConfigurer> requestMatcherCustomizer) {
|
||||
requestMatcherCustomizer.customize(requestMatcherConfigurer);
|
||||
requestMatcherCustomizer.customize(this.requestMatcherConfigurer);
|
||||
return HttpSecurity.this;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
|
||||
|
||||
private DefaultWebSecurityExpressionHandler defaultWebSecurityExpressionHandler = new DefaultWebSecurityExpressionHandler();
|
||||
|
||||
private SecurityExpressionHandler<FilterInvocation> expressionHandler = defaultWebSecurityExpressionHandler;
|
||||
private SecurityExpressionHandler<FilterInvocation> expressionHandler = this.defaultWebSecurityExpressionHandler;
|
||||
|
||||
private Runnable postBuildAction = () -> {
|
||||
};
|
||||
@@ -156,7 +156,7 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
|
||||
* should be ignored
|
||||
*/
|
||||
public IgnoredRequestConfigurer ignoring() {
|
||||
return ignoredRequestRegistry;
|
||||
return this.ignoredRequestRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +230,7 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
|
||||
* @return the {@link SecurityExpressionHandler} for further customizations
|
||||
*/
|
||||
public SecurityExpressionHandler<FilterInvocation> getExpressionHandler() {
|
||||
return expressionHandler;
|
||||
return this.expressionHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,11 +238,11 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
|
||||
* @return the {@link WebInvocationPrivilegeEvaluator} for further customizations
|
||||
*/
|
||||
public WebInvocationPrivilegeEvaluator getPrivilegeEvaluator() {
|
||||
if (privilegeEvaluator != null) {
|
||||
return privilegeEvaluator;
|
||||
if (this.privilegeEvaluator != null) {
|
||||
return this.privilegeEvaluator;
|
||||
}
|
||||
return filterSecurityInterceptor == null ? null
|
||||
: new DefaultWebInvocationPrivilegeEvaluator(filterSecurityInterceptor);
|
||||
return this.filterSecurityInterceptor == null ? null
|
||||
: new DefaultWebInvocationPrivilegeEvaluator(this.filterSecurityInterceptor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,39 +268,39 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
|
||||
|
||||
@Override
|
||||
protected Filter performBuild() throws Exception {
|
||||
Assert.state(!securityFilterChainBuilders.isEmpty(),
|
||||
Assert.state(!this.securityFilterChainBuilders.isEmpty(),
|
||||
() -> "At least one SecurityBuilder<? extends SecurityFilterChain> needs to be specified. "
|
||||
+ "Typically this is done by exposing a SecurityFilterChain bean "
|
||||
+ "or by adding a @Configuration that extends WebSecurityConfigurerAdapter. "
|
||||
+ "More advanced users can invoke " + WebSecurity.class.getSimpleName()
|
||||
+ ".addSecurityFilterChainBuilder directly");
|
||||
int chainSize = ignoredRequests.size() + securityFilterChainBuilders.size();
|
||||
int chainSize = this.ignoredRequests.size() + this.securityFilterChainBuilders.size();
|
||||
List<SecurityFilterChain> securityFilterChains = new ArrayList<>(chainSize);
|
||||
for (RequestMatcher ignoredRequest : ignoredRequests) {
|
||||
for (RequestMatcher ignoredRequest : this.ignoredRequests) {
|
||||
securityFilterChains.add(new DefaultSecurityFilterChain(ignoredRequest));
|
||||
}
|
||||
for (SecurityBuilder<? extends SecurityFilterChain> securityFilterChainBuilder : securityFilterChainBuilders) {
|
||||
for (SecurityBuilder<? extends SecurityFilterChain> securityFilterChainBuilder : this.securityFilterChainBuilders) {
|
||||
securityFilterChains.add(securityFilterChainBuilder.build());
|
||||
}
|
||||
FilterChainProxy filterChainProxy = new FilterChainProxy(securityFilterChains);
|
||||
if (httpFirewall != null) {
|
||||
filterChainProxy.setFirewall(httpFirewall);
|
||||
if (this.httpFirewall != null) {
|
||||
filterChainProxy.setFirewall(this.httpFirewall);
|
||||
}
|
||||
if (requestRejectedHandler != null) {
|
||||
filterChainProxy.setRequestRejectedHandler(requestRejectedHandler);
|
||||
if (this.requestRejectedHandler != null) {
|
||||
filterChainProxy.setRequestRejectedHandler(this.requestRejectedHandler);
|
||||
}
|
||||
filterChainProxy.afterPropertiesSet();
|
||||
|
||||
Filter result = filterChainProxy;
|
||||
if (debugEnabled) {
|
||||
logger.warn("\n\n" + "********************************************************************\n"
|
||||
if (this.debugEnabled) {
|
||||
this.logger.warn("\n\n" + "********************************************************************\n"
|
||||
+ "********** Security debugging is enabled. *************\n"
|
||||
+ "********** This may include sensitive information. *************\n"
|
||||
+ "********** Do not use in a production system! *************\n"
|
||||
+ "********************************************************************\n\n");
|
||||
result = new DebugFilter(filterChainProxy);
|
||||
}
|
||||
postBuildAction.run();
|
||||
this.postBuildAction.run();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ final class AutowiredWebSecurityConfigurersIgnoreParents {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public List<SecurityConfigurer<Filter, WebSecurity>> getWebSecurityConfigurers() {
|
||||
List<SecurityConfigurer<Filter, WebSecurity>> webSecurityConfigurers = new ArrayList<>();
|
||||
Map<String, WebSecurityConfigurer> beansOfType = beanFactory.getBeansOfType(WebSecurityConfigurer.class);
|
||||
Map<String, WebSecurityConfigurer> beansOfType = this.beanFactory.getBeansOfType(WebSecurityConfigurer.class);
|
||||
for (Entry<String, WebSecurityConfigurer> entry : beansOfType.entrySet()) {
|
||||
webSecurityConfigurers.add(entry.getValue());
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class HttpSecurityConfiguration {
|
||||
this.objectPostProcessor, passwordEncoder);
|
||||
authenticationBuilder.parentAuthenticationManager(authenticationManager());
|
||||
|
||||
HttpSecurity http = new HttpSecurity(objectPostProcessor, authenticationBuilder, createSharedObjects());
|
||||
HttpSecurity http = new HttpSecurity(this.objectPostProcessor, authenticationBuilder, createSharedObjects());
|
||||
http.csrf(withDefaults()).addFilter(new WebAsyncManagerIntegrationFilter()).exceptionHandling(withDefaults())
|
||||
.headers(withDefaults()).sessionManagement(withDefaults()).securityContext(withDefaults())
|
||||
.requestCache(withDefaults()).anonymous(withDefaults()).servletApi(withDefaults())
|
||||
@@ -105,7 +105,7 @@ class HttpSecurityConfiguration {
|
||||
|
||||
private Map<Class<?>, Object> createSharedObjects() {
|
||||
Map<Class<?>, Object> sharedObjects = new HashMap<>();
|
||||
sharedObjects.put(ApplicationContext.class, context);
|
||||
sharedObjects.put(ApplicationContext.class, this.context);
|
||||
return sharedObjects;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@ class WebMvcSecurityConfiguration implements WebMvcConfigurer, ApplicationContex
|
||||
@SuppressWarnings("deprecation")
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
AuthenticationPrincipalArgumentResolver authenticationPrincipalResolver = new AuthenticationPrincipalArgumentResolver();
|
||||
authenticationPrincipalResolver.setBeanResolver(beanResolver);
|
||||
authenticationPrincipalResolver.setBeanResolver(this.beanResolver);
|
||||
argumentResolvers.add(authenticationPrincipalResolver);
|
||||
argumentResolvers
|
||||
.add(new org.springframework.security.web.bind.support.AuthenticationPrincipalArgumentResolver());
|
||||
|
||||
CurrentSecurityContextArgumentResolver currentSecurityContextArgumentResolver = new CurrentSecurityContextArgumentResolver();
|
||||
currentSecurityContextArgumentResolver.setBeanResolver(beanResolver);
|
||||
currentSecurityContextArgumentResolver.setBeanResolver(this.beanResolver);
|
||||
argumentResolvers.add(currentSecurityContextArgumentResolver);
|
||||
argumentResolvers.add(new CsrfTokenArgumentResolver());
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||
@Bean
|
||||
@DependsOn(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
|
||||
public SecurityExpressionHandler<FilterInvocation> webSecurityExpressionHandler() {
|
||||
return webSecurity.getExpressionHandler();
|
||||
return this.webSecurity.getExpressionHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,28 +98,28 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||
*/
|
||||
@Bean(name = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
|
||||
public Filter springSecurityFilterChain() throws Exception {
|
||||
boolean hasConfigurers = webSecurityConfigurers != null && !webSecurityConfigurers.isEmpty();
|
||||
boolean hasFilterChain = !securityFilterChains.isEmpty();
|
||||
boolean hasConfigurers = this.webSecurityConfigurers != null && !this.webSecurityConfigurers.isEmpty();
|
||||
boolean hasFilterChain = !this.securityFilterChains.isEmpty();
|
||||
if (hasConfigurers && hasFilterChain) {
|
||||
throw new IllegalStateException(
|
||||
"Found WebSecurityConfigurerAdapter as well as SecurityFilterChain." + "Please select just one.");
|
||||
}
|
||||
if (!hasConfigurers && !hasFilterChain) {
|
||||
WebSecurityConfigurerAdapter adapter = objectObjectPostProcessor
|
||||
WebSecurityConfigurerAdapter adapter = this.objectObjectPostProcessor
|
||||
.postProcess(new WebSecurityConfigurerAdapter() {
|
||||
});
|
||||
webSecurity.apply(adapter);
|
||||
this.webSecurity.apply(adapter);
|
||||
}
|
||||
for (SecurityFilterChain securityFilterChain : securityFilterChains) {
|
||||
webSecurity.addSecurityFilterChainBuilder(() -> securityFilterChain);
|
||||
for (SecurityFilterChain securityFilterChain : this.securityFilterChains) {
|
||||
this.webSecurity.addSecurityFilterChainBuilder(() -> securityFilterChain);
|
||||
for (Filter filter : securityFilterChain.getFilters()) {
|
||||
if (filter instanceof FilterSecurityInterceptor) {
|
||||
webSecurity.securityInterceptor((FilterSecurityInterceptor) filter);
|
||||
this.webSecurity.securityInterceptor((FilterSecurityInterceptor) filter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return webSecurity.build();
|
||||
return this.webSecurity.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||
@Bean
|
||||
@DependsOn(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
|
||||
public WebInvocationPrivilegeEvaluator privilegeEvaluator() {
|
||||
return webSecurity.getPrivilegeEvaluator();
|
||||
return this.webSecurity.getPrivilegeEvaluator();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,9 +147,9 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||
public void setFilterChainProxySecurityConfigurer(ObjectPostProcessor<Object> objectPostProcessor,
|
||||
@Value("#{@autowiredWebSecurityConfigurersIgnoreParents.getWebSecurityConfigurers()}") List<SecurityConfigurer<Filter, WebSecurity>> webSecurityConfigurers)
|
||||
throws Exception {
|
||||
webSecurity = objectPostProcessor.postProcess(new WebSecurity(objectPostProcessor));
|
||||
if (debugEnabled != null) {
|
||||
webSecurity.debug(debugEnabled);
|
||||
this.webSecurity = objectPostProcessor.postProcess(new WebSecurity(objectPostProcessor));
|
||||
if (this.debugEnabled != null) {
|
||||
this.webSecurity.debug(this.debugEnabled);
|
||||
}
|
||||
|
||||
webSecurityConfigurers.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
@@ -166,7 +166,7 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||
previousConfig = config;
|
||||
}
|
||||
for (SecurityConfigurer<Filter, WebSecurity> webSecurityConfigurer : webSecurityConfigurers) {
|
||||
webSecurity.apply(webSecurityConfigurer);
|
||||
this.webSecurity.apply(webSecurityConfigurer);
|
||||
}
|
||||
this.webSecurityConfigurers = webSecurityConfigurers;
|
||||
}
|
||||
@@ -231,9 +231,9 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||
Map<String, Object> enableWebSecurityAttrMap = importMetadata
|
||||
.getAnnotationAttributes(EnableWebSecurity.class.getName());
|
||||
AnnotationAttributes enableWebSecurityAttrs = AnnotationAttributes.fromMap(enableWebSecurityAttrMap);
|
||||
debugEnabled = enableWebSecurityAttrs.getBoolean("debug");
|
||||
if (webSecurity != null) {
|
||||
webSecurity.debug(debugEnabled);
|
||||
this.debugEnabled = enableWebSecurityAttrs.getBoolean("debug");
|
||||
if (this.webSecurity != null) {
|
||||
this.webSecurity.debug(this.debugEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,21 +195,21 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected final HttpSecurity getHttp() throws Exception {
|
||||
if (http != null) {
|
||||
return http;
|
||||
if (this.http != null) {
|
||||
return this.http;
|
||||
}
|
||||
|
||||
AuthenticationEventPublisher eventPublisher = getAuthenticationEventPublisher();
|
||||
localConfigureAuthenticationBldr.authenticationEventPublisher(eventPublisher);
|
||||
this.localConfigureAuthenticationBldr.authenticationEventPublisher(eventPublisher);
|
||||
|
||||
AuthenticationManager authenticationManager = authenticationManager();
|
||||
authenticationBuilder.parentAuthenticationManager(authenticationManager);
|
||||
this.authenticationBuilder.parentAuthenticationManager(authenticationManager);
|
||||
Map<Class<?>, Object> sharedObjects = createSharedObjects();
|
||||
|
||||
http = new HttpSecurity(objectPostProcessor, authenticationBuilder, sharedObjects);
|
||||
if (!disableDefaults) {
|
||||
this.http = new HttpSecurity(this.objectPostProcessor, this.authenticationBuilder, sharedObjects);
|
||||
if (!this.disableDefaults) {
|
||||
// @formatter:off
|
||||
http
|
||||
this.http
|
||||
.csrf().and()
|
||||
.addFilter(new WebAsyncManagerIntegrationFilter())
|
||||
.exceptionHandling().and()
|
||||
@@ -227,11 +227,11 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
.loadFactories(AbstractHttpConfigurer.class, classLoader);
|
||||
|
||||
for (AbstractHttpConfigurer configurer : defaultHttpConfigurers) {
|
||||
http.apply(configurer);
|
||||
this.http.apply(configurer);
|
||||
}
|
||||
}
|
||||
configure(http);
|
||||
return http;
|
||||
configure(this.http);
|
||||
return this.http;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,7 +250,7 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
* @throws Exception
|
||||
*/
|
||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||
return new AuthenticationManagerDelegator(authenticationBuilder, context);
|
||||
return new AuthenticationManagerDelegator(this.authenticationBuilder, this.context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,17 +262,17 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
* @throws Exception
|
||||
*/
|
||||
protected AuthenticationManager authenticationManager() throws Exception {
|
||||
if (!authenticationManagerInitialized) {
|
||||
configure(localConfigureAuthenticationBldr);
|
||||
if (disableLocalConfigureAuthenticationBldr) {
|
||||
authenticationManager = authenticationConfiguration.getAuthenticationManager();
|
||||
if (!this.authenticationManagerInitialized) {
|
||||
configure(this.localConfigureAuthenticationBldr);
|
||||
if (this.disableLocalConfigureAuthenticationBldr) {
|
||||
this.authenticationManager = this.authenticationConfiguration.getAuthenticationManager();
|
||||
}
|
||||
else {
|
||||
authenticationManager = localConfigureAuthenticationBldr.build();
|
||||
this.authenticationManager = this.localConfigureAuthenticationBldr.build();
|
||||
}
|
||||
authenticationManagerInitialized = true;
|
||||
this.authenticationManagerInitialized = true;
|
||||
}
|
||||
return authenticationManager;
|
||||
return this.authenticationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,8 +296,8 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
* @see #userDetailsService()
|
||||
*/
|
||||
public UserDetailsService userDetailsServiceBean() throws Exception {
|
||||
AuthenticationManagerBuilder globalAuthBuilder = context.getBean(AuthenticationManagerBuilder.class);
|
||||
return new UserDetailsServiceDelegator(Arrays.asList(localConfigureAuthenticationBldr, globalAuthBuilder));
|
||||
AuthenticationManagerBuilder globalAuthBuilder = this.context.getBean(AuthenticationManagerBuilder.class);
|
||||
return new UserDetailsServiceDelegator(Arrays.asList(this.localConfigureAuthenticationBldr, globalAuthBuilder));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,8 +308,8 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
* @return the {@link UserDetailsService} to use
|
||||
*/
|
||||
protected UserDetailsService userDetailsService() {
|
||||
AuthenticationManagerBuilder globalAuthBuilder = context.getBean(AuthenticationManagerBuilder.class);
|
||||
return new UserDetailsServiceDelegator(Arrays.asList(localConfigureAuthenticationBldr, globalAuthBuilder));
|
||||
AuthenticationManagerBuilder globalAuthBuilder = this.context.getBean(AuthenticationManagerBuilder.class);
|
||||
return new UserDetailsServiceDelegator(Arrays.asList(this.localConfigureAuthenticationBldr, globalAuthBuilder));
|
||||
}
|
||||
|
||||
public void init(final WebSecurity web) throws Exception {
|
||||
@@ -350,7 +350,7 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
* @throws Exception if an error occurs
|
||||
*/
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
logger.debug(
|
||||
this.logger.debug(
|
||||
"Using default configure(HttpSecurity). If subclassed this will potentially override subclass configure(HttpSecurity).");
|
||||
|
||||
// @formatter:off
|
||||
@@ -378,20 +378,20 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
ObjectPostProcessor<Object> objectPostProcessor = context.getBean(ObjectPostProcessor.class);
|
||||
LazyPasswordEncoder passwordEncoder = new LazyPasswordEncoder(context);
|
||||
|
||||
authenticationBuilder = new DefaultPasswordEncoderAuthenticationManagerBuilder(objectPostProcessor,
|
||||
this.authenticationBuilder = new DefaultPasswordEncoderAuthenticationManagerBuilder(objectPostProcessor,
|
||||
passwordEncoder);
|
||||
localConfigureAuthenticationBldr = new DefaultPasswordEncoderAuthenticationManagerBuilder(objectPostProcessor,
|
||||
passwordEncoder) {
|
||||
this.localConfigureAuthenticationBldr = new DefaultPasswordEncoderAuthenticationManagerBuilder(
|
||||
objectPostProcessor, passwordEncoder) {
|
||||
@Override
|
||||
public AuthenticationManagerBuilder eraseCredentials(boolean eraseCredentials) {
|
||||
authenticationBuilder.eraseCredentials(eraseCredentials);
|
||||
WebSecurityConfigurerAdapter.this.authenticationBuilder.eraseCredentials(eraseCredentials);
|
||||
return super.eraseCredentials(eraseCredentials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationManagerBuilder authenticationEventPublisher(
|
||||
AuthenticationEventPublisher eventPublisher) {
|
||||
authenticationBuilder.authenticationEventPublisher(eventPublisher);
|
||||
WebSecurityConfigurerAdapter.this.authenticationBuilder.authenticationEventPublisher(eventPublisher);
|
||||
return super.authenticationEventPublisher(eventPublisher);
|
||||
}
|
||||
};
|
||||
@@ -430,11 +430,11 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
*/
|
||||
private Map<Class<?>, Object> createSharedObjects() {
|
||||
Map<Class<?>, Object> sharedObjects = new HashMap<>();
|
||||
sharedObjects.putAll(localConfigureAuthenticationBldr.getSharedObjects());
|
||||
sharedObjects.putAll(this.localConfigureAuthenticationBldr.getSharedObjects());
|
||||
sharedObjects.put(UserDetailsService.class, userDetailsService());
|
||||
sharedObjects.put(ApplicationContext.class, context);
|
||||
sharedObjects.put(ContentNegotiationStrategy.class, contentNegotiationStrategy);
|
||||
sharedObjects.put(AuthenticationTrustResolver.class, trustResolver);
|
||||
sharedObjects.put(ApplicationContext.class, this.context);
|
||||
sharedObjects.put(ContentNegotiationStrategy.class, this.contentNegotiationStrategy);
|
||||
sharedObjects.put(AuthenticationTrustResolver.class, this.trustResolver);
|
||||
return sharedObjects;
|
||||
}
|
||||
|
||||
@@ -462,27 +462,27 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
}
|
||||
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
if (delegate != null) {
|
||||
return delegate.loadUserByUsername(username);
|
||||
if (this.delegate != null) {
|
||||
return this.delegate.loadUserByUsername(username);
|
||||
}
|
||||
|
||||
synchronized (delegateMonitor) {
|
||||
if (delegate == null) {
|
||||
for (AuthenticationManagerBuilder delegateBuilder : delegateBuilders) {
|
||||
delegate = delegateBuilder.getDefaultUserDetailsService();
|
||||
if (delegate != null) {
|
||||
synchronized (this.delegateMonitor) {
|
||||
if (this.delegate == null) {
|
||||
for (AuthenticationManagerBuilder delegateBuilder : this.delegateBuilders) {
|
||||
this.delegate = delegateBuilder.getDefaultUserDetailsService();
|
||||
if (this.delegate != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (delegate == null) {
|
||||
if (this.delegate == null) {
|
||||
throw new IllegalStateException("UserDetailsService is required.");
|
||||
}
|
||||
this.delegateBuilders = null;
|
||||
}
|
||||
}
|
||||
|
||||
return delegate.loadUserByUsername(username);
|
||||
return this.delegate.loadUserByUsername(username);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -509,24 +509,24 @@ public abstract class WebSecurityConfigurerAdapter implements WebSecurityConfigu
|
||||
Field parentAuthMgrField = ReflectionUtils.findField(AuthenticationManagerBuilder.class,
|
||||
"parentAuthenticationManager");
|
||||
ReflectionUtils.makeAccessible(parentAuthMgrField);
|
||||
beanNames = getAuthenticationManagerBeanNames(context);
|
||||
validateBeanCycle(ReflectionUtils.getField(parentAuthMgrField, delegateBuilder), beanNames);
|
||||
this.beanNames = getAuthenticationManagerBeanNames(context);
|
||||
validateBeanCycle(ReflectionUtils.getField(parentAuthMgrField, delegateBuilder), this.beanNames);
|
||||
this.delegateBuilder = delegateBuilder;
|
||||
}
|
||||
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
if (delegate != null) {
|
||||
return delegate.authenticate(authentication);
|
||||
if (this.delegate != null) {
|
||||
return this.delegate.authenticate(authentication);
|
||||
}
|
||||
|
||||
synchronized (delegateMonitor) {
|
||||
if (delegate == null) {
|
||||
delegate = this.delegateBuilder.getObject();
|
||||
synchronized (this.delegateMonitor) {
|
||||
if (this.delegate == null) {
|
||||
this.delegate = this.delegateBuilder.getObject();
|
||||
this.delegateBuilder = null;
|
||||
}
|
||||
}
|
||||
|
||||
return delegate.authenticate(authentication);
|
||||
return this.delegate.authenticate(authentication);
|
||||
}
|
||||
|
||||
private static Set<String> getAuthenticationManagerBeanNames(ApplicationContext applicationContext) {
|
||||
|
||||
@@ -141,7 +141,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
*/
|
||||
public T loginProcessingUrl(String loginProcessingUrl) {
|
||||
this.loginProcessingUrl = loginProcessingUrl;
|
||||
authFilter.setRequiresAuthenticationRequestMatcher(createLoginProcessingUrlMatcher(loginProcessingUrl));
|
||||
this.authFilter.setRequiresAuthenticationRequestMatcher(createLoginProcessingUrlMatcher(loginProcessingUrl));
|
||||
return getSelf();
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
public void configure(B http) throws Exception {
|
||||
PortMapper portMapper = http.getSharedObject(PortMapper.class);
|
||||
if (portMapper != null) {
|
||||
authenticationEntryPoint.setPortMapper(portMapper);
|
||||
this.authenticationEntryPoint.setPortMapper(portMapper);
|
||||
}
|
||||
|
||||
RequestCache requestCache = http.getSharedObject(RequestCache.class);
|
||||
@@ -276,22 +276,22 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
this.defaultSuccessHandler.setRequestCache(requestCache);
|
||||
}
|
||||
|
||||
authFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
|
||||
authFilter.setAuthenticationSuccessHandler(successHandler);
|
||||
authFilter.setAuthenticationFailureHandler(failureHandler);
|
||||
if (authenticationDetailsSource != null) {
|
||||
authFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
||||
this.authFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
|
||||
this.authFilter.setAuthenticationSuccessHandler(this.successHandler);
|
||||
this.authFilter.setAuthenticationFailureHandler(this.failureHandler);
|
||||
if (this.authenticationDetailsSource != null) {
|
||||
this.authFilter.setAuthenticationDetailsSource(this.authenticationDetailsSource);
|
||||
}
|
||||
SessionAuthenticationStrategy sessionAuthenticationStrategy = http
|
||||
.getSharedObject(SessionAuthenticationStrategy.class);
|
||||
if (sessionAuthenticationStrategy != null) {
|
||||
authFilter.setSessionAuthenticationStrategy(sessionAuthenticationStrategy);
|
||||
this.authFilter.setSessionAuthenticationStrategy(sessionAuthenticationStrategy);
|
||||
}
|
||||
RememberMeServices rememberMeServices = http.getSharedObject(RememberMeServices.class);
|
||||
if (rememberMeServices != null) {
|
||||
authFilter.setRememberMeServices(rememberMeServices);
|
||||
this.authFilter.setRememberMeServices(rememberMeServices);
|
||||
}
|
||||
F filter = postProcess(authFilter);
|
||||
F filter = postProcess(this.authFilter);
|
||||
http.addFilter(filter);
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* @return true if a custom login page has been specified, else false
|
||||
*/
|
||||
public final boolean isCustomLoginPage() {
|
||||
return customLoginPage;
|
||||
return this.customLoginPage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,7 +327,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* @return the Authentication Filter
|
||||
*/
|
||||
protected final F getAuthenticationFilter() {
|
||||
return authFilter;
|
||||
return this.authFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,7 +343,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* @return the login page
|
||||
*/
|
||||
protected final String getLoginPage() {
|
||||
return loginPage;
|
||||
return this.loginPage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,7 +351,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* @return the Authentication Entry Point
|
||||
*/
|
||||
protected final AuthenticationEntryPoint getAuthenticationEntryPoint() {
|
||||
return authenticationEntryPoint;
|
||||
return this.authenticationEntryPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,7 +360,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* @return the URL to submit an authentication request to
|
||||
*/
|
||||
protected final String getLoginProcessingUrl() {
|
||||
return loginProcessingUrl;
|
||||
return this.loginProcessingUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,7 +368,7 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* @return the URL to send users if authentication fails (e.g. "/login?error").
|
||||
*/
|
||||
protected final String getFailureUrl() {
|
||||
return failureUrl;
|
||||
return this.failureUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,16 +376,16 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* @throws Exception
|
||||
*/
|
||||
protected final void updateAuthenticationDefaults() {
|
||||
if (loginProcessingUrl == null) {
|
||||
loginProcessingUrl(loginPage);
|
||||
if (this.loginProcessingUrl == null) {
|
||||
loginProcessingUrl(this.loginPage);
|
||||
}
|
||||
if (failureHandler == null) {
|
||||
failureUrl(loginPage + "?error");
|
||||
if (this.failureHandler == null) {
|
||||
failureUrl(this.loginPage + "?error");
|
||||
}
|
||||
|
||||
final LogoutConfigurer<B> logoutConfigurer = getBuilder().getConfigurer(LogoutConfigurer.class);
|
||||
if (logoutConfigurer != null && !logoutConfigurer.isCustomLogoutSuccess()) {
|
||||
logoutConfigurer.logoutSuccessUrl(loginPage + "?logout");
|
||||
logoutConfigurer.logoutSuccessUrl(this.loginPage + "?logout");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,8 +393,8 @@ public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecur
|
||||
* Updates the default values for access.
|
||||
*/
|
||||
protected final void updateAccessDefaults(B http) {
|
||||
if (permitAll) {
|
||||
PermitAllSupport.permitAll(http, loginPage, loginProcessingUrl, failureUrl);
|
||||
if (this.permitAll) {
|
||||
PermitAllSupport.permitAll(http, this.loginPage, this.loginProcessingUrl, this.failureUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractConfigAttributeRequestMatcherRegistry<C> extends A
|
||||
* {@link #chainRequestMatchers(java.util.List)}
|
||||
*/
|
||||
final List<UrlMapping> getUrlMappings() {
|
||||
return urlMappings;
|
||||
return this.urlMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +100,8 @@ public abstract class AbstractConfigAttributeRequestMatcherRegistry<C> extends A
|
||||
* {@link ConfigAttribute} instances. Cannot be null.
|
||||
*/
|
||||
final LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> createRequestMap() {
|
||||
if (unmappedMatchers != null) {
|
||||
throw new IllegalStateException("An incomplete mapping was found for " + unmappedMatchers
|
||||
if (this.unmappedMatchers != null) {
|
||||
throw new IllegalStateException("An incomplete mapping was found for " + this.unmappedMatchers
|
||||
+ ". Try completing it with something like requestUrls().<something>.hasRole('USER')");
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ public abstract class AbstractConfigAttributeRequestMatcherRegistry<C> extends A
|
||||
}
|
||||
|
||||
public RequestMatcher getRequestMatcher() {
|
||||
return requestMatcher;
|
||||
return this.requestMatcher;
|
||||
}
|
||||
|
||||
public Collection<ConfigAttribute> getConfigAttrs() {
|
||||
return configAttrs;
|
||||
return this.configAttrs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ abstract class AbstractInterceptUrlConfigurer<C extends AbstractInterceptUrlConf
|
||||
}
|
||||
FilterSecurityInterceptor securityInterceptor = createFilterSecurityInterceptor(http, metadataSource,
|
||||
http.getSharedObject(AuthenticationManager.class));
|
||||
if (filterSecurityInterceptorOncePerRequest != null) {
|
||||
securityInterceptor.setObserveOncePerRequest(filterSecurityInterceptorOncePerRequest);
|
||||
if (this.filterSecurityInterceptorOncePerRequest != null) {
|
||||
securityInterceptor.setObserveOncePerRequest(this.filterSecurityInterceptorOncePerRequest);
|
||||
}
|
||||
securityInterceptor = postProcess(securityInterceptor);
|
||||
http.addFilter(securityInterceptor);
|
||||
@@ -157,10 +157,10 @@ abstract class AbstractInterceptUrlConfigurer<C extends AbstractInterceptUrlConf
|
||||
* @return the {@link AccessDecisionManager} to use
|
||||
*/
|
||||
private AccessDecisionManager getAccessDecisionManager(H http) {
|
||||
if (accessDecisionManager == null) {
|
||||
accessDecisionManager = createDefaultAccessDecisionManager(http);
|
||||
if (this.accessDecisionManager == null) {
|
||||
this.accessDecisionManager = createDefaultAccessDecisionManager(http);
|
||||
}
|
||||
return accessDecisionManager;
|
||||
return this.accessDecisionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,27 +140,27 @@ public final class AnonymousConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
|
||||
@Override
|
||||
public void init(H http) {
|
||||
if (authenticationProvider == null) {
|
||||
authenticationProvider = new AnonymousAuthenticationProvider(getKey());
|
||||
if (this.authenticationProvider == null) {
|
||||
this.authenticationProvider = new AnonymousAuthenticationProvider(getKey());
|
||||
}
|
||||
if (authenticationFilter == null) {
|
||||
authenticationFilter = new AnonymousAuthenticationFilter(getKey(), principal, authorities);
|
||||
if (this.authenticationFilter == null) {
|
||||
this.authenticationFilter = new AnonymousAuthenticationFilter(getKey(), this.principal, this.authorities);
|
||||
}
|
||||
authenticationProvider = postProcess(authenticationProvider);
|
||||
http.authenticationProvider(authenticationProvider);
|
||||
this.authenticationProvider = postProcess(this.authenticationProvider);
|
||||
http.authenticationProvider(this.authenticationProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(H http) {
|
||||
authenticationFilter.afterPropertiesSet();
|
||||
http.addFilter(authenticationFilter);
|
||||
this.authenticationFilter.afterPropertiesSet();
|
||||
http.addFilter(this.authenticationFilter);
|
||||
}
|
||||
|
||||
private String getKey() {
|
||||
if (key == null) {
|
||||
key = UUID.randomUUID().toString();
|
||||
if (this.key == null) {
|
||||
this.key = UUID.randomUUID().toString();
|
||||
}
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public final class ChannelSecurityConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
}
|
||||
|
||||
public ChannelRequestMatcherRegistry getRegistry() {
|
||||
return REGISTRY;
|
||||
return this.REGISTRY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,19 +105,19 @@ public final class ChannelSecurityConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
channelDecisionManager.setChannelProcessors(getChannelProcessors(http));
|
||||
channelDecisionManager = postProcess(channelDecisionManager);
|
||||
|
||||
channelFilter.setChannelDecisionManager(channelDecisionManager);
|
||||
this.channelFilter.setChannelDecisionManager(channelDecisionManager);
|
||||
|
||||
DefaultFilterInvocationSecurityMetadataSource filterInvocationSecurityMetadataSource = new DefaultFilterInvocationSecurityMetadataSource(
|
||||
requestMap);
|
||||
channelFilter.setSecurityMetadataSource(filterInvocationSecurityMetadataSource);
|
||||
this.requestMap);
|
||||
this.channelFilter.setSecurityMetadataSource(filterInvocationSecurityMetadataSource);
|
||||
|
||||
channelFilter = postProcess(channelFilter);
|
||||
http.addFilter(channelFilter);
|
||||
this.channelFilter = postProcess(this.channelFilter);
|
||||
http.addFilter(this.channelFilter);
|
||||
}
|
||||
|
||||
private List<ChannelProcessor> getChannelProcessors(H http) {
|
||||
if (channelProcessors != null) {
|
||||
return channelProcessors;
|
||||
if (this.channelProcessors != null) {
|
||||
return this.channelProcessors;
|
||||
}
|
||||
|
||||
InsecureChannelProcessor insecureChannelProcessor = new InsecureChannelProcessor();
|
||||
@@ -141,9 +141,9 @@ public final class ChannelSecurityConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
private ChannelRequestMatcherRegistry addAttribute(String attribute, List<? extends RequestMatcher> matchers) {
|
||||
for (RequestMatcher matcher : matchers) {
|
||||
Collection<ConfigAttribute> attrs = Arrays.<ConfigAttribute>asList(new SecurityConfig(attribute));
|
||||
requestMap.put(matcher, attrs);
|
||||
this.requestMap.put(matcher, attrs);
|
||||
}
|
||||
return REGISTRY;
|
||||
return this.REGISTRY;
|
||||
}
|
||||
|
||||
public final class ChannelRequestMatcherRegistry
|
||||
@@ -233,7 +233,7 @@ public final class ChannelSecurityConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
}
|
||||
|
||||
public ChannelRequestMatcherRegistry requires(String attribute) {
|
||||
return addAttribute(attribute, requestMatchers);
|
||||
return addAttribute(attribute, this.requestMatchers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public final class DefaultLoginPageConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
};
|
||||
this.loginPageGeneratingFilter.setResolveHiddenInputs(hiddenInputs);
|
||||
this.logoutPageGeneratingFilter.setResolveHiddenInputs(hiddenInputs);
|
||||
http.setSharedObject(DefaultLoginPageGeneratingFilter.class, loginPageGeneratingFilter);
|
||||
http.setSharedObject(DefaultLoginPageGeneratingFilter.class, this.loginPageGeneratingFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,9 +96,9 @@ public final class DefaultLoginPageConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
authenticationEntryPoint = exceptionConf.getAuthenticationEntryPoint();
|
||||
}
|
||||
|
||||
if (loginPageGeneratingFilter.isEnabled() && authenticationEntryPoint == null) {
|
||||
loginPageGeneratingFilter = postProcess(loginPageGeneratingFilter);
|
||||
http.addFilter(loginPageGeneratingFilter);
|
||||
if (this.loginPageGeneratingFilter.isEnabled() && authenticationEntryPoint == null) {
|
||||
this.loginPageGeneratingFilter = postProcess(this.loginPageGeneratingFilter);
|
||||
http.addFilter(this.loginPageGeneratingFilter);
|
||||
http.addFilter(this.logoutPageGeneratingFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBu
|
||||
}
|
||||
|
||||
public ExpressionInterceptUrlRegistry getRegistry() {
|
||||
return REGISTRY;
|
||||
return this.REGISTRY;
|
||||
}
|
||||
|
||||
public final class ExpressionInterceptUrlRegistry extends
|
||||
@@ -175,7 +175,7 @@ public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBu
|
||||
private void interceptUrl(Iterable<? extends RequestMatcher> requestMatchers,
|
||||
Collection<ConfigAttribute> configAttributes) {
|
||||
for (RequestMatcher requestMatcher : requestMatchers) {
|
||||
REGISTRY.addMapping(
|
||||
this.REGISTRY.addMapping(
|
||||
new AbstractConfigAttributeRequestMatcherRegistry.UrlMapping(requestMatcher, configAttributes));
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBu
|
||||
|
||||
@Override
|
||||
ExpressionBasedFilterInvocationSecurityMetadataSource createMetadataSource(H http) {
|
||||
LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = REGISTRY.createRequestMap();
|
||||
LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = this.REGISTRY.createRequestMap();
|
||||
if (requestMap.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"At least one mapping is required (i.e. authorizeRequests().anyRequest().authenticated())");
|
||||
@@ -201,7 +201,7 @@ public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBu
|
||||
}
|
||||
|
||||
private SecurityExpressionHandler<FilterInvocation> getExpressionHandler(H http) {
|
||||
if (expressionHandler == null) {
|
||||
if (this.expressionHandler == null) {
|
||||
DefaultWebSecurityExpressionHandler defaultHandler = new DefaultWebSecurityExpressionHandler();
|
||||
AuthenticationTrustResolver trustResolver = http.getSharedObject(AuthenticationTrustResolver.class);
|
||||
if (trustResolver != null) {
|
||||
@@ -228,10 +228,10 @@ public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBu
|
||||
}
|
||||
}
|
||||
|
||||
expressionHandler = postProcess(defaultHandler);
|
||||
this.expressionHandler = postProcess(defaultHandler);
|
||||
}
|
||||
|
||||
return expressionHandler;
|
||||
return this.expressionHandler;
|
||||
}
|
||||
|
||||
private static String hasAnyRole(String... authorities) {
|
||||
@@ -439,10 +439,10 @@ public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBu
|
||||
* customization
|
||||
*/
|
||||
public ExpressionInterceptUrlRegistry access(String attribute) {
|
||||
if (not) {
|
||||
if (this.not) {
|
||||
attribute = "!" + attribute;
|
||||
}
|
||||
interceptUrl(requestMatchers, SecurityConfig.createList(attribute));
|
||||
interceptUrl(this.requestMatchers, SecurityConfig.createList(attribute));
|
||||
return ExpressionUrlAuthorizationConfigurer.this.REGISTRY;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link ContentTypeOptionsConfig} for additional customizations
|
||||
*/
|
||||
public ContentTypeOptionsConfig contentTypeOptions() {
|
||||
return contentTypeOptions.enable();
|
||||
return this.contentTypeOptions.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +141,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customizations
|
||||
*/
|
||||
public HeadersConfigurer<H> contentTypeOptions(Customizer<ContentTypeOptionsConfig> contentTypeOptionsCustomizer) {
|
||||
contentTypeOptionsCustomizer.customize(contentTypeOptions.enable());
|
||||
contentTypeOptionsCustomizer.customize(this.contentTypeOptions.enable());
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return {@link HeadersConfigurer} for additional customization.
|
||||
*/
|
||||
public HeadersConfigurer<H> disable() {
|
||||
writer = null;
|
||||
this.writer = null;
|
||||
return and();
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link ContentTypeOptionsConfig} for additional customization
|
||||
*/
|
||||
private ContentTypeOptionsConfig enable() {
|
||||
if (writer == null) {
|
||||
writer = new XContentTypeOptionsHeaderWriter();
|
||||
if (this.writer == null) {
|
||||
this.writer = new XContentTypeOptionsHeaderWriter();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link XXssConfig} for additional customizations
|
||||
*/
|
||||
public XXssConfig xssProtection() {
|
||||
return xssProtection.enable();
|
||||
return this.xssProtection.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +210,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customizations
|
||||
*/
|
||||
public HeadersConfigurer<H> xssProtection(Customizer<XXssConfig> xssCustomizer) {
|
||||
xssCustomizer.customize(xssProtection.enable());
|
||||
xssCustomizer.customize(this.xssProtection.enable());
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @param enabled the new value
|
||||
*/
|
||||
public XXssConfig block(boolean enabled) {
|
||||
writer.setBlock(enabled);
|
||||
this.writer.setBlock(enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @param enabled the new value
|
||||
*/
|
||||
public XXssConfig xssProtectionEnabled(boolean enabled) {
|
||||
writer.setEnabled(enabled);
|
||||
this.writer.setEnabled(enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional configuration
|
||||
*/
|
||||
public HeadersConfigurer<H> disable() {
|
||||
writer = null;
|
||||
this.writer = null;
|
||||
return and();
|
||||
}
|
||||
|
||||
@@ -283,8 +283,8 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link XXssConfig} for additional customization
|
||||
*/
|
||||
private XXssConfig enable() {
|
||||
if (writer == null) {
|
||||
writer = new XXssProtectionHeaderWriter();
|
||||
if (this.writer == null) {
|
||||
this.writer = new XXssProtectionHeaderWriter();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link CacheControlConfig} for additional customizations
|
||||
*/
|
||||
public CacheControlConfig cacheControl() {
|
||||
return cacheControl.enable();
|
||||
return this.cacheControl.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customizations
|
||||
*/
|
||||
public HeadersConfigurer<H> cacheControl(Customizer<CacheControlConfig> cacheControlCustomizer) {
|
||||
cacheControlCustomizer.customize(cacheControl.enable());
|
||||
cacheControlCustomizer.customize(this.cacheControl.enable());
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional configuration
|
||||
*/
|
||||
public HeadersConfigurer<H> disable() {
|
||||
writer = null;
|
||||
this.writer = null;
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -353,8 +353,8 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link CacheControlConfig} for additional customization
|
||||
*/
|
||||
private CacheControlConfig enable() {
|
||||
if (writer == null) {
|
||||
writer = new CacheControlHeadersWriter();
|
||||
if (this.writer == null) {
|
||||
this.writer = new CacheControlHeadersWriter();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -368,7 +368,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HstsConfig} for additional customizations
|
||||
*/
|
||||
public HstsConfig httpStrictTransportSecurity() {
|
||||
return hsts.enable();
|
||||
return this.hsts.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,7 +380,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customizations
|
||||
*/
|
||||
public HeadersConfigurer<H> httpStrictTransportSecurity(Customizer<HstsConfig> hstsCustomizer) {
|
||||
hstsCustomizer.customize(hsts.enable());
|
||||
hstsCustomizer.customize(this.hsts.enable());
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @throws IllegalArgumentException if maxAgeInSeconds is negative
|
||||
*/
|
||||
public HstsConfig maxAgeInSeconds(long maxAgeInSeconds) {
|
||||
writer.setMaxAgeInSeconds(maxAgeInSeconds);
|
||||
this.writer.setMaxAgeInSeconds(maxAgeInSeconds);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @throws IllegalArgumentException if {@link RequestMatcher} is null
|
||||
*/
|
||||
public HstsConfig requestMatcher(RequestMatcher requestMatcher) {
|
||||
writer.setRequestMatcher(requestMatcher);
|
||||
this.writer.setRequestMatcher(requestMatcher);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @param includeSubDomains true to include subdomains, else false
|
||||
*/
|
||||
public HstsConfig includeSubDomains(boolean includeSubDomains) {
|
||||
writer.setIncludeSubDomains(includeSubDomains);
|
||||
this.writer.setIncludeSubDomains(includeSubDomains);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @author Ankur Pathak
|
||||
*/
|
||||
public HstsConfig preload(boolean preload) {
|
||||
writer.setPreload(preload);
|
||||
this.writer.setPreload(preload);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional configuration
|
||||
*/
|
||||
public HeadersConfigurer<H> disable() {
|
||||
writer = null;
|
||||
this.writer = null;
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -483,8 +483,8 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HstsConfig} for additional customization
|
||||
*/
|
||||
private HstsConfig enable() {
|
||||
if (writer == null) {
|
||||
writer = new HstsHeaderWriter();
|
||||
if (this.writer == null) {
|
||||
this.writer = new HstsHeaderWriter();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -496,7 +496,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link FrameOptionsConfig} for additional customizations
|
||||
*/
|
||||
public FrameOptionsConfig frameOptions() {
|
||||
return frameOptions.enable();
|
||||
return this.frameOptions.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,7 +506,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customizations
|
||||
*/
|
||||
public HeadersConfigurer<H> frameOptions(Customizer<FrameOptionsConfig> frameOptionsCustomizer) {
|
||||
frameOptionsCustomizer.customize(frameOptions.enable());
|
||||
frameOptionsCustomizer.customize(this.frameOptions.enable());
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customization.
|
||||
*/
|
||||
public HeadersConfigurer<H> deny() {
|
||||
writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.DENY);
|
||||
this.writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.DENY);
|
||||
return and();
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customization.
|
||||
*/
|
||||
public HeadersConfigurer<H> sameOrigin() {
|
||||
writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.SAMEORIGIN);
|
||||
this.writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.SAMEORIGIN);
|
||||
return and();
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional configuration.
|
||||
*/
|
||||
public HeadersConfigurer<H> disable() {
|
||||
writer = null;
|
||||
this.writer = null;
|
||||
return and();
|
||||
}
|
||||
|
||||
@@ -563,8 +563,8 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the FrameOptionsConfig for additional customization.
|
||||
*/
|
||||
private FrameOptionsConfig enable() {
|
||||
if (writer == null) {
|
||||
writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.DENY);
|
||||
if (this.writer == null) {
|
||||
this.writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.DENY);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -579,7 +579,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @since 4.1
|
||||
*/
|
||||
public HpkpConfig httpPublicKeyPinning() {
|
||||
return hpkp.enable();
|
||||
return this.hpkp.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -590,7 +590,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customizations
|
||||
*/
|
||||
public HeadersConfigurer<H> httpPublicKeyPinning(Customizer<HpkpConfig> hpkpCustomizer) {
|
||||
hpkpCustomizer.customize(hpkp.enable());
|
||||
hpkpCustomizer.customize(this.hpkp.enable());
|
||||
return HeadersConfigurer.this;
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @throws IllegalArgumentException if pins is null
|
||||
*/
|
||||
public HpkpConfig withPins(Map<String, String> pins) {
|
||||
writer.setPins(pins);
|
||||
this.writer.setPins(pins);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @throws IllegalArgumentException if a pin is null
|
||||
*/
|
||||
public HpkpConfig addSha256Pins(String... pins) {
|
||||
writer.addSha256Pins(pins);
|
||||
this.writer.addSha256Pins(pins);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @throws IllegalArgumentException if maxAgeInSeconds is negative
|
||||
*/
|
||||
public HpkpConfig maxAgeInSeconds(long maxAgeInSeconds) {
|
||||
writer.setMaxAgeInSeconds(maxAgeInSeconds);
|
||||
this.writer.setMaxAgeInSeconds(maxAgeInSeconds);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @param includeSubDomains true to include subdomains, else false
|
||||
*/
|
||||
public HpkpConfig includeSubDomains(boolean includeSubDomains) {
|
||||
writer.setIncludeSubDomains(includeSubDomains);
|
||||
this.writer.setIncludeSubDomains(includeSubDomains);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -692,7 +692,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @param reportOnly true to report only, else false
|
||||
*/
|
||||
public HpkpConfig reportOnly(boolean reportOnly) {
|
||||
writer.setReportOnly(reportOnly);
|
||||
this.writer.setReportOnly(reportOnly);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @param reportUri the URI where the browser should send the report to.
|
||||
*/
|
||||
public HpkpConfig reportUri(URI reportUri) {
|
||||
writer.setReportUri(reportUri);
|
||||
this.writer.setReportUri(reportUri);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @throws IllegalArgumentException if the reportUri is not a valid URI
|
||||
*/
|
||||
public HpkpConfig reportUri(String reportUri) {
|
||||
writer.setReportUri(reportUri);
|
||||
this.writer.setReportUri(reportUri);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional configuration.
|
||||
*/
|
||||
public HeadersConfigurer<H> disable() {
|
||||
writer = null;
|
||||
this.writer = null;
|
||||
return and();
|
||||
}
|
||||
|
||||
@@ -753,8 +753,8 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HstsConfig} for additional customization
|
||||
*/
|
||||
private HpkpConfig enable() {
|
||||
if (writer == null) {
|
||||
writer = new HpkpHeaderWriter();
|
||||
if (this.writer == null) {
|
||||
this.writer = new HpkpHeaderWriter();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -788,7 +788,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
*/
|
||||
public ContentSecurityPolicyConfig contentSecurityPolicy(String policyDirectives) {
|
||||
this.contentSecurityPolicy.writer = new ContentSecurityPolicyHeaderWriter(policyDirectives);
|
||||
return contentSecurityPolicy;
|
||||
return this.contentSecurityPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -874,11 +874,11 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link HeadersConfigurer} for additional customization
|
||||
*/
|
||||
public HeadersConfigurer<H> defaultsDisabled() {
|
||||
contentTypeOptions.disable();
|
||||
xssProtection.disable();
|
||||
cacheControl.disable();
|
||||
hsts.disable();
|
||||
frameOptions.disable();
|
||||
this.contentTypeOptions.disable();
|
||||
this.xssProtection.disable();
|
||||
this.cacheControl.disable();
|
||||
this.hsts.disable();
|
||||
this.frameOptions.disable();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -909,16 +909,16 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
*/
|
||||
private List<HeaderWriter> getHeaderWriters() {
|
||||
List<HeaderWriter> writers = new ArrayList<>();
|
||||
addIfNotNull(writers, contentTypeOptions.writer);
|
||||
addIfNotNull(writers, xssProtection.writer);
|
||||
addIfNotNull(writers, cacheControl.writer);
|
||||
addIfNotNull(writers, hsts.writer);
|
||||
addIfNotNull(writers, frameOptions.writer);
|
||||
addIfNotNull(writers, hpkp.writer);
|
||||
addIfNotNull(writers, contentSecurityPolicy.writer);
|
||||
addIfNotNull(writers, referrerPolicy.writer);
|
||||
addIfNotNull(writers, featurePolicy.writer);
|
||||
writers.addAll(headerWriters);
|
||||
addIfNotNull(writers, this.contentTypeOptions.writer);
|
||||
addIfNotNull(writers, this.xssProtection.writer);
|
||||
addIfNotNull(writers, this.cacheControl.writer);
|
||||
addIfNotNull(writers, this.hsts.writer);
|
||||
addIfNotNull(writers, this.frameOptions.writer);
|
||||
addIfNotNull(writers, this.hpkp.writer);
|
||||
addIfNotNull(writers, this.contentSecurityPolicy.writer);
|
||||
addIfNotNull(writers, this.referrerPolicy.writer);
|
||||
addIfNotNull(writers, this.featurePolicy.writer);
|
||||
writers.addAll(this.headerWriters);
|
||||
return writers;
|
||||
}
|
||||
|
||||
@@ -1045,7 +1045,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
*/
|
||||
public FeaturePolicyConfig featurePolicy(String policyDirectives) {
|
||||
this.featurePolicy.writer = new FeaturePolicyHeaderWriter(policyDirectives);
|
||||
return featurePolicy;
|
||||
return this.featurePolicy;
|
||||
}
|
||||
|
||||
public final class FeaturePolicyConfig {
|
||||
|
||||
@@ -212,14 +212,15 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends Abstr
|
||||
* @return the {@link J2eePreAuthenticatedProcessingFilter} to use.
|
||||
*/
|
||||
private J2eePreAuthenticatedProcessingFilter getFilter(AuthenticationManager authenticationManager) {
|
||||
if (j2eePreAuthenticatedProcessingFilter == null) {
|
||||
j2eePreAuthenticatedProcessingFilter = new J2eePreAuthenticatedProcessingFilter();
|
||||
j2eePreAuthenticatedProcessingFilter.setAuthenticationManager(authenticationManager);
|
||||
j2eePreAuthenticatedProcessingFilter.setAuthenticationDetailsSource(createWebAuthenticationDetailsSource());
|
||||
j2eePreAuthenticatedProcessingFilter = postProcess(j2eePreAuthenticatedProcessingFilter);
|
||||
if (this.j2eePreAuthenticatedProcessingFilter == null) {
|
||||
this.j2eePreAuthenticatedProcessingFilter = new J2eePreAuthenticatedProcessingFilter();
|
||||
this.j2eePreAuthenticatedProcessingFilter.setAuthenticationManager(authenticationManager);
|
||||
this.j2eePreAuthenticatedProcessingFilter
|
||||
.setAuthenticationDetailsSource(createWebAuthenticationDetailsSource());
|
||||
this.j2eePreAuthenticatedProcessingFilter = postProcess(this.j2eePreAuthenticatedProcessingFilter);
|
||||
}
|
||||
|
||||
return j2eePreAuthenticatedProcessingFilter;
|
||||
return this.j2eePreAuthenticatedProcessingFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,8 +229,8 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends Abstr
|
||||
* @return the {@link AuthenticationUserDetailsService} to use
|
||||
*/
|
||||
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> getUserDetailsService() {
|
||||
return authenticationUserDetailsService == null ? new PreAuthenticatedGrantedAuthoritiesUserDetailsService()
|
||||
: authenticationUserDetailsService;
|
||||
return this.authenticationUserDetailsService == null
|
||||
? new PreAuthenticatedGrantedAuthoritiesUserDetailsService() : this.authenticationUserDetailsService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +242,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends Abstr
|
||||
private J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource createWebAuthenticationDetailsSource() {
|
||||
J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource detailsSource = new J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource();
|
||||
SimpleMappableAttributesRetriever rolesRetriever = new SimpleMappableAttributesRetriever();
|
||||
rolesRetriever.setMappableAttributes(mappableRoles);
|
||||
rolesRetriever.setMappableAttributes(this.mappableRoles);
|
||||
detailsSource.setMappableRolesRetriever(rolesRetriever);
|
||||
|
||||
detailsSource = postProcess(detailsSource);
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link LogoutConfigurer} for further customization
|
||||
*/
|
||||
public LogoutConfigurer<H> clearAuthentication(boolean clearAuthentication) {
|
||||
contextLogoutHandler.setClearAuthentication(clearAuthentication);
|
||||
this.contextLogoutHandler.setClearAuthentication(clearAuthentication);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link LogoutConfigurer} for further customization
|
||||
*/
|
||||
public LogoutConfigurer<H> invalidateHttpSession(boolean invalidateHttpSession) {
|
||||
contextLogoutHandler.setInvalidateHttpSession(invalidateHttpSession);
|
||||
this.contextLogoutHandler.setInvalidateHttpSession(invalidateHttpSession);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -259,19 +259,19 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
|
||||
private LogoutSuccessHandler createDefaultSuccessHandler() {
|
||||
SimpleUrlLogoutSuccessHandler urlLogoutHandler = new SimpleUrlLogoutSuccessHandler();
|
||||
urlLogoutHandler.setDefaultTargetUrl(logoutSuccessUrl);
|
||||
if (defaultLogoutSuccessHandlerMappings.isEmpty()) {
|
||||
urlLogoutHandler.setDefaultTargetUrl(this.logoutSuccessUrl);
|
||||
if (this.defaultLogoutSuccessHandlerMappings.isEmpty()) {
|
||||
return urlLogoutHandler;
|
||||
}
|
||||
DelegatingLogoutSuccessHandler successHandler = new DelegatingLogoutSuccessHandler(
|
||||
defaultLogoutSuccessHandlerMappings);
|
||||
this.defaultLogoutSuccessHandlerMappings);
|
||||
successHandler.setDefaultLogoutSuccessHandler(urlLogoutHandler);
|
||||
return successHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(H http) {
|
||||
if (permitAll) {
|
||||
if (this.permitAll) {
|
||||
PermitAllSupport.permitAll(http, this.logoutSuccessUrl);
|
||||
PermitAllSupport.permitAll(http, this.getLogoutRequestMatcher(http));
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return true if logout success handling has been customized, else false
|
||||
*/
|
||||
boolean isCustomLogoutSuccess() {
|
||||
return customLogoutSuccess;
|
||||
return this.customLogoutSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,7 +305,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the logoutSuccessUrl
|
||||
*/
|
||||
private String getLogoutSuccessUrl() {
|
||||
return logoutSuccessUrl;
|
||||
return this.logoutSuccessUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,7 +313,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link LogoutHandler} instances. Cannot be null.
|
||||
*/
|
||||
List<LogoutHandler> getLogoutHandlers() {
|
||||
return logoutHandlers;
|
||||
return this.logoutHandlers;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,9 +324,9 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link LogoutFilter} to use.
|
||||
*/
|
||||
private LogoutFilter createLogoutFilter(H http) {
|
||||
logoutHandlers.add(contextLogoutHandler);
|
||||
logoutHandlers.add(postProcess(new LogoutSuccessEventPublishingLogoutHandler()));
|
||||
LogoutHandler[] handlers = logoutHandlers.toArray(new LogoutHandler[0]);
|
||||
this.logoutHandlers.add(this.contextLogoutHandler);
|
||||
this.logoutHandlers.add(postProcess(new LogoutSuccessEventPublishingLogoutHandler()));
|
||||
LogoutHandler[] handlers = this.logoutHandlers.toArray(new LogoutHandler[0]);
|
||||
LogoutFilter result = new LogoutFilter(getLogoutSuccessHandler(), handlers);
|
||||
result.setLogoutRequestMatcher(getLogoutRequestMatcher(http));
|
||||
result = postProcess(result);
|
||||
@@ -335,8 +335,8 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private RequestMatcher getLogoutRequestMatcher(H http) {
|
||||
if (logoutRequestMatcher != null) {
|
||||
return logoutRequestMatcher;
|
||||
if (this.logoutRequestMatcher != null) {
|
||||
return this.logoutRequestMatcher;
|
||||
}
|
||||
if (http.getConfigurer(CsrfConfigurer.class) != null) {
|
||||
this.logoutRequestMatcher = new AntPathRequestMatcher(this.logoutUrl, "POST");
|
||||
|
||||
@@ -73,16 +73,16 @@ final class PermitAllSupport {
|
||||
}
|
||||
|
||||
if ("".equals(request.getContextPath())) {
|
||||
return uri.equals(processUrl);
|
||||
return uri.equals(this.processUrl);
|
||||
}
|
||||
|
||||
return uri.equals(request.getContextPath() + processUrl);
|
||||
return uri.equals(request.getContextPath() + this.processUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ExactUrl [processUrl='").append(processUrl).append("']");
|
||||
sb.append("ExactUrl [processUrl='").append(this.processUrl).append("']");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,12 +75,12 @@ public final class PortMapperConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link PortMapper} to use
|
||||
*/
|
||||
private PortMapper getPortMapper() {
|
||||
if (portMapper == null) {
|
||||
if (this.portMapper == null) {
|
||||
PortMapperImpl portMapper = new PortMapperImpl();
|
||||
portMapper.setPortMappings(httpsPortMappings);
|
||||
portMapper.setPortMappings(this.httpsPortMappings);
|
||||
this.portMapper = portMapper;
|
||||
}
|
||||
return portMapper;
|
||||
return this.portMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ public final class PortMapperConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link PortMapperConfigurer} for further customization
|
||||
*/
|
||||
public PortMapperConfigurer<H> mapsTo(int httpsPort) {
|
||||
httpsPortMappings.put(String.valueOf(httpPort), String.valueOf(httpsPort));
|
||||
PortMapperConfigurer.this.httpsPortMappings.put(String.valueOf(this.httpPort), String.valueOf(httpsPort));
|
||||
return PortMapperConfigurer.this;
|
||||
}
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
private String getKey() {
|
||||
if (this.key == null) {
|
||||
if (this.rememberMeServices instanceof AbstractRememberMeServices) {
|
||||
this.key = ((AbstractRememberMeServices) rememberMeServices).getKey();
|
||||
this.key = ((AbstractRememberMeServices) this.rememberMeServices).getKey();
|
||||
}
|
||||
else {
|
||||
this.key = UUID.randomUUID().toString();
|
||||
|
||||
@@ -70,24 +70,24 @@ public final class ServletApiConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
}
|
||||
|
||||
public ServletApiConfigurer<H> rolePrefix(String rolePrefix) {
|
||||
securityContextRequestFilter.setRolePrefix(rolePrefix);
|
||||
this.securityContextRequestFilter.setRolePrefix(rolePrefix);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void configure(H http) {
|
||||
securityContextRequestFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
|
||||
this.securityContextRequestFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
|
||||
ExceptionHandlingConfigurer<H> exceptionConf = http.getConfigurer(ExceptionHandlingConfigurer.class);
|
||||
AuthenticationEntryPoint authenticationEntryPoint = exceptionConf == null ? null
|
||||
: exceptionConf.getAuthenticationEntryPoint(http);
|
||||
securityContextRequestFilter.setAuthenticationEntryPoint(authenticationEntryPoint);
|
||||
this.securityContextRequestFilter.setAuthenticationEntryPoint(authenticationEntryPoint);
|
||||
LogoutConfigurer<H> logoutConf = http.getConfigurer(LogoutConfigurer.class);
|
||||
List<LogoutHandler> logoutHandlers = logoutConf == null ? null : logoutConf.getLogoutHandlers();
|
||||
securityContextRequestFilter.setLogoutHandlers(logoutHandlers);
|
||||
this.securityContextRequestFilter.setLogoutHandlers(logoutHandlers);
|
||||
AuthenticationTrustResolver trustResolver = http.getSharedObject(AuthenticationTrustResolver.class);
|
||||
if (trustResolver != null) {
|
||||
securityContextRequestFilter.setTrustResolver(trustResolver);
|
||||
this.securityContextRequestFilter.setTrustResolver(trustResolver);
|
||||
}
|
||||
ApplicationContext context = http.getSharedObject(ApplicationContext.class);
|
||||
if (context != null) {
|
||||
@@ -95,11 +95,11 @@ public final class ServletApiConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
if (grantedAuthorityDefaultsBeanNames.length == 1) {
|
||||
GrantedAuthorityDefaults grantedAuthorityDefaults = context
|
||||
.getBean(grantedAuthorityDefaultsBeanNames[0], GrantedAuthorityDefaults.class);
|
||||
securityContextRequestFilter.setRolePrefix(grantedAuthorityDefaults.getRolePrefix());
|
||||
this.securityContextRequestFilter.setRolePrefix(grantedAuthorityDefaults.getRolePrefix());
|
||||
}
|
||||
}
|
||||
securityContextRequestFilter = postProcess(securityContextRequestFilter);
|
||||
http.addFilter(securityContextRequestFilter);
|
||||
this.securityContextRequestFilter = postProcess(this.securityContextRequestFilter);
|
||||
http.addFilter(this.securityContextRequestFilter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class UrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link ExpressionUrlAuthorizationConfigurer} for further customizations
|
||||
*/
|
||||
public StandardInterceptUrlRegistry getRegistry() {
|
||||
return REGISTRY;
|
||||
return this.REGISTRY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +176,7 @@ public final class UrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
*/
|
||||
@Override
|
||||
FilterInvocationSecurityMetadataSource createMetadataSource(H http) {
|
||||
return new DefaultFilterInvocationSecurityMetadataSource(REGISTRY.createRequestMap());
|
||||
return new DefaultFilterInvocationSecurityMetadataSource(this.REGISTRY.createRequestMap());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,10 +191,10 @@ public final class UrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
private StandardInterceptUrlRegistry addMapping(Iterable<? extends RequestMatcher> requestMatchers,
|
||||
Collection<ConfigAttribute> configAttributes) {
|
||||
for (RequestMatcher requestMatcher : requestMatchers) {
|
||||
REGISTRY.addMapping(
|
||||
this.REGISTRY.addMapping(
|
||||
new AbstractConfigAttributeRequestMatcherRegistry.UrlMapping(requestMatcher, configAttributes));
|
||||
}
|
||||
return REGISTRY;
|
||||
return this.REGISTRY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,7 +334,7 @@ public final class UrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>>
|
||||
* @return the {@link UrlAuthorizationConfigurer} for further customization
|
||||
*/
|
||||
public StandardInterceptUrlRegistry access(String... attributes) {
|
||||
addMapping(requestMatchers, SecurityConfig.createList(attributes));
|
||||
addMapping(this.requestMatchers, SecurityConfig.createList(attributes));
|
||||
return UrlAuthorizationConfigurer.this.REGISTRY;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,27 +185,27 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>>
|
||||
}
|
||||
|
||||
private X509AuthenticationFilter getFilter(AuthenticationManager authenticationManager) {
|
||||
if (x509AuthenticationFilter == null) {
|
||||
x509AuthenticationFilter = new X509AuthenticationFilter();
|
||||
x509AuthenticationFilter.setAuthenticationManager(authenticationManager);
|
||||
if (x509PrincipalExtractor != null) {
|
||||
x509AuthenticationFilter.setPrincipalExtractor(x509PrincipalExtractor);
|
||||
if (this.x509AuthenticationFilter == null) {
|
||||
this.x509AuthenticationFilter = new X509AuthenticationFilter();
|
||||
this.x509AuthenticationFilter.setAuthenticationManager(authenticationManager);
|
||||
if (this.x509PrincipalExtractor != null) {
|
||||
this.x509AuthenticationFilter.setPrincipalExtractor(this.x509PrincipalExtractor);
|
||||
}
|
||||
if (authenticationDetailsSource != null) {
|
||||
x509AuthenticationFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
||||
if (this.authenticationDetailsSource != null) {
|
||||
this.x509AuthenticationFilter.setAuthenticationDetailsSource(this.authenticationDetailsSource);
|
||||
}
|
||||
x509AuthenticationFilter = postProcess(x509AuthenticationFilter);
|
||||
this.x509AuthenticationFilter = postProcess(this.x509AuthenticationFilter);
|
||||
}
|
||||
|
||||
return x509AuthenticationFilter;
|
||||
return this.x509AuthenticationFilter;
|
||||
}
|
||||
|
||||
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> getAuthenticationUserDetailsService(
|
||||
H http) {
|
||||
if (authenticationUserDetailsService == null) {
|
||||
if (this.authenticationUserDetailsService == null) {
|
||||
userDetailsService(http.getSharedObject(UserDetailsService.class));
|
||||
}
|
||||
return authenticationUserDetailsService;
|
||||
return this.authenticationUserDetailsService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -210,9 +210,9 @@ public final class Saml2LoginConfigurer<B extends HttpSecurityBuilder<B>>
|
||||
this.relyingPartyRegistrationRepository = getSharedOrBean(http, RelyingPartyRegistrationRepository.class);
|
||||
}
|
||||
|
||||
saml2WebSsoAuthenticationFilter = new Saml2WebSsoAuthenticationFilter(getAuthenticationConverter(http),
|
||||
this.saml2WebSsoAuthenticationFilter = new Saml2WebSsoAuthenticationFilter(getAuthenticationConverter(http),
|
||||
this.loginProcessingUrl);
|
||||
setAuthenticationFilter(saml2WebSsoAuthenticationFilter);
|
||||
setAuthenticationFilter(this.saml2WebSsoAuthenticationFilter);
|
||||
super.loginProcessingUrl(this.loginProcessingUrl);
|
||||
|
||||
if (hasText(this.loginPage)) {
|
||||
@@ -258,7 +258,7 @@ public final class Saml2LoginConfigurer<B extends HttpSecurityBuilder<B>>
|
||||
registerDefaultAuthenticationProvider(http);
|
||||
}
|
||||
else {
|
||||
saml2WebSsoAuthenticationFilter.setAuthenticationManager(this.authenticationManager);
|
||||
this.saml2WebSsoAuthenticationFilter.setAuthenticationManager(this.authenticationManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ public final class Saml2LoginConfigurer<B extends HttpSecurityBuilder<B>>
|
||||
return;
|
||||
}
|
||||
|
||||
csrf.ignoringRequestMatchers(new AntPathRequestMatcher(loginProcessingUrl));
|
||||
csrf.ignoringRequestMatchers(new AntPathRequestMatcher(this.loginProcessingUrl));
|
||||
}
|
||||
|
||||
private void initDefaultLoginFilter(B http) {
|
||||
|
||||
@@ -231,7 +231,7 @@ public class MessageSecurityMetadataSourceRegistry {
|
||||
matcherToExpression.put(entry.getKey().build(), entry.getValue());
|
||||
}
|
||||
return ExpressionBasedMessageSecurityMetadataSourceFactory
|
||||
.createExpressionMessageMetadataSource(matcherToExpression, expressionHandler);
|
||||
.createExpressionMessageMetadataSource(matcherToExpression, this.expressionHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,8 +378,8 @@ public class MessageSecurityMetadataSourceRegistry {
|
||||
* customization
|
||||
*/
|
||||
public MessageSecurityMetadataSourceRegistry access(String attribute) {
|
||||
for (MatcherBuilder messageMatcher : messageMatchers) {
|
||||
matcherToExpression.put(messageMatcher, attribute);
|
||||
for (MatcherBuilder messageMatcher : this.messageMatchers) {
|
||||
MessageSecurityMetadataSourceRegistry.this.matcherToExpression.put(messageMatcher, attribute);
|
||||
}
|
||||
return MessageSecurityMetadataSourceRegistry.this;
|
||||
}
|
||||
@@ -418,7 +418,7 @@ public class MessageSecurityMetadataSourceRegistry {
|
||||
}
|
||||
|
||||
public MessageMatcher<?> build() {
|
||||
return matcher;
|
||||
return this.matcher;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -435,16 +435,19 @@ public class MessageSecurityMetadataSourceRegistry {
|
||||
}
|
||||
|
||||
public MessageMatcher<?> build() {
|
||||
if (type == null) {
|
||||
return new SimpDestinationMessageMatcher(pattern, pathMatcher);
|
||||
if (this.type == null) {
|
||||
return new SimpDestinationMessageMatcher(this.pattern,
|
||||
MessageSecurityMetadataSourceRegistry.this.pathMatcher);
|
||||
}
|
||||
else if (SimpMessageType.MESSAGE == type) {
|
||||
return SimpDestinationMessageMatcher.createMessageMatcher(pattern, pathMatcher);
|
||||
else if (SimpMessageType.MESSAGE == this.type) {
|
||||
return SimpDestinationMessageMatcher.createMessageMatcher(this.pattern,
|
||||
MessageSecurityMetadataSourceRegistry.this.pathMatcher);
|
||||
}
|
||||
else if (SimpMessageType.SUBSCRIBE == type) {
|
||||
return SimpDestinationMessageMatcher.createSubscribeMatcher(pattern, pathMatcher);
|
||||
else if (SimpMessageType.SUBSCRIBE == this.type) {
|
||||
return SimpDestinationMessageMatcher.createSubscribeMatcher(this.pattern,
|
||||
MessageSecurityMetadataSourceRegistry.this.pathMatcher);
|
||||
}
|
||||
throw new IllegalStateException(type + " is not supported since it does not have a destination");
|
||||
throw new IllegalStateException(this.type + " is not supported since it does not have a destination");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -460,31 +463,31 @@ public class MessageSecurityMetadataSourceRegistry {
|
||||
private PathMatcher delegate = new AntPathMatcher();
|
||||
|
||||
public boolean isPattern(String path) {
|
||||
return delegate.isPattern(path);
|
||||
return this.delegate.isPattern(path);
|
||||
}
|
||||
|
||||
public boolean match(String pattern, String path) {
|
||||
return delegate.match(pattern, path);
|
||||
return this.delegate.match(pattern, path);
|
||||
}
|
||||
|
||||
public boolean matchStart(String pattern, String path) {
|
||||
return delegate.matchStart(pattern, path);
|
||||
return this.delegate.matchStart(pattern, path);
|
||||
}
|
||||
|
||||
public String extractPathWithinPattern(String pattern, String path) {
|
||||
return delegate.extractPathWithinPattern(pattern, path);
|
||||
return this.delegate.extractPathWithinPattern(pattern, path);
|
||||
}
|
||||
|
||||
public Map<String, String> extractUriTemplateVariables(String pattern, String path) {
|
||||
return delegate.extractUriTemplateVariables(pattern, path);
|
||||
return this.delegate.extractUriTemplateVariables(pattern, path);
|
||||
}
|
||||
|
||||
public Comparator<String> getPatternComparator(String path) {
|
||||
return delegate.getPatternComparator(path);
|
||||
return this.delegate.getPatternComparator(path);
|
||||
}
|
||||
|
||||
public String combine(String pattern1, String pattern2) {
|
||||
return delegate.combine(pattern1, pattern2);
|
||||
return this.delegate.combine(pattern1, pattern2);
|
||||
}
|
||||
|
||||
void setPathMatcher(PathMatcher pathMatcher) {
|
||||
|
||||
@@ -103,12 +103,12 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends A
|
||||
|
||||
@Override
|
||||
public final void configureClientInboundChannel(ChannelRegistration registration) {
|
||||
ChannelSecurityInterceptor inboundChannelSecurity = context.getBean(ChannelSecurityInterceptor.class);
|
||||
registration.setInterceptors(context.getBean(SecurityContextChannelInterceptor.class));
|
||||
ChannelSecurityInterceptor inboundChannelSecurity = this.context.getBean(ChannelSecurityInterceptor.class);
|
||||
registration.setInterceptors(this.context.getBean(SecurityContextChannelInterceptor.class));
|
||||
if (!sameOriginDisabled()) {
|
||||
registration.setInterceptors(context.getBean(CsrfChannelInterceptor.class));
|
||||
registration.setInterceptors(this.context.getBean(CsrfChannelInterceptor.class));
|
||||
}
|
||||
if (inboundRegistry.containsMapping()) {
|
||||
if (this.inboundRegistry.containsMapping()) {
|
||||
registration.setInterceptors(inboundChannelSecurity);
|
||||
}
|
||||
customizeClientInboundChannel(registration);
|
||||
@@ -116,7 +116,7 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends A
|
||||
|
||||
private PathMatcher getDefaultPathMatcher() {
|
||||
try {
|
||||
return context.getBean(SimpAnnotationMethodMessageHandler.class).getPathMatcher();
|
||||
return this.context.getBean(SimpAnnotationMethodMessageHandler.class).getPathMatcher();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
return new AntPathMatcher();
|
||||
@@ -174,9 +174,9 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends A
|
||||
|
||||
@Bean
|
||||
public MessageSecurityMetadataSource inboundMessageSecurityMetadataSource() {
|
||||
inboundRegistry.expressionHandler(getMessageExpressionHandler());
|
||||
configureInbound(inboundRegistry);
|
||||
return inboundRegistry.createMetadataSource();
|
||||
this.inboundRegistry.expressionHandler(getMessageExpressionHandler());
|
||||
configureInbound(this.inboundRegistry);
|
||||
return this.inboundRegistry.createMetadataSource();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,14 +223,14 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends A
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
|
||||
defaultExpressionHandler = objectPostProcessor.postProcess(defaultExpressionHandler);
|
||||
this.defaultExpressionHandler = objectPostProcessor.postProcess(this.defaultExpressionHandler);
|
||||
}
|
||||
|
||||
private SecurityExpressionHandler<Message<Object>> getMessageExpressionHandler() {
|
||||
if (expressionHandler == null) {
|
||||
return defaultExpressionHandler;
|
||||
if (this.expressionHandler == null) {
|
||||
return this.defaultExpressionHandler;
|
||||
}
|
||||
return expressionHandler;
|
||||
return this.expressionHandler;
|
||||
}
|
||||
|
||||
public void afterSingletonsInstantiated() {
|
||||
@@ -239,7 +239,7 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends A
|
||||
}
|
||||
|
||||
String beanName = "stompWebSocketHandlerMapping";
|
||||
SimpleUrlHandlerMapping mapping = context.getBean(beanName, SimpleUrlHandlerMapping.class);
|
||||
SimpleUrlHandlerMapping mapping = this.context.getBean(beanName, SimpleUrlHandlerMapping.class);
|
||||
Map<String, Object> mappings = mapping.getHandlerMap();
|
||||
for (Object object : mappings.values()) {
|
||||
if (object instanceof SockJsHttpRequestHandler) {
|
||||
@@ -275,9 +275,9 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends A
|
||||
}
|
||||
}
|
||||
|
||||
if (inboundRegistry.containsMapping() && !inboundRegistry.isSimpDestPathMatcherConfigured()) {
|
||||
if (this.inboundRegistry.containsMapping() && !this.inboundRegistry.isSimpDestPathMatcherConfigured()) {
|
||||
PathMatcher pathMatcher = getDefaultPathMatcher();
|
||||
inboundRegistry.simpDestPathMatcher(pathMatcher);
|
||||
this.inboundRegistry.simpDestPathMatcher(pathMatcher);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class AuthenticationManagerFactoryBean implements FactoryBean<Authenticat
|
||||
|
||||
public AuthenticationManager getObject() throws Exception {
|
||||
try {
|
||||
return (AuthenticationManager) bf.getBean(BeanIds.AUTHENTICATION_MANAGER);
|
||||
return (AuthenticationManager) this.bf.getBean(BeanIds.AUTHENTICATION_MANAGER);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
if (!BeanIds.AUTHENTICATION_MANAGER.equals(e.getBeanName())) {
|
||||
@@ -80,7 +80,7 @@ public class AuthenticationManagerFactoryBean implements FactoryBean<Authenticat
|
||||
}
|
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
bf = beanFactory;
|
||||
this.bf = beanFactory;
|
||||
}
|
||||
|
||||
private <T> T getBeanOrNull(Class<T> type) {
|
||||
|
||||
@@ -76,11 +76,11 @@ public class PasswordEncoderParser {
|
||||
String ref = element.getAttribute(ATT_REF);
|
||||
|
||||
if (StringUtils.hasText(ref)) {
|
||||
passwordEncoder = new RuntimeBeanReference(ref);
|
||||
this.passwordEncoder = new RuntimeBeanReference(ref);
|
||||
}
|
||||
else {
|
||||
passwordEncoder = createPasswordEncoderBeanDefinition(hash, useBase64);
|
||||
((RootBeanDefinition) passwordEncoder).setSource(parserContext.extractSource(element));
|
||||
this.passwordEncoder = createPasswordEncoderBeanDefinition(hash, useBase64);
|
||||
((RootBeanDefinition) this.passwordEncoder).setSource(parserContext.extractSource(element));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class PasswordEncoderParser {
|
||||
}
|
||||
|
||||
public BeanMetadataElement getPasswordEncoder() {
|
||||
return passwordEncoder;
|
||||
return this.passwordEncoder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,16 +112,16 @@ public class UserServiceBeanDefinitionParser extends AbstractUserDetailsServiceB
|
||||
}
|
||||
|
||||
private String generateRandomPassword() {
|
||||
if (random == null) {
|
||||
if (this.random == null) {
|
||||
try {
|
||||
random = SecureRandom.getInstance("SHA1PRNG");
|
||||
this.random = SecureRandom.getInstance("SHA1PRNG");
|
||||
}
|
||||
catch (NoSuchAlgorithmException e) {
|
||||
// Shouldn't happen...
|
||||
throw new RuntimeException("Failed find SHA1PRNG algorithm!");
|
||||
}
|
||||
}
|
||||
return Long.toString(random.nextLong());
|
||||
return Long.toString(this.random.nextLong());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBean
|
||||
|
||||
@Override
|
||||
public MapReactiveUserDetailsService getObject() throws Exception {
|
||||
Collection<UserDetails> users = userDetails.getObject();
|
||||
Collection<UserDetails> users = this.userDetails.getObject();
|
||||
return new MapReactiveUserDetailsService(users);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ReactiveUserDetailsServiceResourceFactoryBean
|
||||
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
userDetails.setResourceLoader(resourceLoader);
|
||||
this.userDetails.setResourceLoader(resourceLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -98,9 +98,9 @@ public class UserDetailsResourceFactoryBean implements ResourceLoaderAware, Fact
|
||||
}
|
||||
|
||||
private Resource getPropertiesResource() {
|
||||
Resource result = resource;
|
||||
if (result == null && resourceLocation != null) {
|
||||
result = resourceLoader.getResource(resourceLocation);
|
||||
Resource result = this.resource;
|
||||
if (result == null && this.resourceLocation != null) {
|
||||
result = this.resourceLoader.getResource(this.resourceLocation);
|
||||
}
|
||||
Assert.notNull(result, "resource cannot be null if resourceLocation is null");
|
||||
return result;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SecurityDebugBeanFactoryPostProcessor implements BeanDefinitionRegi
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
|
||||
logger.warn("\n\n" + "********************************************************************\n"
|
||||
this.logger.warn("\n\n" + "********************************************************************\n"
|
||||
+ "********** Security debugging is enabled. *************\n"
|
||||
+ "********** This may include sensitive information. *************\n"
|
||||
+ "********** Do not use in a production system! *************\n"
|
||||
|
||||
@@ -235,7 +235,7 @@ final class AuthenticationConfigBuilder {
|
||||
this.httpElt = element;
|
||||
this.pc = pc;
|
||||
this.requestCache = requestCache;
|
||||
autoConfig = forceAutoConfig | "true".equals(element.getAttribute(ATT_AUTO_CONFIG));
|
||||
this.autoConfig = forceAutoConfig | "true".equals(element.getAttribute(ATT_AUTO_CONFIG));
|
||||
this.allowSessionCreation = sessionPolicy != SessionCreationPolicy.NEVER
|
||||
&& sessionPolicy != SessionCreationPolicy.STATELESS;
|
||||
this.portMapper = portMapper;
|
||||
@@ -261,7 +261,7 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
// Parse remember me before logout as RememberMeServices is also a LogoutHandler
|
||||
// implementation.
|
||||
Element rememberMeElt = DomUtils.getChildElementByTagName(httpElt, Elements.REMEMBER_ME);
|
||||
Element rememberMeElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.REMEMBER_ME);
|
||||
|
||||
if (rememberMeElt != null) {
|
||||
String key = rememberMeElt.getAttribute(ATT_KEY);
|
||||
@@ -272,49 +272,49 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
RememberMeBeanDefinitionParser rememberMeParser = new RememberMeBeanDefinitionParser(key,
|
||||
authenticationManager);
|
||||
rememberMeFilter = rememberMeParser.parse(rememberMeElt, pc);
|
||||
rememberMeServicesId = rememberMeParser.getRememberMeServicesId();
|
||||
this.rememberMeFilter = rememberMeParser.parse(rememberMeElt, this.pc);
|
||||
this.rememberMeServicesId = rememberMeParser.getRememberMeServicesId();
|
||||
createRememberMeProvider(key);
|
||||
}
|
||||
}
|
||||
|
||||
private void createRememberMeProvider(String key) {
|
||||
RootBeanDefinition provider = new RootBeanDefinition(RememberMeAuthenticationProvider.class);
|
||||
provider.setSource(rememberMeFilter.getSource());
|
||||
provider.setSource(this.rememberMeFilter.getSource());
|
||||
|
||||
provider.getConstructorArgumentValues().addGenericArgumentValue(key);
|
||||
|
||||
String id = pc.getReaderContext().generateBeanName(provider);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(provider, id));
|
||||
String id = this.pc.getReaderContext().generateBeanName(provider);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(provider, id));
|
||||
|
||||
rememberMeProviderRef = new RuntimeBeanReference(id);
|
||||
this.rememberMeProviderRef = new RuntimeBeanReference(id);
|
||||
}
|
||||
|
||||
void createFormLoginFilter(BeanReference sessionStrategy, BeanReference authManager) {
|
||||
|
||||
Element formLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.FORM_LOGIN);
|
||||
Element formLoginElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.FORM_LOGIN);
|
||||
RootBeanDefinition formFilter = null;
|
||||
|
||||
if (formLoginElt != null || autoConfig) {
|
||||
if (formLoginElt != null || this.autoConfig) {
|
||||
FormLoginBeanDefinitionParser parser = new FormLoginBeanDefinitionParser("/login", "POST",
|
||||
AUTHENTICATION_PROCESSING_FILTER_CLASS, requestCache, sessionStrategy, allowSessionCreation,
|
||||
portMapper, portResolver);
|
||||
AUTHENTICATION_PROCESSING_FILTER_CLASS, this.requestCache, sessionStrategy,
|
||||
this.allowSessionCreation, this.portMapper, this.portResolver);
|
||||
|
||||
parser.parse(formLoginElt, pc);
|
||||
parser.parse(formLoginElt, this.pc);
|
||||
formFilter = parser.getFilterBean();
|
||||
formEntryPoint = parser.getEntryPointBean();
|
||||
loginProcessingUrl = parser.getLoginProcessingUrl();
|
||||
formLoginPage = parser.getLoginPage();
|
||||
this.formEntryPoint = parser.getEntryPointBean();
|
||||
this.loginProcessingUrl = parser.getLoginProcessingUrl();
|
||||
this.formLoginPage = parser.getLoginPage();
|
||||
}
|
||||
|
||||
if (formFilter != null) {
|
||||
formFilter.getPropertyValues().addPropertyValue("allowSessionCreation", allowSessionCreation);
|
||||
formFilter.getPropertyValues().addPropertyValue("allowSessionCreation", this.allowSessionCreation);
|
||||
formFilter.getPropertyValues().addPropertyValue("authenticationManager", authManager);
|
||||
|
||||
// Id is required by login page filter
|
||||
formFilterId = pc.getReaderContext().generateBeanName(formFilter);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(formFilter, formFilterId));
|
||||
injectRememberMeServicesRef(formFilter, rememberMeServicesId);
|
||||
this.formFilterId = this.pc.getReaderContext().generateBeanName(formFilter);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(formFilter, this.formFilterId));
|
||||
injectRememberMeServicesRef(formFilter, this.rememberMeServicesId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,8 +332,8 @@ final class AuthenticationConfigBuilder {
|
||||
}
|
||||
this.oauth2LoginEnabled = true;
|
||||
|
||||
OAuth2LoginBeanDefinitionParser parser = new OAuth2LoginBeanDefinitionParser(requestCache, portMapper,
|
||||
portResolver, sessionStrategy, allowSessionCreation);
|
||||
OAuth2LoginBeanDefinitionParser parser = new OAuth2LoginBeanDefinitionParser(this.requestCache, this.portMapper,
|
||||
this.portResolver, sessionStrategy, this.allowSessionCreation);
|
||||
BeanDefinition oauth2LoginFilterBean = parser.parse(oauth2LoginElt, this.pc);
|
||||
|
||||
BeanDefinition defaultAuthorizedClientRepository = parser.getDefaultAuthorizedClientRepository();
|
||||
@@ -343,30 +343,30 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
// retrieve the other bean result
|
||||
BeanDefinition oauth2LoginAuthProvider = parser.getOAuth2LoginAuthenticationProvider();
|
||||
oauth2AuthorizationRequestRedirectFilter = parser.getOAuth2AuthorizationRequestRedirectFilter();
|
||||
oauth2LoginEntryPoint = parser.getOAuth2LoginAuthenticationEntryPoint();
|
||||
this.oauth2AuthorizationRequestRedirectFilter = parser.getOAuth2AuthorizationRequestRedirectFilter();
|
||||
this.oauth2LoginEntryPoint = parser.getOAuth2LoginAuthenticationEntryPoint();
|
||||
|
||||
// generate bean name to be registered
|
||||
String oauth2LoginAuthProviderId = pc.getReaderContext().generateBeanName(oauth2LoginAuthProvider);
|
||||
oauth2LoginFilterId = pc.getReaderContext().generateBeanName(oauth2LoginFilterBean);
|
||||
String oauth2AuthorizationRequestRedirectFilterId = pc.getReaderContext()
|
||||
.generateBeanName(oauth2AuthorizationRequestRedirectFilter);
|
||||
oauth2LoginLinks = parser.getOAuth2LoginLinks();
|
||||
String oauth2LoginAuthProviderId = this.pc.getReaderContext().generateBeanName(oauth2LoginAuthProvider);
|
||||
this.oauth2LoginFilterId = this.pc.getReaderContext().generateBeanName(oauth2LoginFilterBean);
|
||||
String oauth2AuthorizationRequestRedirectFilterId = this.pc.getReaderContext()
|
||||
.generateBeanName(this.oauth2AuthorizationRequestRedirectFilter);
|
||||
this.oauth2LoginLinks = parser.getOAuth2LoginLinks();
|
||||
|
||||
// register the component
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(oauth2LoginFilterBean, oauth2LoginFilterId));
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(oauth2AuthorizationRequestRedirectFilter,
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(oauth2LoginFilterBean, this.oauth2LoginFilterId));
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(this.oauth2AuthorizationRequestRedirectFilter,
|
||||
oauth2AuthorizationRequestRedirectFilterId));
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(oauth2LoginAuthProvider, oauth2LoginAuthProviderId));
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(oauth2LoginAuthProvider, oauth2LoginAuthProviderId));
|
||||
|
||||
oauth2LoginAuthenticationProviderRef = new RuntimeBeanReference(oauth2LoginAuthProviderId);
|
||||
this.oauth2LoginAuthenticationProviderRef = new RuntimeBeanReference(oauth2LoginAuthProviderId);
|
||||
|
||||
// oidc provider
|
||||
BeanDefinition oauth2LoginOidcAuthProvider = parser.getOAuth2LoginOidcAuthenticationProvider();
|
||||
String oauth2LoginOidcAuthProviderId = pc.getReaderContext().generateBeanName(oauth2LoginOidcAuthProvider);
|
||||
pc.registerBeanComponent(
|
||||
String oauth2LoginOidcAuthProviderId = this.pc.getReaderContext().generateBeanName(oauth2LoginOidcAuthProvider);
|
||||
this.pc.registerBeanComponent(
|
||||
new BeanComponentDefinition(oauth2LoginOidcAuthProvider, oauth2LoginOidcAuthProviderId));
|
||||
oauth2LoginOidcAuthenticationProviderRef = new RuntimeBeanReference(oauth2LoginOidcAuthProviderId);
|
||||
this.oauth2LoginOidcAuthenticationProviderRef = new RuntimeBeanReference(oauth2LoginOidcAuthProviderId);
|
||||
}
|
||||
|
||||
void createOAuth2ClientFilter(BeanReference requestCache, BeanReference authenticationManager) {
|
||||
@@ -384,19 +384,19 @@ final class AuthenticationConfigBuilder {
|
||||
registerDefaultAuthorizedClientRepositoryIfNecessary(defaultAuthorizedClientRepository);
|
||||
|
||||
this.authorizationRequestRedirectFilter = parser.getAuthorizationRequestRedirectFilter();
|
||||
String authorizationRequestRedirectFilterId = pc.getReaderContext()
|
||||
String authorizationRequestRedirectFilterId = this.pc.getReaderContext()
|
||||
.generateBeanName(this.authorizationRequestRedirectFilter);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(this.authorizationRequestRedirectFilter,
|
||||
authorizationRequestRedirectFilterId));
|
||||
|
||||
this.authorizationCodeGrantFilter = parser.getAuthorizationCodeGrantFilter();
|
||||
String authorizationCodeGrantFilterId = pc.getReaderContext()
|
||||
String authorizationCodeGrantFilterId = this.pc.getReaderContext()
|
||||
.generateBeanName(this.authorizationCodeGrantFilter);
|
||||
this.pc.registerBeanComponent(
|
||||
new BeanComponentDefinition(this.authorizationCodeGrantFilter, authorizationCodeGrantFilterId));
|
||||
|
||||
BeanDefinition authorizationCodeAuthenticationProvider = parser.getAuthorizationCodeAuthenticationProvider();
|
||||
String authorizationCodeAuthenticationProviderId = pc.getReaderContext()
|
||||
String authorizationCodeAuthenticationProviderId = this.pc.getReaderContext()
|
||||
.generateBeanName(authorizationCodeAuthenticationProvider);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(authorizationCodeAuthenticationProvider,
|
||||
authorizationCodeAuthenticationProviderId));
|
||||
@@ -406,7 +406,7 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
void registerDefaultAuthorizedClientRepositoryIfNecessary(BeanDefinition defaultAuthorizedClientRepository) {
|
||||
if (!this.defaultAuthorizedClientRepositoryRegistered && defaultAuthorizedClientRepository != null) {
|
||||
String authorizedClientRepositoryId = pc.getReaderContext()
|
||||
String authorizedClientRepositoryId = this.pc.getReaderContext()
|
||||
.generateBeanName(defaultAuthorizedClientRepository);
|
||||
this.pc.registerBeanComponent(
|
||||
new BeanComponentDefinition(defaultAuthorizedClientRepository, authorizedClientRepositoryId));
|
||||
@@ -428,7 +428,7 @@ final class AuthenticationConfigBuilder {
|
||||
}
|
||||
|
||||
void createOpenIDLoginFilter(BeanReference sessionStrategy, BeanReference authManager) {
|
||||
Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.OPENID_LOGIN);
|
||||
Element openIDLoginElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.OPENID_LOGIN);
|
||||
RootBeanDefinition openIDFilter = null;
|
||||
|
||||
if (openIDLoginElt != null) {
|
||||
@@ -436,12 +436,12 @@ final class AuthenticationConfigBuilder {
|
||||
}
|
||||
|
||||
if (openIDFilter != null) {
|
||||
openIDFilter.getPropertyValues().addPropertyValue("allowSessionCreation", allowSessionCreation);
|
||||
openIDFilter.getPropertyValues().addPropertyValue("allowSessionCreation", this.allowSessionCreation);
|
||||
openIDFilter.getPropertyValues().addPropertyValue("authenticationManager", authManager);
|
||||
// Required by login page filter
|
||||
openIDFilterId = pc.getReaderContext().generateBeanName(openIDFilter);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(openIDFilter, openIDFilterId));
|
||||
injectRememberMeServicesRef(openIDFilter, rememberMeServicesId);
|
||||
this.openIDFilterId = this.pc.getReaderContext().generateBeanName(openIDFilter);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(openIDFilter, this.openIDFilterId));
|
||||
injectRememberMeServicesRef(openIDFilter, this.rememberMeServicesId);
|
||||
|
||||
createOpenIDProvider();
|
||||
}
|
||||
@@ -460,14 +460,14 @@ final class AuthenticationConfigBuilder {
|
||||
private RootBeanDefinition parseOpenIDFilter(BeanReference sessionStrategy, Element openIDLoginElt) {
|
||||
RootBeanDefinition openIDFilter;
|
||||
FormLoginBeanDefinitionParser parser = new FormLoginBeanDefinitionParser("/login/openid", null,
|
||||
OPEN_ID_AUTHENTICATION_PROCESSING_FILTER_CLASS, requestCache, sessionStrategy, allowSessionCreation,
|
||||
portMapper, portResolver);
|
||||
OPEN_ID_AUTHENTICATION_PROCESSING_FILTER_CLASS, this.requestCache, sessionStrategy,
|
||||
this.allowSessionCreation, this.portMapper, this.portResolver);
|
||||
|
||||
parser.parse(openIDLoginElt, pc);
|
||||
parser.parse(openIDLoginElt, this.pc);
|
||||
openIDFilter = parser.getFilterBean();
|
||||
openIDEntryPoint = parser.getEntryPointBean();
|
||||
openidLoginProcessingUrl = parser.getLoginProcessingUrl();
|
||||
openIDLoginPage = parser.getLoginPage();
|
||||
this.openIDEntryPoint = parser.getEntryPointBean();
|
||||
this.openidLoginProcessingUrl = parser.getLoginProcessingUrl();
|
||||
this.openIDLoginPage = parser.getLoginPage();
|
||||
|
||||
List<Element> attrExElts = DomUtils.getChildElementsByTagName(openIDLoginElt,
|
||||
Elements.OPENID_ATTRIBUTE_EXCHANGE);
|
||||
@@ -483,7 +483,7 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
if (!StringUtils.hasText(identifierMatch)) {
|
||||
if (attrExElts.size() > 1) {
|
||||
pc.getReaderContext().error("You must supply an identifier-match attribute if using more"
|
||||
this.pc.getReaderContext().error("You must supply an identifier-match attribute if using more"
|
||||
+ " than one " + Elements.OPENID_ATTRIBUTE_EXCHANGE + " element", attrExElt);
|
||||
}
|
||||
// Match anything
|
||||
@@ -524,7 +524,7 @@ final class AuthenticationConfigBuilder {
|
||||
}
|
||||
|
||||
private void createOpenIDProvider() {
|
||||
Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.OPENID_LOGIN);
|
||||
Element openIDLoginElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.OPENID_LOGIN);
|
||||
BeanDefinitionBuilder openIDProviderBuilder = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(OPEN_ID_AUTHENTICATION_PROVIDER_CLASS);
|
||||
|
||||
@@ -536,7 +536,8 @@ final class AuthenticationConfigBuilder {
|
||||
openIDProviderBuilder.addPropertyValue("authenticationUserDetailsService", uds);
|
||||
|
||||
BeanDefinition openIDProvider = openIDProviderBuilder.getBeanDefinition();
|
||||
openIDProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(openIDProvider));
|
||||
this.openIDProviderRef = new RuntimeBeanReference(
|
||||
this.pc.getReaderContext().registerWithGeneratedName(openIDProvider));
|
||||
}
|
||||
|
||||
private void injectRememberMeServicesRef(RootBeanDefinition bean, String rememberMeServicesId) {
|
||||
@@ -547,14 +548,14 @@ final class AuthenticationConfigBuilder {
|
||||
}
|
||||
|
||||
void createBasicFilter(BeanReference authManager) {
|
||||
Element basicAuthElt = DomUtils.getChildElementByTagName(httpElt, Elements.BASIC_AUTH);
|
||||
Element basicAuthElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.BASIC_AUTH);
|
||||
|
||||
if (basicAuthElt == null && !autoConfig) {
|
||||
if (basicAuthElt == null && !this.autoConfig) {
|
||||
// No basic auth, do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
String realm = httpElt.getAttribute(ATT_REALM);
|
||||
String realm = this.httpElt.getAttribute(ATT_REALM);
|
||||
if (!StringUtils.hasText(realm)) {
|
||||
realm = DEF_REALM;
|
||||
}
|
||||
@@ -565,29 +566,29 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
if (basicAuthElt != null) {
|
||||
if (StringUtils.hasText(basicAuthElt.getAttribute(ATT_ENTRY_POINT_REF))) {
|
||||
basicEntryPoint = new RuntimeBeanReference(basicAuthElt.getAttribute(ATT_ENTRY_POINT_REF));
|
||||
this.basicEntryPoint = new RuntimeBeanReference(basicAuthElt.getAttribute(ATT_ENTRY_POINT_REF));
|
||||
}
|
||||
|
||||
injectAuthenticationDetailsSource(basicAuthElt, filterBuilder);
|
||||
|
||||
}
|
||||
|
||||
if (basicEntryPoint == null) {
|
||||
if (this.basicEntryPoint == null) {
|
||||
RootBeanDefinition entryPoint = new RootBeanDefinition(BasicAuthenticationEntryPoint.class);
|
||||
entryPoint.setSource(pc.extractSource(httpElt));
|
||||
entryPoint.setSource(this.pc.extractSource(this.httpElt));
|
||||
entryPoint.getPropertyValues().addPropertyValue("realmName", realm);
|
||||
entryPointId = pc.getReaderContext().generateBeanName(entryPoint);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(entryPoint, entryPointId));
|
||||
basicEntryPoint = new RuntimeBeanReference(entryPointId);
|
||||
entryPointId = this.pc.getReaderContext().generateBeanName(entryPoint);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(entryPoint, entryPointId));
|
||||
this.basicEntryPoint = new RuntimeBeanReference(entryPointId);
|
||||
}
|
||||
|
||||
filterBuilder.addConstructorArgValue(authManager);
|
||||
filterBuilder.addConstructorArgValue(basicEntryPoint);
|
||||
basicFilter = filterBuilder.getBeanDefinition();
|
||||
filterBuilder.addConstructorArgValue(this.basicEntryPoint);
|
||||
this.basicFilter = filterBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
void createBearerTokenAuthenticationFilter(BeanReference authManager) {
|
||||
Element resourceServerElt = DomUtils.getChildElementByTagName(httpElt, Elements.OAUTH2_RESOURCE_SERVER);
|
||||
Element resourceServerElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.OAUTH2_RESOURCE_SERVER);
|
||||
|
||||
if (resourceServerElt == null) {
|
||||
// No resource server, do nothing
|
||||
@@ -595,19 +596,19 @@ final class AuthenticationConfigBuilder {
|
||||
}
|
||||
|
||||
OAuth2ResourceServerBeanDefinitionParser resourceServerBuilder = new OAuth2ResourceServerBeanDefinitionParser(
|
||||
authManager, authenticationProviders, defaultEntryPointMappings, defaultDeniedHandlerMappings,
|
||||
csrfIgnoreRequestMatchers);
|
||||
bearerTokenAuthenticationFilter = resourceServerBuilder.parse(resourceServerElt, pc);
|
||||
authManager, this.authenticationProviders, this.defaultEntryPointMappings,
|
||||
this.defaultDeniedHandlerMappings, this.csrfIgnoreRequestMatchers);
|
||||
this.bearerTokenAuthenticationFilter = resourceServerBuilder.parse(resourceServerElt, this.pc);
|
||||
}
|
||||
|
||||
void createX509Filter(BeanReference authManager) {
|
||||
Element x509Elt = DomUtils.getChildElementByTagName(httpElt, Elements.X509);
|
||||
Element x509Elt = DomUtils.getChildElementByTagName(this.httpElt, Elements.X509);
|
||||
RootBeanDefinition filter = null;
|
||||
|
||||
if (x509Elt != null) {
|
||||
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(X509AuthenticationFilter.class);
|
||||
filterBuilder.getRawBeanDefinition().setSource(pc.extractSource(x509Elt));
|
||||
filterBuilder.getRawBeanDefinition().setSource(this.pc.extractSource(x509Elt));
|
||||
filterBuilder.addPropertyValue("authenticationManager", authManager);
|
||||
|
||||
String regex = x509Elt.getAttribute("subject-principal-regex");
|
||||
@@ -628,7 +629,7 @@ final class AuthenticationConfigBuilder {
|
||||
createX509Provider();
|
||||
}
|
||||
|
||||
x509Filter = filter;
|
||||
this.x509Filter = filter;
|
||||
}
|
||||
|
||||
private void injectAuthenticationDetailsSource(Element elt, BeanDefinitionBuilder filterBuilder) {
|
||||
@@ -640,7 +641,7 @@ final class AuthenticationConfigBuilder {
|
||||
}
|
||||
|
||||
private void createX509Provider() {
|
||||
Element x509Elt = DomUtils.getChildElementByTagName(httpElt, Elements.X509);
|
||||
Element x509Elt = DomUtils.getChildElementByTagName(this.httpElt, Elements.X509);
|
||||
BeanDefinition provider = new RootBeanDefinition(PreAuthenticatedAuthenticationProvider.class);
|
||||
|
||||
RootBeanDefinition uds = new RootBeanDefinition();
|
||||
@@ -650,26 +651,26 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
provider.getPropertyValues().addPropertyValue("preAuthenticatedUserDetailsService", uds);
|
||||
|
||||
x509ProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(provider));
|
||||
this.x509ProviderRef = new RuntimeBeanReference(this.pc.getReaderContext().registerWithGeneratedName(provider));
|
||||
}
|
||||
|
||||
private void createPrauthEntryPoint(Element source) {
|
||||
if (preAuthEntryPoint == null) {
|
||||
preAuthEntryPoint = new RootBeanDefinition(Http403ForbiddenEntryPoint.class);
|
||||
preAuthEntryPoint.setSource(pc.extractSource(source));
|
||||
if (this.preAuthEntryPoint == null) {
|
||||
this.preAuthEntryPoint = new RootBeanDefinition(Http403ForbiddenEntryPoint.class);
|
||||
this.preAuthEntryPoint.setSource(this.pc.extractSource(source));
|
||||
}
|
||||
}
|
||||
|
||||
void createJeeFilter(BeanReference authManager) {
|
||||
final String ATT_MAPPABLE_ROLES = "mappable-roles";
|
||||
|
||||
Element jeeElt = DomUtils.getChildElementByTagName(httpElt, Elements.JEE);
|
||||
Element jeeElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.JEE);
|
||||
RootBeanDefinition filter = null;
|
||||
|
||||
if (jeeElt != null) {
|
||||
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(J2eePreAuthenticatedProcessingFilter.class);
|
||||
filterBuilder.getRawBeanDefinition().setSource(pc.extractSource(jeeElt));
|
||||
filterBuilder.getRawBeanDefinition().setSource(this.pc.extractSource(jeeElt));
|
||||
filterBuilder.addPropertyValue("authenticationManager", authManager);
|
||||
|
||||
BeanDefinitionBuilder adsBldr = BeanDefinitionBuilder
|
||||
@@ -695,11 +696,11 @@ final class AuthenticationConfigBuilder {
|
||||
createJeeProvider();
|
||||
}
|
||||
|
||||
jeeFilter = filter;
|
||||
this.jeeFilter = filter;
|
||||
}
|
||||
|
||||
private void createJeeProvider() {
|
||||
Element jeeElt = DomUtils.getChildElementByTagName(httpElt, Elements.JEE);
|
||||
Element jeeElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.JEE);
|
||||
BeanDefinition provider = new RootBeanDefinition(PreAuthenticatedAuthenticationProvider.class);
|
||||
|
||||
RootBeanDefinition uds;
|
||||
@@ -715,15 +716,16 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
provider.getPropertyValues().addPropertyValue("preAuthenticatedUserDetailsService", uds);
|
||||
|
||||
jeeProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(provider));
|
||||
this.jeeProviderRef = new RuntimeBeanReference(this.pc.getReaderContext().registerWithGeneratedName(provider));
|
||||
}
|
||||
|
||||
void createLoginPageFilterIfNeeded() {
|
||||
boolean needLoginPage = formFilterId != null || openIDFilterId != null || oauth2LoginFilterId != null;
|
||||
boolean needLoginPage = this.formFilterId != null || this.openIDFilterId != null
|
||||
|| this.oauth2LoginFilterId != null;
|
||||
|
||||
// If no login page has been defined, add in the default page generator.
|
||||
if (needLoginPage && formLoginPage == null && openIDLoginPage == null) {
|
||||
logger.info("No login page configured. The default internal one will be used. Use the '"
|
||||
if (needLoginPage && this.formLoginPage == null && this.openIDLoginPage == null) {
|
||||
this.logger.info("No login page configured. The default internal one will be used. Use the '"
|
||||
+ FormLoginBeanDefinitionParser.ATT_LOGIN_PAGE + "' attribute to set the URL of the login page.");
|
||||
BeanDefinitionBuilder loginPageFilter = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(DefaultLoginPageGeneratingFilter.class);
|
||||
@@ -733,69 +735,69 @@ final class AuthenticationConfigBuilder {
|
||||
.rootBeanDefinition(DefaultLogoutPageGeneratingFilter.class);
|
||||
logoutPageFilter.addPropertyValue("resolveHiddenInputs", new CsrfTokenHiddenInputFunction());
|
||||
|
||||
if (formFilterId != null) {
|
||||
loginPageFilter.addConstructorArgReference(formFilterId);
|
||||
loginPageFilter.addPropertyValue("authenticationUrl", loginProcessingUrl);
|
||||
if (this.formFilterId != null) {
|
||||
loginPageFilter.addConstructorArgReference(this.formFilterId);
|
||||
loginPageFilter.addPropertyValue("authenticationUrl", this.loginProcessingUrl);
|
||||
}
|
||||
|
||||
if (openIDFilterId != null) {
|
||||
loginPageFilter.addConstructorArgReference(openIDFilterId);
|
||||
loginPageFilter.addPropertyValue("openIDauthenticationUrl", openidLoginProcessingUrl);
|
||||
if (this.openIDFilterId != null) {
|
||||
loginPageFilter.addConstructorArgReference(this.openIDFilterId);
|
||||
loginPageFilter.addPropertyValue("openIDauthenticationUrl", this.openidLoginProcessingUrl);
|
||||
}
|
||||
|
||||
if (oauth2LoginFilterId != null) {
|
||||
loginPageFilter.addConstructorArgReference(oauth2LoginFilterId);
|
||||
if (this.oauth2LoginFilterId != null) {
|
||||
loginPageFilter.addConstructorArgReference(this.oauth2LoginFilterId);
|
||||
loginPageFilter.addPropertyValue("Oauth2LoginEnabled", true);
|
||||
loginPageFilter.addPropertyValue("Oauth2AuthenticationUrlToClientName", oauth2LoginLinks);
|
||||
loginPageFilter.addPropertyValue("Oauth2AuthenticationUrlToClientName", this.oauth2LoginLinks);
|
||||
}
|
||||
|
||||
loginPageGenerationFilter = loginPageFilter.getBeanDefinition();
|
||||
this.loginPageGenerationFilter = loginPageFilter.getBeanDefinition();
|
||||
this.logoutPageGenerationFilter = logoutPageFilter.getBeanDefinition();
|
||||
}
|
||||
}
|
||||
|
||||
void createLogoutFilter() {
|
||||
Element logoutElt = DomUtils.getChildElementByTagName(httpElt, Elements.LOGOUT);
|
||||
if (logoutElt != null || autoConfig) {
|
||||
Element logoutElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.LOGOUT);
|
||||
if (logoutElt != null || this.autoConfig) {
|
||||
String formLoginPage = this.formLoginPage;
|
||||
if (formLoginPage == null) {
|
||||
formLoginPage = DefaultLoginPageGeneratingFilter.DEFAULT_LOGIN_PAGE_URL;
|
||||
}
|
||||
LogoutBeanDefinitionParser logoutParser = new LogoutBeanDefinitionParser(formLoginPage,
|
||||
rememberMeServicesId, csrfLogoutHandler);
|
||||
logoutFilter = logoutParser.parse(logoutElt, pc);
|
||||
logoutHandlers = logoutParser.getLogoutHandlers();
|
||||
this.rememberMeServicesId, this.csrfLogoutHandler);
|
||||
this.logoutFilter = logoutParser.parse(logoutElt, this.pc);
|
||||
this.logoutHandlers = logoutParser.getLogoutHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
ManagedList getLogoutHandlers() {
|
||||
if (logoutHandlers == null && rememberMeProviderRef != null) {
|
||||
logoutHandlers = new ManagedList();
|
||||
if (csrfLogoutHandler != null) {
|
||||
logoutHandlers.add(csrfLogoutHandler);
|
||||
if (this.logoutHandlers == null && this.rememberMeProviderRef != null) {
|
||||
this.logoutHandlers = new ManagedList();
|
||||
if (this.csrfLogoutHandler != null) {
|
||||
this.logoutHandlers.add(this.csrfLogoutHandler);
|
||||
}
|
||||
logoutHandlers.add(new RuntimeBeanReference(rememberMeServicesId));
|
||||
logoutHandlers.add(new RootBeanDefinition(SecurityContextLogoutHandler.class));
|
||||
this.logoutHandlers.add(new RuntimeBeanReference(this.rememberMeServicesId));
|
||||
this.logoutHandlers.add(new RootBeanDefinition(SecurityContextLogoutHandler.class));
|
||||
}
|
||||
|
||||
return logoutHandlers;
|
||||
return this.logoutHandlers;
|
||||
}
|
||||
|
||||
BeanMetadataElement getEntryPointBean() {
|
||||
return mainEntryPoint;
|
||||
return this.mainEntryPoint;
|
||||
}
|
||||
|
||||
BeanMetadataElement getAccessDeniedHandlerBean() {
|
||||
return accessDeniedHandler;
|
||||
return this.accessDeniedHandler;
|
||||
}
|
||||
|
||||
List<BeanDefinition> getCsrfIgnoreRequestMatchers() {
|
||||
return csrfIgnoreRequestMatchers;
|
||||
return this.csrfIgnoreRequestMatchers;
|
||||
}
|
||||
|
||||
void createAnonymousFilter() {
|
||||
Element anonymousElt = DomUtils.getChildElementByTagName(httpElt, Elements.ANONYMOUS);
|
||||
Element anonymousElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.ANONYMOUS);
|
||||
|
||||
if (anonymousElt != null && "false".equals(anonymousElt.getAttribute("enabled"))) {
|
||||
return;
|
||||
@@ -804,13 +806,13 @@ final class AuthenticationConfigBuilder {
|
||||
String grantedAuthority = null;
|
||||
String username = null;
|
||||
String key = null;
|
||||
Object source = pc.extractSource(httpElt);
|
||||
Object source = this.pc.extractSource(this.httpElt);
|
||||
|
||||
if (anonymousElt != null) {
|
||||
grantedAuthority = anonymousElt.getAttribute("granted-authority");
|
||||
username = anonymousElt.getAttribute("username");
|
||||
key = anonymousElt.getAttribute(ATT_KEY);
|
||||
source = pc.extractSource(anonymousElt);
|
||||
source = this.pc.extractSource(anonymousElt);
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(grantedAuthority)) {
|
||||
@@ -826,20 +828,20 @@ final class AuthenticationConfigBuilder {
|
||||
key = createKey();
|
||||
}
|
||||
|
||||
anonymousFilter = new RootBeanDefinition(AnonymousAuthenticationFilter.class);
|
||||
anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(0, key);
|
||||
anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(1, username);
|
||||
anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(2,
|
||||
this.anonymousFilter = new RootBeanDefinition(AnonymousAuthenticationFilter.class);
|
||||
this.anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(0, key);
|
||||
this.anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(1, username);
|
||||
this.anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(2,
|
||||
AuthorityUtils.commaSeparatedStringToAuthorityList(grantedAuthority));
|
||||
anonymousFilter.setSource(source);
|
||||
this.anonymousFilter.setSource(source);
|
||||
|
||||
RootBeanDefinition anonymousProviderBean = new RootBeanDefinition(AnonymousAuthenticationProvider.class);
|
||||
anonymousProviderBean.getConstructorArgumentValues().addIndexedArgumentValue(0, key);
|
||||
anonymousProviderBean.setSource(anonymousFilter.getSource());
|
||||
String id = pc.getReaderContext().generateBeanName(anonymousProviderBean);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(anonymousProviderBean, id));
|
||||
anonymousProviderBean.setSource(this.anonymousFilter.getSource());
|
||||
String id = this.pc.getReaderContext().generateBeanName(anonymousProviderBean);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(anonymousProviderBean, id));
|
||||
|
||||
anonymousProviderRef = new RuntimeBeanReference(id);
|
||||
this.anonymousProviderRef = new RuntimeBeanReference(id);
|
||||
|
||||
}
|
||||
|
||||
@@ -850,14 +852,14 @@ final class AuthenticationConfigBuilder {
|
||||
|
||||
void createExceptionTranslationFilter() {
|
||||
BeanDefinitionBuilder etfBuilder = BeanDefinitionBuilder.rootBeanDefinition(ExceptionTranslationFilter.class);
|
||||
accessDeniedHandler = createAccessDeniedHandler(httpElt, pc);
|
||||
etfBuilder.addPropertyValue("accessDeniedHandler", accessDeniedHandler);
|
||||
assert requestCache != null;
|
||||
mainEntryPoint = selectEntryPoint();
|
||||
etfBuilder.addConstructorArgValue(mainEntryPoint);
|
||||
etfBuilder.addConstructorArgValue(requestCache);
|
||||
this.accessDeniedHandler = createAccessDeniedHandler(this.httpElt, this.pc);
|
||||
etfBuilder.addPropertyValue("accessDeniedHandler", this.accessDeniedHandler);
|
||||
assert this.requestCache != null;
|
||||
this.mainEntryPoint = selectEntryPoint();
|
||||
etfBuilder.addConstructorArgValue(this.mainEntryPoint);
|
||||
etfBuilder.addConstructorArgValue(this.requestCache);
|
||||
|
||||
etf = etfBuilder.getBeanDefinition();
|
||||
this.etf = etfBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
private BeanMetadataElement createAccessDeniedHandler(Element element, ParserContext pc) {
|
||||
@@ -905,143 +907,144 @@ final class AuthenticationConfigBuilder {
|
||||
private BeanMetadataElement selectEntryPoint() {
|
||||
// We need to establish the main entry point.
|
||||
// First check if a custom entry point bean is set
|
||||
String customEntryPoint = httpElt.getAttribute(ATT_ENTRY_POINT_REF);
|
||||
String customEntryPoint = this.httpElt.getAttribute(ATT_ENTRY_POINT_REF);
|
||||
|
||||
if (StringUtils.hasText(customEntryPoint)) {
|
||||
return new RuntimeBeanReference(customEntryPoint);
|
||||
}
|
||||
|
||||
if (!defaultEntryPointMappings.isEmpty()) {
|
||||
if (defaultEntryPointMappings.size() == 1) {
|
||||
return defaultEntryPointMappings.values().iterator().next();
|
||||
if (!this.defaultEntryPointMappings.isEmpty()) {
|
||||
if (this.defaultEntryPointMappings.size() == 1) {
|
||||
return this.defaultEntryPointMappings.values().iterator().next();
|
||||
}
|
||||
BeanDefinitionBuilder delegatingEntryPoint = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(DelegatingAuthenticationEntryPoint.class);
|
||||
delegatingEntryPoint.addConstructorArgValue(defaultEntryPointMappings);
|
||||
delegatingEntryPoint.addConstructorArgValue(this.defaultEntryPointMappings);
|
||||
return delegatingEntryPoint.getBeanDefinition();
|
||||
}
|
||||
|
||||
Element basicAuthElt = DomUtils.getChildElementByTagName(httpElt, Elements.BASIC_AUTH);
|
||||
Element formLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.FORM_LOGIN);
|
||||
Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.OPENID_LOGIN);
|
||||
Element basicAuthElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.BASIC_AUTH);
|
||||
Element formLoginElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.FORM_LOGIN);
|
||||
Element openIDLoginElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.OPENID_LOGIN);
|
||||
// Basic takes precedence if explicit element is used and no others are configured
|
||||
if (basicAuthElt != null && formLoginElt == null && openIDLoginElt == null && oauth2LoginEntryPoint == null) {
|
||||
return basicEntryPoint;
|
||||
if (basicAuthElt != null && formLoginElt == null && openIDLoginElt == null
|
||||
&& this.oauth2LoginEntryPoint == null) {
|
||||
return this.basicEntryPoint;
|
||||
}
|
||||
|
||||
// If formLogin has been enabled either through an element or auto-config, then it
|
||||
// is used if no openID login page
|
||||
// has been set.
|
||||
|
||||
if (formLoginPage != null && openIDLoginPage != null) {
|
||||
pc.getReaderContext().error(
|
||||
if (this.formLoginPage != null && this.openIDLoginPage != null) {
|
||||
this.pc.getReaderContext().error(
|
||||
"Only one login-page can be defined, either for OpenID or form-login, " + "but not both.",
|
||||
pc.extractSource(openIDLoginElt));
|
||||
this.pc.extractSource(openIDLoginElt));
|
||||
}
|
||||
|
||||
if (formFilterId != null && openIDLoginPage == null) {
|
||||
if (this.formFilterId != null && this.openIDLoginPage == null) {
|
||||
// gh-6802
|
||||
// If form login was enabled through element and Oauth2 login was enabled from
|
||||
// element then use form login
|
||||
if (formLoginElt != null && oauth2LoginEntryPoint != null) {
|
||||
return formEntryPoint;
|
||||
if (formLoginElt != null && this.oauth2LoginEntryPoint != null) {
|
||||
return this.formEntryPoint;
|
||||
}
|
||||
// If form login was enabled through auto-config, and Oauth2 login was not
|
||||
// enabled then use form login
|
||||
if (oauth2LoginEntryPoint == null) {
|
||||
return formEntryPoint;
|
||||
if (this.oauth2LoginEntryPoint == null) {
|
||||
return this.formEntryPoint;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise use OpenID if enabled
|
||||
if (openIDFilterId != null) {
|
||||
return openIDEntryPoint;
|
||||
if (this.openIDFilterId != null) {
|
||||
return this.openIDEntryPoint;
|
||||
}
|
||||
|
||||
// If X.509 or JEE have been enabled, use the preauth entry point.
|
||||
if (preAuthEntryPoint != null) {
|
||||
return preAuthEntryPoint;
|
||||
if (this.preAuthEntryPoint != null) {
|
||||
return this.preAuthEntryPoint;
|
||||
}
|
||||
|
||||
// OAuth2 entry point will not be null if only 1 client registration
|
||||
if (oauth2LoginEntryPoint != null) {
|
||||
return oauth2LoginEntryPoint;
|
||||
if (this.oauth2LoginEntryPoint != null) {
|
||||
return this.oauth2LoginEntryPoint;
|
||||
}
|
||||
|
||||
pc.getReaderContext().error("No AuthenticationEntryPoint could be established. Please "
|
||||
this.pc.getReaderContext().error("No AuthenticationEntryPoint could be established. Please "
|
||||
+ "make sure you have a login mechanism configured through the namespace (such as form-login) or "
|
||||
+ "specify a custom AuthenticationEntryPoint with the '" + ATT_ENTRY_POINT_REF + "' attribute ",
|
||||
pc.extractSource(httpElt));
|
||||
this.pc.extractSource(this.httpElt));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createUserDetailsServiceFactory() {
|
||||
if (pc.getRegistry().containsBeanDefinition(BeanIds.USER_DETAILS_SERVICE_FACTORY)) {
|
||||
if (this.pc.getRegistry().containsBeanDefinition(BeanIds.USER_DETAILS_SERVICE_FACTORY)) {
|
||||
// Multiple <http> case
|
||||
return;
|
||||
}
|
||||
RootBeanDefinition bean = new RootBeanDefinition(UserDetailsServiceFactoryBean.class);
|
||||
bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(bean, BeanIds.USER_DETAILS_SERVICE_FACTORY));
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(bean, BeanIds.USER_DETAILS_SERVICE_FACTORY));
|
||||
}
|
||||
|
||||
List<OrderDecorator> getFilters() {
|
||||
List<OrderDecorator> filters = new ArrayList<>();
|
||||
|
||||
if (anonymousFilter != null) {
|
||||
filters.add(new OrderDecorator(anonymousFilter, ANONYMOUS_FILTER));
|
||||
if (this.anonymousFilter != null) {
|
||||
filters.add(new OrderDecorator(this.anonymousFilter, ANONYMOUS_FILTER));
|
||||
}
|
||||
|
||||
if (rememberMeFilter != null) {
|
||||
filters.add(new OrderDecorator(rememberMeFilter, REMEMBER_ME_FILTER));
|
||||
if (this.rememberMeFilter != null) {
|
||||
filters.add(new OrderDecorator(this.rememberMeFilter, REMEMBER_ME_FILTER));
|
||||
}
|
||||
|
||||
if (logoutFilter != null) {
|
||||
filters.add(new OrderDecorator(logoutFilter, LOGOUT_FILTER));
|
||||
if (this.logoutFilter != null) {
|
||||
filters.add(new OrderDecorator(this.logoutFilter, LOGOUT_FILTER));
|
||||
}
|
||||
|
||||
if (x509Filter != null) {
|
||||
filters.add(new OrderDecorator(x509Filter, X509_FILTER));
|
||||
if (this.x509Filter != null) {
|
||||
filters.add(new OrderDecorator(this.x509Filter, X509_FILTER));
|
||||
}
|
||||
|
||||
if (jeeFilter != null) {
|
||||
filters.add(new OrderDecorator(jeeFilter, PRE_AUTH_FILTER));
|
||||
if (this.jeeFilter != null) {
|
||||
filters.add(new OrderDecorator(this.jeeFilter, PRE_AUTH_FILTER));
|
||||
}
|
||||
|
||||
if (formFilterId != null) {
|
||||
filters.add(new OrderDecorator(new RuntimeBeanReference(formFilterId), FORM_LOGIN_FILTER));
|
||||
if (this.formFilterId != null) {
|
||||
filters.add(new OrderDecorator(new RuntimeBeanReference(this.formFilterId), FORM_LOGIN_FILTER));
|
||||
}
|
||||
|
||||
if (oauth2LoginFilterId != null) {
|
||||
filters.add(new OrderDecorator(new RuntimeBeanReference(oauth2LoginFilterId), OAUTH2_LOGIN_FILTER));
|
||||
filters.add(
|
||||
new OrderDecorator(oauth2AuthorizationRequestRedirectFilter, OAUTH2_AUTHORIZATION_REQUEST_FILTER));
|
||||
if (this.oauth2LoginFilterId != null) {
|
||||
filters.add(new OrderDecorator(new RuntimeBeanReference(this.oauth2LoginFilterId), OAUTH2_LOGIN_FILTER));
|
||||
filters.add(new OrderDecorator(this.oauth2AuthorizationRequestRedirectFilter,
|
||||
OAUTH2_AUTHORIZATION_REQUEST_FILTER));
|
||||
}
|
||||
|
||||
if (openIDFilterId != null) {
|
||||
filters.add(new OrderDecorator(new RuntimeBeanReference(openIDFilterId), OPENID_FILTER));
|
||||
if (this.openIDFilterId != null) {
|
||||
filters.add(new OrderDecorator(new RuntimeBeanReference(this.openIDFilterId), OPENID_FILTER));
|
||||
}
|
||||
|
||||
if (loginPageGenerationFilter != null) {
|
||||
filters.add(new OrderDecorator(loginPageGenerationFilter, LOGIN_PAGE_FILTER));
|
||||
if (this.loginPageGenerationFilter != null) {
|
||||
filters.add(new OrderDecorator(this.loginPageGenerationFilter, LOGIN_PAGE_FILTER));
|
||||
filters.add(new OrderDecorator(this.logoutPageGenerationFilter, LOGOUT_PAGE_FILTER));
|
||||
}
|
||||
|
||||
if (basicFilter != null) {
|
||||
filters.add(new OrderDecorator(basicFilter, BASIC_AUTH_FILTER));
|
||||
if (this.basicFilter != null) {
|
||||
filters.add(new OrderDecorator(this.basicFilter, BASIC_AUTH_FILTER));
|
||||
}
|
||||
|
||||
if (bearerTokenAuthenticationFilter != null) {
|
||||
filters.add(new OrderDecorator(bearerTokenAuthenticationFilter, BEARER_TOKEN_AUTH_FILTER));
|
||||
if (this.bearerTokenAuthenticationFilter != null) {
|
||||
filters.add(new OrderDecorator(this.bearerTokenAuthenticationFilter, BEARER_TOKEN_AUTH_FILTER));
|
||||
}
|
||||
|
||||
if (authorizationCodeGrantFilter != null) {
|
||||
filters.add(new OrderDecorator(authorizationRequestRedirectFilter,
|
||||
if (this.authorizationCodeGrantFilter != null) {
|
||||
filters.add(new OrderDecorator(this.authorizationRequestRedirectFilter,
|
||||
OAUTH2_AUTHORIZATION_REQUEST_FILTER.getOrder() + 1));
|
||||
filters.add(new OrderDecorator(authorizationCodeGrantFilter, OAUTH2_AUTHORIZATION_CODE_GRANT_FILTER));
|
||||
filters.add(new OrderDecorator(this.authorizationCodeGrantFilter, OAUTH2_AUTHORIZATION_CODE_GRANT_FILTER));
|
||||
}
|
||||
|
||||
filters.add(new OrderDecorator(etf, EXCEPTION_TRANSLATION_FILTER));
|
||||
filters.add(new OrderDecorator(this.etf, EXCEPTION_TRANSLATION_FILTER));
|
||||
|
||||
return filters;
|
||||
}
|
||||
@@ -1049,36 +1052,36 @@ final class AuthenticationConfigBuilder {
|
||||
List<BeanReference> getProviders() {
|
||||
List<BeanReference> providers = new ArrayList<>();
|
||||
|
||||
if (anonymousProviderRef != null) {
|
||||
providers.add(anonymousProviderRef);
|
||||
if (this.anonymousProviderRef != null) {
|
||||
providers.add(this.anonymousProviderRef);
|
||||
}
|
||||
|
||||
if (rememberMeProviderRef != null) {
|
||||
providers.add(rememberMeProviderRef);
|
||||
if (this.rememberMeProviderRef != null) {
|
||||
providers.add(this.rememberMeProviderRef);
|
||||
}
|
||||
|
||||
if (openIDProviderRef != null) {
|
||||
providers.add(openIDProviderRef);
|
||||
if (this.openIDProviderRef != null) {
|
||||
providers.add(this.openIDProviderRef);
|
||||
}
|
||||
|
||||
if (x509ProviderRef != null) {
|
||||
providers.add(x509ProviderRef);
|
||||
if (this.x509ProviderRef != null) {
|
||||
providers.add(this.x509ProviderRef);
|
||||
}
|
||||
|
||||
if (jeeProviderRef != null) {
|
||||
providers.add(jeeProviderRef);
|
||||
if (this.jeeProviderRef != null) {
|
||||
providers.add(this.jeeProviderRef);
|
||||
}
|
||||
|
||||
if (oauth2LoginAuthenticationProviderRef != null) {
|
||||
providers.add(oauth2LoginAuthenticationProviderRef);
|
||||
if (this.oauth2LoginAuthenticationProviderRef != null) {
|
||||
providers.add(this.oauth2LoginAuthenticationProviderRef);
|
||||
}
|
||||
|
||||
if (oauth2LoginOidcAuthenticationProviderRef != null) {
|
||||
providers.add(oauth2LoginOidcAuthenticationProviderRef);
|
||||
if (this.oauth2LoginOidcAuthenticationProviderRef != null) {
|
||||
providers.add(this.oauth2LoginOidcAuthenticationProviderRef);
|
||||
}
|
||||
|
||||
if (authorizationCodeAuthenticationProviderRef != null) {
|
||||
providers.add(authorizationCodeAuthenticationProviderRef);
|
||||
if (this.authorizationCodeAuthenticationProviderRef != null) {
|
||||
providers.add(this.authorizationCodeAuthenticationProviderRef);
|
||||
}
|
||||
|
||||
providers.addAll(this.authenticationProviders);
|
||||
|
||||
@@ -123,7 +123,7 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
for (int j = i + 1; j < filters.size(); j++) {
|
||||
Filter f2 = filters.get(j);
|
||||
if (clazz.isAssignableFrom(f2.getClass())) {
|
||||
logger.warn("Possible error: Filters at position " + i + " and " + j + " are both "
|
||||
this.logger.warn("Possible error: Filters at position " + i + " and " + j + " are both "
|
||||
+ "instances of " + clazz.getName());
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
}
|
||||
|
||||
String loginPage = ((LoginUrlAuthenticationEntryPoint) etf.getAuthenticationEntryPoint()).getLoginFormUrl();
|
||||
logger.info("Checking whether login URL '" + loginPage + "' is accessible with your configuration");
|
||||
this.logger.info("Checking whether login URL '" + loginPage + "' is accessible with your configuration");
|
||||
FilterInvocation loginRequest = new FilterInvocation(loginPage, "POST");
|
||||
List<Filter> filters = null;
|
||||
|
||||
@@ -155,16 +155,16 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
// May happen legitimately if a filter-chain request matcher requires more
|
||||
// request data than that provided
|
||||
// by the dummy request used when creating the filter invocation.
|
||||
logger.info("Failed to obtain filter chain information for the login page. Unable to complete check.");
|
||||
this.logger.info("Failed to obtain filter chain information for the login page. Unable to complete check.");
|
||||
}
|
||||
|
||||
if (filters == null || filters.isEmpty()) {
|
||||
logger.debug("Filter chain is empty for the login page");
|
||||
this.logger.debug("Filter chain is empty for the login page");
|
||||
return;
|
||||
}
|
||||
|
||||
if (getFilter(DefaultLoginPageGeneratingFilter.class, filters) != null) {
|
||||
logger.debug("Default generated login page is in use");
|
||||
this.logger.debug("Default generated login page is in use");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,9 +174,9 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
Collection<ConfigAttribute> attributes = fids.getAttributes(loginRequest);
|
||||
|
||||
if (attributes == null) {
|
||||
logger.debug("No access attributes defined for login page URL");
|
||||
this.logger.debug("No access attributes defined for login page URL");
|
||||
if (fsi.isRejectPublicInvocations()) {
|
||||
logger.warn("FilterSecurityInterceptor is configured to reject public invocations."
|
||||
this.logger.warn("FilterSecurityInterceptor is configured to reject public invocations."
|
||||
+ " Your login page may not be accessible.");
|
||||
}
|
||||
return;
|
||||
@@ -184,7 +184,7 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
|
||||
AnonymousAuthenticationFilter anonPF = getFilter(AnonymousAuthenticationFilter.class, filters);
|
||||
if (anonPF == null) {
|
||||
logger.warn("The login page is being protected by the filter chain, but you don't appear to have"
|
||||
this.logger.warn("The login page is being protected by the filter chain, but you don't appear to have"
|
||||
+ " anonymous authentication enabled. This is almost certainly an error.");
|
||||
return;
|
||||
}
|
||||
@@ -196,15 +196,16 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
|
||||
fsi.getAccessDecisionManager().decide(token, loginRequest, attributes);
|
||||
}
|
||||
catch (AccessDeniedException e) {
|
||||
logger.warn("Anonymous access to the login page doesn't appear to be enabled. This is almost certainly "
|
||||
+ "an error. Please check your configuration allows unauthenticated access to the configured "
|
||||
+ "login page. (Simulated access was rejected: " + e + ")");
|
||||
this.logger
|
||||
.warn("Anonymous access to the login page doesn't appear to be enabled. This is almost certainly "
|
||||
+ "an error. Please check your configuration allows unauthenticated access to the configured "
|
||||
+ "login page. (Simulated access was rejected: " + e + ")");
|
||||
}
|
||||
catch (Exception e) {
|
||||
// May happen legitimately if a filter-chain request matcher requires more
|
||||
// request data than that provided
|
||||
// by the dummy request used when creating the filter invocation. See SEC-1878
|
||||
logger.info(
|
||||
this.logger.info(
|
||||
"Unable to check access to the login page to determine if anonymous access is allowed. This might be an error, but can happen under normal circumstances.",
|
||||
e);
|
||||
}
|
||||
|
||||
@@ -224,8 +224,8 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit
|
||||
private DefaultWebSecurityExpressionHandler handler = new DefaultWebSecurityExpressionHandler();
|
||||
|
||||
public DefaultWebSecurityExpressionHandler getBean() {
|
||||
handler.setDefaultRolePrefix(this.rolePrefix);
|
||||
return handler;
|
||||
this.handler.setDefaultRolePrefix(this.rolePrefix);
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class FormLoginBeanDefinitionParser {
|
||||
authenticationFailureUrl = elt.getAttribute(ATT_FORM_LOGIN_AUTHENTICATION_FAILURE_URL);
|
||||
WebConfigUtils.validateHttpRedirect(authenticationFailureUrl, pc, source);
|
||||
alwaysUseDefault = elt.getAttribute(ATT_ALWAYS_USE_DEFAULT_TARGET_URL);
|
||||
loginPage = elt.getAttribute(ATT_LOGIN_PAGE);
|
||||
this.loginPage = elt.getAttribute(ATT_LOGIN_PAGE);
|
||||
successHandlerRef = elt.getAttribute(ATT_SUCCESS_HANDLER_REF);
|
||||
failureHandlerRef = elt.getAttribute(ATT_FAILURE_HANDLER_REF);
|
||||
authDetailsSourceRef = elt.getAttribute(AuthenticationConfigBuilder.ATT_AUTH_DETAILS_SOURCE_REF);
|
||||
@@ -143,34 +143,34 @@ public class FormLoginBeanDefinitionParser {
|
||||
authenticationSuccessForwardUrl = elt.getAttribute(ATT_FORM_LOGIN_AUTHENTICATION_SUCCESS_FORWARD_URL);
|
||||
WebConfigUtils.validateHttpRedirect(authenticationSuccessForwardUrl, pc, source);
|
||||
|
||||
if (!StringUtils.hasText(loginPage)) {
|
||||
loginPage = null;
|
||||
if (!StringUtils.hasText(this.loginPage)) {
|
||||
this.loginPage = null;
|
||||
}
|
||||
WebConfigUtils.validateHttpRedirect(loginPage, pc, source);
|
||||
WebConfigUtils.validateHttpRedirect(this.loginPage, pc, source);
|
||||
usernameParameter = elt.getAttribute(ATT_USERNAME_PARAMETER);
|
||||
passwordParameter = elt.getAttribute(ATT_PASSWORD_PARAMETER);
|
||||
}
|
||||
|
||||
filterBean = createFilterBean(loginUrl, defaultTargetUrl, alwaysUseDefault, loginPage, authenticationFailureUrl,
|
||||
successHandlerRef, failureHandlerRef, authDetailsSourceRef, authenticationFailureForwardUrl,
|
||||
authenticationSuccessForwardUrl);
|
||||
this.filterBean = createFilterBean(loginUrl, defaultTargetUrl, alwaysUseDefault, this.loginPage,
|
||||
authenticationFailureUrl, successHandlerRef, failureHandlerRef, authDetailsSourceRef,
|
||||
authenticationFailureForwardUrl, authenticationSuccessForwardUrl);
|
||||
|
||||
if (StringUtils.hasText(usernameParameter)) {
|
||||
filterBean.getPropertyValues().addPropertyValue("usernameParameter", usernameParameter);
|
||||
this.filterBean.getPropertyValues().addPropertyValue("usernameParameter", usernameParameter);
|
||||
}
|
||||
if (StringUtils.hasText(passwordParameter)) {
|
||||
filterBean.getPropertyValues().addPropertyValue("passwordParameter", passwordParameter);
|
||||
this.filterBean.getPropertyValues().addPropertyValue("passwordParameter", passwordParameter);
|
||||
}
|
||||
|
||||
filterBean.setSource(source);
|
||||
this.filterBean.setSource(source);
|
||||
|
||||
BeanDefinitionBuilder entryPointBuilder = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(LoginUrlAuthenticationEntryPoint.class);
|
||||
entryPointBuilder.getRawBeanDefinition().setSource(source);
|
||||
entryPointBuilder.addConstructorArgValue(loginPage != null ? loginPage : DEF_LOGIN_PAGE);
|
||||
entryPointBuilder.addPropertyValue("portMapper", portMapper);
|
||||
entryPointBuilder.addPropertyValue("portResolver", portResolver);
|
||||
entryPointBean = (RootBeanDefinition) entryPointBuilder.getBeanDefinition();
|
||||
entryPointBuilder.addConstructorArgValue(this.loginPage != null ? this.loginPage : DEF_LOGIN_PAGE);
|
||||
entryPointBuilder.addPropertyValue("portMapper", this.portMapper);
|
||||
entryPointBuilder.addPropertyValue("portResolver", this.portResolver);
|
||||
this.entryPointBean = (RootBeanDefinition) entryPointBuilder.getBeanDefinition();
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -180,10 +180,10 @@ public class FormLoginBeanDefinitionParser {
|
||||
String authDetailsSourceRef, String authenticationFailureForwardUrl,
|
||||
String authenticationSuccessForwardUrl) {
|
||||
|
||||
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.rootBeanDefinition(filterClassName);
|
||||
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.rootBeanDefinition(this.filterClassName);
|
||||
|
||||
if (!StringUtils.hasText(loginUrl)) {
|
||||
loginUrl = defaultLoginProcessingUrl;
|
||||
loginUrl = this.defaultLoginProcessingUrl;
|
||||
}
|
||||
|
||||
this.loginProcessingUrl = loginUrl;
|
||||
@@ -191,7 +191,7 @@ public class FormLoginBeanDefinitionParser {
|
||||
BeanDefinitionBuilder matcherBuilder = BeanDefinitionBuilder
|
||||
.rootBeanDefinition("org.springframework.security.web.util.matcher.AntPathRequestMatcher");
|
||||
matcherBuilder.addConstructorArgValue(loginUrl);
|
||||
if (loginMethod != null) {
|
||||
if (this.loginMethod != null) {
|
||||
matcherBuilder.addConstructorArgValue("POST");
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public class FormLoginBeanDefinitionParser {
|
||||
if ("true".equals(alwaysUseDefault)) {
|
||||
successHandler.addPropertyValue("alwaysUseDefaultTargetUrl", Boolean.TRUE);
|
||||
}
|
||||
successHandler.addPropertyValue("requestCache", requestCache);
|
||||
successHandler.addPropertyValue("requestCache", this.requestCache);
|
||||
successHandler.addPropertyValue("defaultTargetUrl",
|
||||
StringUtils.hasText(defaultTargetUrl) ? defaultTargetUrl : DEF_FORM_LOGIN_TARGET_URL);
|
||||
filterBuilder.addPropertyValue("authenticationSuccessHandler", successHandler.getBeanDefinition());
|
||||
@@ -222,8 +222,8 @@ public class FormLoginBeanDefinitionParser {
|
||||
filterBuilder.addPropertyReference("authenticationDetailsSource", authDetailsSourceRef);
|
||||
}
|
||||
|
||||
if (sessionStrategy != null) {
|
||||
filterBuilder.addPropertyValue("sessionAuthenticationStrategy", sessionStrategy);
|
||||
if (this.sessionStrategy != null) {
|
||||
filterBuilder.addPropertyValue("sessionAuthenticationStrategy", this.sessionStrategy);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(failureHandlerRef)) {
|
||||
@@ -248,7 +248,7 @@ public class FormLoginBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
failureHandler.addPropertyValue("defaultFailureUrl", authenticationFailureUrl);
|
||||
failureHandler.addPropertyValue("allowSessionCreation", allowSessionCreation);
|
||||
failureHandler.addPropertyValue("allowSessionCreation", this.allowSessionCreation);
|
||||
filterBuilder.addPropertyValue("authenticationFailureHandler", failureHandler.getBeanDefinition());
|
||||
}
|
||||
|
||||
@@ -256,19 +256,19 @@ public class FormLoginBeanDefinitionParser {
|
||||
}
|
||||
|
||||
RootBeanDefinition getFilterBean() {
|
||||
return filterBean;
|
||||
return this.filterBean;
|
||||
}
|
||||
|
||||
RootBeanDefinition getEntryPointBean() {
|
||||
return entryPointBean;
|
||||
return this.entryPointBean;
|
||||
}
|
||||
|
||||
String getLoginPage() {
|
||||
return loginPage;
|
||||
return this.loginPage;
|
||||
}
|
||||
|
||||
String getLoginProcessingUrl() {
|
||||
return loginProcessingUrl;
|
||||
return this.loginProcessingUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
|
||||
headerWriters = new ManagedList<>();
|
||||
this.headerWriters = new ManagedList<>();
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(HeaderWriterFilter.class);
|
||||
|
||||
boolean disabled = element != null && "true".equals(resolveAttribute(parserContext, element, "disabled"));
|
||||
@@ -150,7 +150,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
parseHeaderElements(element);
|
||||
|
||||
boolean noWriters = headerWriters.isEmpty();
|
||||
boolean noWriters = this.headerWriters.isEmpty();
|
||||
if (disabled && !noWriters) {
|
||||
parserContext.getReaderContext().error("Cannot specify <headers disabled=\"true\"> with child elements.",
|
||||
element);
|
||||
@@ -159,7 +159,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
return null;
|
||||
}
|
||||
|
||||
builder.addConstructorArgValue(headerWriters);
|
||||
builder.addConstructorArgValue(this.headerWriters);
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
private void addCacheControl() {
|
||||
BeanDefinitionBuilder headersWriter = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(CacheControlHeadersWriter.class);
|
||||
headerWriters.add(headersWriter.getBeanDefinition());
|
||||
this.headerWriters.add(headersWriter.getBeanDefinition());
|
||||
}
|
||||
|
||||
private void parseHstsElement(boolean addIfNotPresent, Element element, ParserContext context) {
|
||||
@@ -238,7 +238,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
if (addIfNotPresent || hstsElement != null) {
|
||||
headerWriters.add(headersWriter.getBeanDefinition());
|
||||
this.headerWriters.add(headersWriter.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
if (addIfNotPresent) {
|
||||
headerWriters.add(headersWriter.getBeanDefinition());
|
||||
this.headerWriters.add(headersWriter.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
headersWriter.addPropertyValue("reportOnly", reportOnly);
|
||||
}
|
||||
|
||||
headerWriters.add(headersWriter.getBeanDefinition());
|
||||
this.headerWriters.add(headersWriter.getBeanDefinition());
|
||||
}
|
||||
|
||||
private void parseReferrerPolicyElement(Element element, ParserContext context) {
|
||||
@@ -356,7 +356,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
if (StringUtils.hasLength(policy)) {
|
||||
headersWriter.addConstructorArgValue(ReferrerPolicy.get(policy));
|
||||
}
|
||||
headerWriters.add(headersWriter.getBeanDefinition());
|
||||
this.headerWriters.add(headersWriter.getBeanDefinition());
|
||||
}
|
||||
|
||||
private void parseFeaturePolicyElement(Element element, ParserContext context) {
|
||||
@@ -380,7 +380,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
headersWriter.addConstructorArgValue(policyDirectives);
|
||||
}
|
||||
|
||||
headerWriters.add(headersWriter.getBeanDefinition());
|
||||
this.headerWriters.add(headersWriter.getBeanDefinition());
|
||||
}
|
||||
|
||||
private void attrNotAllowed(ParserContext context, String attrName, String otherAttrName, Element element) {
|
||||
@@ -394,13 +394,13 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
for (Element headerElt : headerElts) {
|
||||
String headerFactoryRef = headerElt.getAttribute(ATT_REF);
|
||||
if (StringUtils.hasText(headerFactoryRef)) {
|
||||
headerWriters.add(new RuntimeBeanReference(headerFactoryRef));
|
||||
this.headerWriters.add(new RuntimeBeanReference(headerFactoryRef));
|
||||
}
|
||||
else {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(StaticHeadersWriter.class);
|
||||
builder.addConstructorArgValue(headerElt.getAttribute(ATT_NAME));
|
||||
builder.addConstructorArgValue(headerElt.getAttribute(ATT_VALUE));
|
||||
headerWriters.add(builder.getBeanDefinition());
|
||||
this.headerWriters.add(builder.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -420,7 +420,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
private void addContentTypeOptions() {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(XContentTypeOptionsHeaderWriter.class);
|
||||
headerWriters.add(builder.getBeanDefinition());
|
||||
this.headerWriters.add(builder.getBeanDefinition());
|
||||
}
|
||||
|
||||
private void parseFrameOptionsElement(boolean addIfNotPresent, Element element, ParserContext parserContext) {
|
||||
@@ -495,7 +495,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
if (addIfNotPresent || frameElt != null) {
|
||||
headerWriters.add(builder.getBeanDefinition());
|
||||
this.headerWriters.add(builder.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
if (addIfNotPresent || xssElt != null) {
|
||||
headerWriters.add(builder.getBeanDefinition());
|
||||
this.headerWriters.add(builder.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,9 +194,9 @@ class HttpConfigurationBuilder {
|
||||
this.portMapper = portMapper;
|
||||
this.portResolver = portResolver;
|
||||
this.matcherType = MatcherType.fromElement(element);
|
||||
interceptUrls = DomUtils.getChildElementsByTagName(element, Elements.INTERCEPT_URL);
|
||||
this.interceptUrls = DomUtils.getChildElementsByTagName(element, Elements.INTERCEPT_URL);
|
||||
|
||||
for (Element urlElt : interceptUrls) {
|
||||
for (Element urlElt : this.interceptUrls) {
|
||||
if (StringUtils.hasText(urlElt.getAttribute(ATT_FILTERS))) {
|
||||
pc.getReaderContext()
|
||||
.error("The use of \"filters='none'\" is no longer supported. Please define a"
|
||||
@@ -208,10 +208,10 @@ class HttpConfigurationBuilder {
|
||||
String createSession = element.getAttribute(ATT_CREATE_SESSION);
|
||||
|
||||
if (StringUtils.hasText(createSession)) {
|
||||
sessionPolicy = createPolicy(createSession);
|
||||
this.sessionPolicy = createPolicy(createSession);
|
||||
}
|
||||
else {
|
||||
sessionPolicy = SessionCreationPolicy.IF_REQUIRED;
|
||||
this.sessionPolicy = SessionCreationPolicy.IF_REQUIRED;
|
||||
}
|
||||
|
||||
createCsrfFilter();
|
||||
@@ -248,30 +248,30 @@ class HttpConfigurationBuilder {
|
||||
@SuppressWarnings("rawtypes")
|
||||
void setLogoutHandlers(ManagedList logoutHandlers) {
|
||||
if (logoutHandlers != null) {
|
||||
if (concurrentSessionFilter != null) {
|
||||
concurrentSessionFilter.getPropertyValues().add("logoutHandlers", logoutHandlers);
|
||||
if (this.concurrentSessionFilter != null) {
|
||||
this.concurrentSessionFilter.getPropertyValues().add("logoutHandlers", logoutHandlers);
|
||||
}
|
||||
if (servApiFilter != null) {
|
||||
servApiFilter.getPropertyValues().add("logoutHandlers", logoutHandlers);
|
||||
if (this.servApiFilter != null) {
|
||||
this.servApiFilter.getPropertyValues().add("logoutHandlers", logoutHandlers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setEntryPoint(BeanMetadataElement entryPoint) {
|
||||
if (servApiFilter != null) {
|
||||
servApiFilter.getPropertyValues().add("authenticationEntryPoint", entryPoint);
|
||||
if (this.servApiFilter != null) {
|
||||
this.servApiFilter.getPropertyValues().add("authenticationEntryPoint", entryPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void setAccessDeniedHandler(BeanMetadataElement accessDeniedHandler) {
|
||||
if (csrfParser != null) {
|
||||
csrfParser.initAccessDeniedHandler(this.invalidSession, accessDeniedHandler);
|
||||
if (this.csrfParser != null) {
|
||||
this.csrfParser.initAccessDeniedHandler(this.invalidSession, accessDeniedHandler);
|
||||
}
|
||||
}
|
||||
|
||||
void setCsrfIgnoreRequestMatchers(List<BeanDefinition> requestMatchers) {
|
||||
if (csrfParser != null) {
|
||||
csrfParser.setIgnoreCsrfRequestMatchers(requestMatchers);
|
||||
if (this.csrfParser != null) {
|
||||
this.csrfParser.setIgnoreCsrfRequestMatchers(requestMatchers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,25 +283,25 @@ class HttpConfigurationBuilder {
|
||||
private void createSecurityContextPersistenceFilter() {
|
||||
BeanDefinitionBuilder scpf = BeanDefinitionBuilder.rootBeanDefinition(SecurityContextPersistenceFilter.class);
|
||||
|
||||
String repoRef = httpElt.getAttribute(ATT_SECURITY_CONTEXT_REPOSITORY);
|
||||
String disableUrlRewriting = httpElt.getAttribute(ATT_DISABLE_URL_REWRITING);
|
||||
String repoRef = this.httpElt.getAttribute(ATT_SECURITY_CONTEXT_REPOSITORY);
|
||||
String disableUrlRewriting = this.httpElt.getAttribute(ATT_DISABLE_URL_REWRITING);
|
||||
if (!StringUtils.hasText(disableUrlRewriting)) {
|
||||
disableUrlRewriting = "true";
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(repoRef)) {
|
||||
if (sessionPolicy == SessionCreationPolicy.ALWAYS) {
|
||||
if (this.sessionPolicy == SessionCreationPolicy.ALWAYS) {
|
||||
scpf.addPropertyValue("forceEagerSessionCreation", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BeanDefinitionBuilder contextRepo;
|
||||
if (sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
if (this.sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
contextRepo = BeanDefinitionBuilder.rootBeanDefinition(NullSecurityContextRepository.class);
|
||||
}
|
||||
else {
|
||||
contextRepo = BeanDefinitionBuilder.rootBeanDefinition(HttpSessionSecurityContextRepository.class);
|
||||
switch (sessionPolicy) {
|
||||
switch (this.sessionPolicy) {
|
||||
case ALWAYS:
|
||||
contextRepo.addPropertyValue("allowSessionCreation", Boolean.TRUE);
|
||||
scpf.addPropertyValue("forceEagerSessionCreation", Boolean.TRUE);
|
||||
@@ -321,18 +321,18 @@ class HttpConfigurationBuilder {
|
||||
}
|
||||
|
||||
BeanDefinition repoBean = contextRepo.getBeanDefinition();
|
||||
repoRef = pc.getReaderContext().generateBeanName(repoBean);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(repoBean, repoRef));
|
||||
repoRef = this.pc.getReaderContext().generateBeanName(repoBean);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(repoBean, repoRef));
|
||||
}
|
||||
|
||||
contextRepoRef = new RuntimeBeanReference(repoRef);
|
||||
scpf.addConstructorArgValue(contextRepoRef);
|
||||
this.contextRepoRef = new RuntimeBeanReference(repoRef);
|
||||
scpf.addConstructorArgValue(this.contextRepoRef);
|
||||
|
||||
securityContextPersistenceFilter = scpf.getBeanDefinition();
|
||||
this.securityContextPersistenceFilter = scpf.getBeanDefinition();
|
||||
}
|
||||
|
||||
private void createSessionManagementFilters() {
|
||||
Element sessionMgmtElt = DomUtils.getChildElementByTagName(httpElt, Elements.SESSION_MANAGEMENT);
|
||||
Element sessionMgmtElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.SESSION_MANAGEMENT);
|
||||
Element sessionCtrlElt = null;
|
||||
|
||||
String sessionFixationAttribute = null;
|
||||
@@ -343,11 +343,11 @@ class HttpConfigurationBuilder {
|
||||
|
||||
boolean sessionControlEnabled = false;
|
||||
if (sessionMgmtElt != null) {
|
||||
if (sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
pc.getReaderContext()
|
||||
if (this.sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
this.pc.getReaderContext()
|
||||
.error(Elements.SESSION_MANAGEMENT + " cannot be used" + " in combination with "
|
||||
+ ATT_CREATE_SESSION + "='" + SessionCreationPolicy.STATELESS + "'",
|
||||
pc.extractSource(sessionMgmtElt));
|
||||
this.pc.extractSource(sessionMgmtElt));
|
||||
}
|
||||
sessionFixationAttribute = sessionMgmtElt.getAttribute(ATT_SESSION_FIXATION_PROTECTION);
|
||||
invalidSessionUrl = sessionMgmtElt.getAttribute(ATT_INVALID_SESSION_URL);
|
||||
@@ -359,16 +359,17 @@ class HttpConfigurationBuilder {
|
||||
sessionControlEnabled = sessionCtrlElt != null;
|
||||
|
||||
if (StringUtils.hasText(invalidSessionUrl) && StringUtils.hasText(invalidSessionStrategyRef)) {
|
||||
pc.getReaderContext().error(ATT_INVALID_SESSION_URL + " attribute cannot be used in combination with"
|
||||
+ " the " + ATT_INVALID_SESSION_STRATEGY_REF + " attribute.", sessionMgmtElt);
|
||||
this.pc.getReaderContext()
|
||||
.error(ATT_INVALID_SESSION_URL + " attribute cannot be used in combination with" + " the "
|
||||
+ ATT_INVALID_SESSION_STRATEGY_REF + " attribute.", sessionMgmtElt);
|
||||
}
|
||||
|
||||
if (sessionControlEnabled) {
|
||||
if (StringUtils.hasText(sessionAuthStratRef)) {
|
||||
pc.getReaderContext()
|
||||
this.pc.getReaderContext()
|
||||
.error(ATT_SESSION_AUTH_STRATEGY_REF + " attribute cannot be used"
|
||||
+ " in combination with <" + Elements.CONCURRENT_SESSIONS + ">",
|
||||
pc.extractSource(sessionCtrlElt));
|
||||
this.pc.extractSource(sessionCtrlElt));
|
||||
}
|
||||
createConcurrencyControlFilterAndSessionRegistry(sessionCtrlElt);
|
||||
}
|
||||
@@ -378,11 +379,11 @@ class HttpConfigurationBuilder {
|
||||
sessionFixationAttribute = OPT_CHANGE_SESSION_ID;
|
||||
}
|
||||
else if (StringUtils.hasText(sessionAuthStratRef)) {
|
||||
pc.getReaderContext().error(ATT_SESSION_FIXATION_PROTECTION + " attribute cannot be used"
|
||||
+ " in combination with " + ATT_SESSION_AUTH_STRATEGY_REF, pc.extractSource(sessionMgmtElt));
|
||||
this.pc.getReaderContext().error(ATT_SESSION_FIXATION_PROTECTION + " attribute cannot be used"
|
||||
+ " in combination with " + ATT_SESSION_AUTH_STRATEGY_REF, this.pc.extractSource(sessionMgmtElt));
|
||||
}
|
||||
|
||||
if (sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
if (this.sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
// SEC-1424: do nothing
|
||||
return;
|
||||
}
|
||||
@@ -395,15 +396,15 @@ class HttpConfigurationBuilder {
|
||||
BeanDefinitionBuilder sessionFixationStrategy = null;
|
||||
BeanDefinitionBuilder registerSessionStrategy;
|
||||
|
||||
if (csrfAuthStrategy != null) {
|
||||
delegateSessionStrategies.add(csrfAuthStrategy);
|
||||
if (this.csrfAuthStrategy != null) {
|
||||
delegateSessionStrategies.add(this.csrfAuthStrategy);
|
||||
}
|
||||
|
||||
if (sessionControlEnabled) {
|
||||
assert sessionRegistryRef != null;
|
||||
assert this.sessionRegistryRef != null;
|
||||
concurrentSessionStrategy = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(ConcurrentSessionControlAuthenticationStrategy.class);
|
||||
concurrentSessionStrategy.addConstructorArgValue(sessionRegistryRef);
|
||||
concurrentSessionStrategy.addConstructorArgValue(this.sessionRegistryRef);
|
||||
|
||||
String maxSessions = sessionCtrlElt.getAttribute("max-sessions");
|
||||
|
||||
@@ -438,12 +439,12 @@ class HttpConfigurationBuilder {
|
||||
if (sessionControlEnabled) {
|
||||
registerSessionStrategy = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(RegisterSessionAuthenticationStrategy.class);
|
||||
registerSessionStrategy.addConstructorArgValue(sessionRegistryRef);
|
||||
registerSessionStrategy.addConstructorArgValue(this.sessionRegistryRef);
|
||||
delegateSessionStrategies.add(registerSessionStrategy.getBeanDefinition());
|
||||
}
|
||||
|
||||
if (delegateSessionStrategies.isEmpty()) {
|
||||
sfpf = null;
|
||||
this.sfpf = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -454,7 +455,7 @@ class HttpConfigurationBuilder {
|
||||
failureHandler.getPropertyValues().addPropertyValue("defaultFailureUrl", errorUrl);
|
||||
}
|
||||
sessionMgmtFilter.addPropertyValue("authenticationFailureHandler", failureHandler);
|
||||
sessionMgmtFilter.addConstructorArgValue(contextRepoRef);
|
||||
sessionMgmtFilter.addConstructorArgValue(this.contextRepoRef);
|
||||
|
||||
if (!StringUtils.hasText(sessionAuthStratRef) && sessionFixationStrategy != null && !useChangeSessionId) {
|
||||
|
||||
@@ -469,8 +470,8 @@ class HttpConfigurationBuilder {
|
||||
.rootBeanDefinition(CompositeSessionAuthenticationStrategy.class);
|
||||
BeanDefinition strategyBean = sessionStrategy.getBeanDefinition();
|
||||
sessionStrategy.addConstructorArgValue(delegateSessionStrategies);
|
||||
sessionAuthStratRef = pc.getReaderContext().generateBeanName(strategyBean);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(strategyBean, sessionAuthStratRef));
|
||||
sessionAuthStratRef = this.pc.getReaderContext().generateBeanName(strategyBean);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(strategyBean, sessionAuthStratRef));
|
||||
|
||||
}
|
||||
|
||||
@@ -478,8 +479,8 @@ class HttpConfigurationBuilder {
|
||||
BeanDefinitionBuilder invalidSessionBldr = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(SimpleRedirectInvalidSessionStrategy.class);
|
||||
invalidSessionBldr.addConstructorArgValue(invalidSessionUrl);
|
||||
invalidSession = invalidSessionBldr.getBeanDefinition();
|
||||
sessionMgmtFilter.addPropertyValue("invalidSessionStrategy", invalidSession);
|
||||
this.invalidSession = invalidSessionBldr.getBeanDefinition();
|
||||
sessionMgmtFilter.addPropertyValue("invalidSessionStrategy", this.invalidSession);
|
||||
}
|
||||
else if (StringUtils.hasText(invalidSessionStrategyRef)) {
|
||||
sessionMgmtFilter.addPropertyReference("invalidSessionStrategy", invalidSessionStrategyRef);
|
||||
@@ -487,8 +488,8 @@ class HttpConfigurationBuilder {
|
||||
|
||||
sessionMgmtFilter.addConstructorArgReference(sessionAuthStratRef);
|
||||
|
||||
sfpf = (RootBeanDefinition) sessionMgmtFilter.getBeanDefinition();
|
||||
sessionStrategyRef = new RuntimeBeanReference(sessionAuthStratRef);
|
||||
this.sfpf = (RootBeanDefinition) sessionMgmtFilter.getBeanDefinition();
|
||||
this.sessionStrategyRef = new RuntimeBeanReference(sessionAuthStratRef);
|
||||
}
|
||||
|
||||
private void createConcurrencyControlFilterAndSessionRegistry(Element element) {
|
||||
@@ -498,18 +499,18 @@ class HttpConfigurationBuilder {
|
||||
final String ATT_SESSION_REGISTRY_REF = "session-registry-ref";
|
||||
|
||||
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(),
|
||||
pc.extractSource(element));
|
||||
pc.pushContainingComponent(compositeDef);
|
||||
this.pc.extractSource(element));
|
||||
this.pc.pushContainingComponent(compositeDef);
|
||||
|
||||
BeanDefinitionRegistry beanRegistry = pc.getRegistry();
|
||||
BeanDefinitionRegistry beanRegistry = this.pc.getRegistry();
|
||||
|
||||
String sessionRegistryId = element.getAttribute(ATT_SESSION_REGISTRY_REF);
|
||||
|
||||
if (!StringUtils.hasText(sessionRegistryId)) {
|
||||
// Register an internal SessionRegistryImpl if no external reference supplied.
|
||||
RootBeanDefinition sessionRegistry = new RootBeanDefinition(SessionRegistryImpl.class);
|
||||
sessionRegistryId = pc.getReaderContext().registerWithGeneratedName(sessionRegistry);
|
||||
pc.registerComponent(new BeanComponentDefinition(sessionRegistry, sessionRegistryId));
|
||||
sessionRegistryId = this.pc.getReaderContext().registerWithGeneratedName(sessionRegistry);
|
||||
this.pc.registerComponent(new BeanComponentDefinition(sessionRegistry, sessionRegistryId));
|
||||
}
|
||||
|
||||
String registryAlias = element.getAttribute(ATT_SESSION_REGISTRY_ALIAS);
|
||||
@@ -520,7 +521,7 @@ class HttpConfigurationBuilder {
|
||||
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.rootBeanDefinition(ConcurrentSessionFilter.class);
|
||||
filterBuilder.addConstructorArgReference(sessionRegistryId);
|
||||
|
||||
Object source = pc.extractSource(element);
|
||||
Object source = this.pc.extractSource(element);
|
||||
filterBuilder.getRawBeanDefinition().setSource(source);
|
||||
filterBuilder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
|
||||
@@ -528,7 +529,7 @@ class HttpConfigurationBuilder {
|
||||
String expiredSessionStrategyRef = element.getAttribute(ATT_EXPIRED_SESSION_STRATEGY_REF);
|
||||
|
||||
if (StringUtils.hasText(expiryUrl) && StringUtils.hasText(expiredSessionStrategyRef)) {
|
||||
pc.getReaderContext().error(
|
||||
this.pc.getReaderContext().error(
|
||||
"Cannot use 'expired-url' attribute and 'expired-session-strategy-ref'" + " attribute together.",
|
||||
source);
|
||||
}
|
||||
@@ -543,16 +544,16 @@ class HttpConfigurationBuilder {
|
||||
filterBuilder.addConstructorArgReference(expiredSessionStrategyRef);
|
||||
}
|
||||
|
||||
pc.popAndRegisterContainingComponent();
|
||||
this.pc.popAndRegisterContainingComponent();
|
||||
|
||||
concurrentSessionFilter = filterBuilder.getBeanDefinition();
|
||||
sessionRegistryRef = new RuntimeBeanReference(sessionRegistryId);
|
||||
this.concurrentSessionFilter = filterBuilder.getBeanDefinition();
|
||||
this.sessionRegistryRef = new RuntimeBeanReference(sessionRegistryId);
|
||||
}
|
||||
|
||||
private void createWebAsyncManagerFilter() {
|
||||
boolean asyncSupported = ClassUtils.hasMethod(ServletRequest.class, "startAsync");
|
||||
if (asyncSupported) {
|
||||
webAsyncManagerFilter = new RootBeanDefinition(WebAsyncManagerIntegrationFilter.class);
|
||||
this.webAsyncManagerFilter = new RootBeanDefinition(WebAsyncManagerIntegrationFilter.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,15 +562,15 @@ class HttpConfigurationBuilder {
|
||||
final String ATT_SERVLET_API_PROVISION = "servlet-api-provision";
|
||||
final String DEF_SERVLET_API_PROVISION = "true";
|
||||
|
||||
String provideServletApi = httpElt.getAttribute(ATT_SERVLET_API_PROVISION);
|
||||
String provideServletApi = this.httpElt.getAttribute(ATT_SERVLET_API_PROVISION);
|
||||
if (!StringUtils.hasText(provideServletApi)) {
|
||||
provideServletApi = DEF_SERVLET_API_PROVISION;
|
||||
}
|
||||
|
||||
if ("true".equals(provideServletApi)) {
|
||||
servApiFilter = GrantedAuthorityDefaultsParserUtils.registerWithDefaultRolePrefix(pc,
|
||||
this.servApiFilter = GrantedAuthorityDefaultsParserUtils.registerWithDefaultRolePrefix(this.pc,
|
||||
SecurityContextHolderAwareRequestFilterBeanFactory.class);
|
||||
servApiFilter.getPropertyValues().add("authenticationManager", authenticationManager);
|
||||
this.servApiFilter.getPropertyValues().add("authenticationManager", authenticationManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,13 +579,13 @@ class HttpConfigurationBuilder {
|
||||
final String ATT_JAAS_API_PROVISION = "jaas-api-provision";
|
||||
final String DEF_JAAS_API_PROVISION = "false";
|
||||
|
||||
String provideJaasApi = httpElt.getAttribute(ATT_JAAS_API_PROVISION);
|
||||
String provideJaasApi = this.httpElt.getAttribute(ATT_JAAS_API_PROVISION);
|
||||
if (!StringUtils.hasText(provideJaasApi)) {
|
||||
provideJaasApi = DEF_JAAS_API_PROVISION;
|
||||
}
|
||||
|
||||
if ("true".equals(provideJaasApi)) {
|
||||
jaasApiFilter = new RootBeanDefinition(JaasApiIntegrationFilter.class);
|
||||
this.jaasApiFilter = new RootBeanDefinition(JaasApiIntegrationFilter.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,10 +611,10 @@ class HttpConfigurationBuilder {
|
||||
RootBeanDefinition retryWithHttp = new RootBeanDefinition(RetryWithHttpEntryPoint.class);
|
||||
RootBeanDefinition retryWithHttps = new RootBeanDefinition(RetryWithHttpsEntryPoint.class);
|
||||
|
||||
retryWithHttp.getPropertyValues().addPropertyValue("portMapper", portMapper);
|
||||
retryWithHttp.getPropertyValues().addPropertyValue("portResolver", portResolver);
|
||||
retryWithHttps.getPropertyValues().addPropertyValue("portMapper", portMapper);
|
||||
retryWithHttps.getPropertyValues().addPropertyValue("portResolver", portResolver);
|
||||
retryWithHttp.getPropertyValues().addPropertyValue("portMapper", this.portMapper);
|
||||
retryWithHttp.getPropertyValues().addPropertyValue("portResolver", this.portResolver);
|
||||
retryWithHttps.getPropertyValues().addPropertyValue("portMapper", this.portMapper);
|
||||
retryWithHttps.getPropertyValues().addPropertyValue("portResolver", this.portResolver);
|
||||
secureChannelProcessor.getPropertyValues().addPropertyValue("entryPoint", retryWithHttps);
|
||||
RootBeanDefinition inSecureChannelProcessor = new RootBeanDefinition(InsecureChannelProcessor.class);
|
||||
inSecureChannelProcessor.getPropertyValues().addPropertyValue("entryPoint", retryWithHttp);
|
||||
@@ -621,9 +622,9 @@ class HttpConfigurationBuilder {
|
||||
channelProcessors.add(inSecureChannelProcessor);
|
||||
channelDecisionManager.getPropertyValues().addPropertyValue("channelProcessors", channelProcessors);
|
||||
|
||||
String id = pc.getReaderContext().registerWithGeneratedName(channelDecisionManager);
|
||||
String id = this.pc.getReaderContext().registerWithGeneratedName(channelDecisionManager);
|
||||
channelFilter.getPropertyValues().addPropertyValue("channelDecisionManager", new RuntimeBeanReference(id));
|
||||
cpf = channelFilter;
|
||||
this.cpf = channelFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -635,21 +636,21 @@ class HttpConfigurationBuilder {
|
||||
|
||||
ManagedMap<BeanMetadataElement, BeanDefinition> channelRequestMap = new ManagedMap<>();
|
||||
|
||||
for (Element urlElt : interceptUrls) {
|
||||
for (Element urlElt : this.interceptUrls) {
|
||||
String path = urlElt.getAttribute(ATT_PATH_PATTERN);
|
||||
String method = urlElt.getAttribute(ATT_HTTP_METHOD);
|
||||
String matcherRef = urlElt.getAttribute(ATT_REQUEST_MATCHER_REF);
|
||||
boolean hasMatcherRef = StringUtils.hasText(matcherRef);
|
||||
|
||||
if (!hasMatcherRef && !StringUtils.hasText(path)) {
|
||||
pc.getReaderContext().error("pattern attribute cannot be empty or null", urlElt);
|
||||
this.pc.getReaderContext().error("pattern attribute cannot be empty or null", urlElt);
|
||||
}
|
||||
|
||||
String requiredChannel = urlElt.getAttribute(ATT_REQUIRES_CHANNEL);
|
||||
|
||||
if (StringUtils.hasText(requiredChannel)) {
|
||||
BeanMetadataElement matcher = hasMatcherRef ? new RuntimeBeanReference(matcherRef)
|
||||
: matcherType.createMatcher(pc, path, method);
|
||||
: this.matcherType.createMatcher(this.pc, path, method);
|
||||
|
||||
RootBeanDefinition channelAttributes = new RootBeanDefinition(ChannelAttributeFactory.class);
|
||||
channelAttributes.getConstructorArgumentValues().addGenericArgumentValue(requiredChannel);
|
||||
@@ -663,23 +664,23 @@ class HttpConfigurationBuilder {
|
||||
}
|
||||
|
||||
private void createRequestCacheFilter() {
|
||||
Element requestCacheElt = DomUtils.getChildElementByTagName(httpElt, Elements.REQUEST_CACHE);
|
||||
Element requestCacheElt = DomUtils.getChildElementByTagName(this.httpElt, Elements.REQUEST_CACHE);
|
||||
|
||||
if (requestCacheElt != null) {
|
||||
requestCache = new RuntimeBeanReference(requestCacheElt.getAttribute(ATT_REF));
|
||||
this.requestCache = new RuntimeBeanReference(requestCacheElt.getAttribute(ATT_REF));
|
||||
}
|
||||
else {
|
||||
BeanDefinitionBuilder requestCacheBldr;
|
||||
|
||||
if (sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
if (this.sessionPolicy == SessionCreationPolicy.STATELESS) {
|
||||
requestCacheBldr = BeanDefinitionBuilder.rootBeanDefinition(NullRequestCache.class);
|
||||
}
|
||||
else {
|
||||
requestCacheBldr = BeanDefinitionBuilder.rootBeanDefinition(HttpSessionRequestCache.class);
|
||||
requestCacheBldr.addPropertyValue("createSessionAllowed",
|
||||
sessionPolicy == SessionCreationPolicy.IF_REQUIRED);
|
||||
requestCacheBldr.addPropertyValue("portResolver", portResolver);
|
||||
if (csrfFilter != null) {
|
||||
this.sessionPolicy == SessionCreationPolicy.IF_REQUIRED);
|
||||
requestCacheBldr.addPropertyValue("portResolver", this.portResolver);
|
||||
if (this.csrfFilter != null) {
|
||||
BeanDefinitionBuilder requestCacheMatcherBldr = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(AntPathRequestMatcher.class);
|
||||
requestCacheMatcherBldr.addConstructorArgValue("/**");
|
||||
@@ -689,20 +690,20 @@ class HttpConfigurationBuilder {
|
||||
}
|
||||
|
||||
BeanDefinition bean = requestCacheBldr.getBeanDefinition();
|
||||
String id = pc.getReaderContext().generateBeanName(bean);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(bean, id));
|
||||
String id = this.pc.getReaderContext().generateBeanName(bean);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(bean, id));
|
||||
|
||||
this.requestCache = new RuntimeBeanReference(id);
|
||||
}
|
||||
|
||||
requestCacheAwareFilter = new RootBeanDefinition(RequestCacheAwareFilter.class);
|
||||
requestCacheAwareFilter.getConstructorArgumentValues().addGenericArgumentValue(requestCache);
|
||||
this.requestCacheAwareFilter = new RootBeanDefinition(RequestCacheAwareFilter.class);
|
||||
this.requestCacheAwareFilter.getConstructorArgumentValues().addGenericArgumentValue(this.requestCache);
|
||||
}
|
||||
|
||||
private void createFilterSecurityInterceptor(BeanReference authManager) {
|
||||
boolean useExpressions = FilterInvocationSecurityMetadataSourceParser.isUseExpressions(httpElt);
|
||||
boolean useExpressions = FilterInvocationSecurityMetadataSourceParser.isUseExpressions(this.httpElt);
|
||||
RootBeanDefinition securityMds = FilterInvocationSecurityMetadataSourceParser
|
||||
.createSecurityMetadataSource(interceptUrls, addAllAuth, httpElt, pc);
|
||||
.createSecurityMetadataSource(this.interceptUrls, this.addAllAuth, this.httpElt, this.pc);
|
||||
|
||||
RootBeanDefinition accessDecisionMgr;
|
||||
ManagedList<BeanDefinition> voters = new ManagedList<>(2);
|
||||
@@ -718,20 +719,20 @@ class HttpConfigurationBuilder {
|
||||
voters.add(expressionVoter.getBeanDefinition());
|
||||
}
|
||||
else {
|
||||
voters.add(
|
||||
GrantedAuthorityDefaultsParserUtils.registerWithDefaultRolePrefix(pc, RoleVoterBeanFactory.class));
|
||||
voters.add(GrantedAuthorityDefaultsParserUtils.registerWithDefaultRolePrefix(this.pc,
|
||||
RoleVoterBeanFactory.class));
|
||||
voters.add(new RootBeanDefinition(AuthenticatedVoter.class));
|
||||
}
|
||||
accessDecisionMgr = new RootBeanDefinition(AffirmativeBased.class);
|
||||
accessDecisionMgr.getConstructorArgumentValues().addGenericArgumentValue(voters);
|
||||
accessDecisionMgr.setSource(pc.extractSource(httpElt));
|
||||
accessDecisionMgr.setSource(this.pc.extractSource(this.httpElt));
|
||||
|
||||
// Set up the access manager reference for http
|
||||
String accessManagerId = httpElt.getAttribute(ATT_ACCESS_MGR);
|
||||
String accessManagerId = this.httpElt.getAttribute(ATT_ACCESS_MGR);
|
||||
|
||||
if (!StringUtils.hasText(accessManagerId)) {
|
||||
accessManagerId = pc.getReaderContext().generateBeanName(accessDecisionMgr);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(accessDecisionMgr, accessManagerId));
|
||||
accessManagerId = this.pc.getReaderContext().generateBeanName(accessDecisionMgr);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(accessDecisionMgr, accessManagerId));
|
||||
}
|
||||
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(FilterSecurityInterceptor.class);
|
||||
@@ -739,28 +740,29 @@ class HttpConfigurationBuilder {
|
||||
builder.addPropertyReference("accessDecisionManager", accessManagerId);
|
||||
builder.addPropertyValue("authenticationManager", authManager);
|
||||
|
||||
if ("false".equals(httpElt.getAttribute(ATT_ONCE_PER_REQUEST))) {
|
||||
if ("false".equals(this.httpElt.getAttribute(ATT_ONCE_PER_REQUEST))) {
|
||||
builder.addPropertyValue("observeOncePerRequest", Boolean.FALSE);
|
||||
}
|
||||
|
||||
builder.addPropertyValue("securityMetadataSource", securityMds);
|
||||
BeanDefinition fsiBean = builder.getBeanDefinition();
|
||||
String fsiId = pc.getReaderContext().generateBeanName(fsiBean);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(fsiBean, fsiId));
|
||||
String fsiId = this.pc.getReaderContext().generateBeanName(fsiBean);
|
||||
this.pc.registerBeanComponent(new BeanComponentDefinition(fsiBean, fsiId));
|
||||
|
||||
// Create and register a DefaultWebInvocationPrivilegeEvaluator for use with
|
||||
// taglibs etc.
|
||||
BeanDefinition wipe = new RootBeanDefinition(DefaultWebInvocationPrivilegeEvaluator.class);
|
||||
wipe.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(fsiId));
|
||||
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(wipe, pc.getReaderContext().generateBeanName(wipe)));
|
||||
this.pc.registerBeanComponent(
|
||||
new BeanComponentDefinition(wipe, this.pc.getReaderContext().generateBeanName(wipe)));
|
||||
|
||||
this.fsi = new RuntimeBeanReference(fsiId);
|
||||
}
|
||||
|
||||
private void createAddHeadersFilter() {
|
||||
Element elmt = DomUtils.getChildElementByTagName(httpElt, Elements.HEADERS);
|
||||
this.addHeadersFilter = new HeadersBeanDefinitionParser().parse(elmt, pc);
|
||||
Element elmt = DomUtils.getChildElementByTagName(this.httpElt, Elements.HEADERS);
|
||||
this.addHeadersFilter = new HeadersBeanDefinitionParser().parse(elmt, this.pc);
|
||||
}
|
||||
|
||||
private void createCorsFilter() {
|
||||
@@ -770,17 +772,17 @@ class HttpConfigurationBuilder {
|
||||
}
|
||||
|
||||
private void createCsrfFilter() {
|
||||
Element elmt = DomUtils.getChildElementByTagName(httpElt, Elements.CSRF);
|
||||
csrfParser = new CsrfBeanDefinitionParser();
|
||||
csrfFilter = csrfParser.parse(elmt, pc);
|
||||
Element elmt = DomUtils.getChildElementByTagName(this.httpElt, Elements.CSRF);
|
||||
this.csrfParser = new CsrfBeanDefinitionParser();
|
||||
this.csrfFilter = this.csrfParser.parse(elmt, this.pc);
|
||||
|
||||
if (csrfFilter == null) {
|
||||
csrfParser = null;
|
||||
if (this.csrfFilter == null) {
|
||||
this.csrfParser = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.csrfAuthStrategy = csrfParser.getCsrfAuthenticationStrategy();
|
||||
this.csrfLogoutHandler = csrfParser.getCsrfLogoutHandler();
|
||||
this.csrfAuthStrategy = this.csrfParser.getCsrfAuthenticationStrategy();
|
||||
this.csrfLogoutHandler = this.csrfParser.getCsrfLogoutHandler();
|
||||
}
|
||||
|
||||
BeanMetadataElement getCsrfLogoutHandler() {
|
||||
@@ -788,62 +790,62 @@ class HttpConfigurationBuilder {
|
||||
}
|
||||
|
||||
BeanReference getSessionStrategy() {
|
||||
return sessionStrategyRef;
|
||||
return this.sessionStrategyRef;
|
||||
}
|
||||
|
||||
SessionCreationPolicy getSessionCreationPolicy() {
|
||||
return sessionPolicy;
|
||||
return this.sessionPolicy;
|
||||
}
|
||||
|
||||
BeanReference getRequestCache() {
|
||||
return requestCache;
|
||||
return this.requestCache;
|
||||
}
|
||||
|
||||
List<OrderDecorator> getFilters() {
|
||||
List<OrderDecorator> filters = new ArrayList<>();
|
||||
|
||||
if (cpf != null) {
|
||||
filters.add(new OrderDecorator(cpf, CHANNEL_FILTER));
|
||||
if (this.cpf != null) {
|
||||
filters.add(new OrderDecorator(this.cpf, CHANNEL_FILTER));
|
||||
}
|
||||
|
||||
if (concurrentSessionFilter != null) {
|
||||
filters.add(new OrderDecorator(concurrentSessionFilter, CONCURRENT_SESSION_FILTER));
|
||||
if (this.concurrentSessionFilter != null) {
|
||||
filters.add(new OrderDecorator(this.concurrentSessionFilter, CONCURRENT_SESSION_FILTER));
|
||||
}
|
||||
|
||||
if (webAsyncManagerFilter != null) {
|
||||
filters.add(new OrderDecorator(webAsyncManagerFilter, WEB_ASYNC_MANAGER_FILTER));
|
||||
if (this.webAsyncManagerFilter != null) {
|
||||
filters.add(new OrderDecorator(this.webAsyncManagerFilter, WEB_ASYNC_MANAGER_FILTER));
|
||||
}
|
||||
|
||||
filters.add(new OrderDecorator(securityContextPersistenceFilter, SECURITY_CONTEXT_FILTER));
|
||||
filters.add(new OrderDecorator(this.securityContextPersistenceFilter, SECURITY_CONTEXT_FILTER));
|
||||
|
||||
if (servApiFilter != null) {
|
||||
filters.add(new OrderDecorator(servApiFilter, SERVLET_API_SUPPORT_FILTER));
|
||||
if (this.servApiFilter != null) {
|
||||
filters.add(new OrderDecorator(this.servApiFilter, SERVLET_API_SUPPORT_FILTER));
|
||||
}
|
||||
|
||||
if (jaasApiFilter != null) {
|
||||
filters.add(new OrderDecorator(jaasApiFilter, JAAS_API_SUPPORT_FILTER));
|
||||
if (this.jaasApiFilter != null) {
|
||||
filters.add(new OrderDecorator(this.jaasApiFilter, JAAS_API_SUPPORT_FILTER));
|
||||
}
|
||||
|
||||
if (sfpf != null) {
|
||||
filters.add(new OrderDecorator(sfpf, SESSION_MANAGEMENT_FILTER));
|
||||
if (this.sfpf != null) {
|
||||
filters.add(new OrderDecorator(this.sfpf, SESSION_MANAGEMENT_FILTER));
|
||||
}
|
||||
|
||||
filters.add(new OrderDecorator(fsi, FILTER_SECURITY_INTERCEPTOR));
|
||||
filters.add(new OrderDecorator(this.fsi, FILTER_SECURITY_INTERCEPTOR));
|
||||
|
||||
if (sessionPolicy != SessionCreationPolicy.STATELESS) {
|
||||
filters.add(new OrderDecorator(requestCacheAwareFilter, REQUEST_CACHE_FILTER));
|
||||
if (this.sessionPolicy != SessionCreationPolicy.STATELESS) {
|
||||
filters.add(new OrderDecorator(this.requestCacheAwareFilter, REQUEST_CACHE_FILTER));
|
||||
}
|
||||
|
||||
if (this.corsFilter != null) {
|
||||
filters.add(new OrderDecorator(this.corsFilter, CORS_FILTER));
|
||||
}
|
||||
|
||||
if (addHeadersFilter != null) {
|
||||
filters.add(new OrderDecorator(addHeadersFilter, HEADERS_FILTER));
|
||||
if (this.addHeadersFilter != null) {
|
||||
filters.add(new OrderDecorator(this.addHeadersFilter, HEADERS_FILTER));
|
||||
}
|
||||
|
||||
if (csrfFilter != null) {
|
||||
filters.add(new OrderDecorator(csrfFilter, CSRF_FILTER));
|
||||
if (this.csrfFilter != null) {
|
||||
filters.add(new OrderDecorator(this.csrfFilter, CSRF_FILTER));
|
||||
}
|
||||
|
||||
return filters;
|
||||
@@ -854,8 +856,8 @@ class HttpConfigurationBuilder {
|
||||
private RoleVoter voter = new RoleVoter();
|
||||
|
||||
public RoleVoter getBean() {
|
||||
voter.setRolePrefix(this.rolePrefix);
|
||||
return voter;
|
||||
this.voter.setRolePrefix(this.rolePrefix);
|
||||
return this.voter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -866,8 +868,8 @@ class HttpConfigurationBuilder {
|
||||
private SecurityContextHolderAwareRequestFilter filter = new SecurityContextHolderAwareRequestFilter();
|
||||
|
||||
public SecurityContextHolderAwareRequestFilter getBean() {
|
||||
filter.setRolePrefix(this.rolePrefix);
|
||||
return filter;
|
||||
this.filter.setRolePrefix(this.rolePrefix);
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -448,12 +448,12 @@ class OrderDecorator implements Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return order;
|
||||
return this.order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return bean + ", order = " + order;
|
||||
return this.bean + ", order = " + this.order;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class LogoutBeanDefinitionParser implements BeanDefinitionParser {
|
||||
this.rememberMeServices = rememberMeServices;
|
||||
this.csrfEnabled = csrfLogoutHandler != null;
|
||||
if (this.csrfEnabled) {
|
||||
logoutHandlers.add(csrfLogoutHandler);
|
||||
this.logoutHandlers.add(csrfLogoutHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,29 +102,29 @@ class LogoutBeanDefinitionParser implements BeanDefinitionParser {
|
||||
else {
|
||||
// Use the logout URL if no handler set
|
||||
if (!StringUtils.hasText(logoutSuccessUrl)) {
|
||||
logoutSuccessUrl = defaultLogoutUrl;
|
||||
logoutSuccessUrl = this.defaultLogoutUrl;
|
||||
}
|
||||
builder.addConstructorArgValue(logoutSuccessUrl);
|
||||
}
|
||||
|
||||
BeanDefinition sclh = new RootBeanDefinition(SecurityContextLogoutHandler.class);
|
||||
sclh.getPropertyValues().addPropertyValue("invalidateHttpSession", !"false".equals(invalidateSession));
|
||||
logoutHandlers.add(sclh);
|
||||
this.logoutHandlers.add(sclh);
|
||||
|
||||
if (rememberMeServices != null) {
|
||||
logoutHandlers.add(new RuntimeBeanReference(rememberMeServices));
|
||||
if (this.rememberMeServices != null) {
|
||||
this.logoutHandlers.add(new RuntimeBeanReference(this.rememberMeServices));
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(deleteCookies)) {
|
||||
BeanDefinition cookieDeleter = new RootBeanDefinition(CookieClearingLogoutHandler.class);
|
||||
String[] names = StringUtils.tokenizeToStringArray(deleteCookies, ",");
|
||||
cookieDeleter.getConstructorArgumentValues().addGenericArgumentValue(names);
|
||||
logoutHandlers.add(cookieDeleter);
|
||||
this.logoutHandlers.add(cookieDeleter);
|
||||
}
|
||||
|
||||
logoutHandlers.add(new RootBeanDefinition(LogoutSuccessEventPublishingLogoutHandler.class));
|
||||
this.logoutHandlers.add(new RootBeanDefinition(LogoutSuccessEventPublishingLogoutHandler.class));
|
||||
|
||||
builder.addConstructorArgValue(logoutHandlers);
|
||||
builder.addConstructorArgValue(this.logoutHandlers);
|
||||
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
@@ -141,7 +141,7 @@ class LogoutBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
ManagedList<BeanMetadataElement> getLogoutHandlers() {
|
||||
return logoutHandlers;
|
||||
return this.logoutHandlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public enum MatcherType {
|
||||
return new RootBeanDefinition(AnyRequestMatcher.class);
|
||||
}
|
||||
|
||||
BeanDefinitionBuilder matcherBldr = BeanDefinitionBuilder.rootBeanDefinition(type);
|
||||
BeanDefinitionBuilder matcherBldr = BeanDefinitionBuilder.rootBeanDefinition(this.type);
|
||||
|
||||
if (this == mvc) {
|
||||
matcherBldr.addConstructorArgValue(new RootBeanDefinition(HandlerMappingIntrospectorFactoryBean.class));
|
||||
|
||||
@@ -167,8 +167,9 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
.addConstructorArgValue(clientRegistrationRepository).addConstructorArgValue(authorizedClientRepository)
|
||||
.addPropertyValue("authorizationRequestRepository", authorizationRequestRepository);
|
||||
|
||||
if (sessionStrategy != null) {
|
||||
oauth2LoginAuthenticationFilterBuilder.addPropertyValue("sessionAuthenticationStrategy", sessionStrategy);
|
||||
if (this.sessionStrategy != null) {
|
||||
oauth2LoginAuthenticationFilterBuilder.addPropertyValue("sessionAuthenticationStrategy",
|
||||
this.sessionStrategy);
|
||||
}
|
||||
|
||||
Object source = parserContext.extractSource(element);
|
||||
@@ -192,9 +193,9 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
userAuthoritiesMapperRef);
|
||||
}
|
||||
|
||||
oauth2LoginAuthenticationProvider = oauth2LoginAuthenticationProviderBuilder.getBeanDefinition();
|
||||
this.oauth2LoginAuthenticationProvider = oauth2LoginAuthenticationProviderBuilder.getBeanDefinition();
|
||||
|
||||
oauth2LoginOidcAuthenticationProvider = getOidcAuthProvider(element, accessTokenResponseClient,
|
||||
this.oauth2LoginOidcAuthenticationProvider = getOidcAuthProvider(element, accessTokenResponseClient,
|
||||
userAuthoritiesMapperRef);
|
||||
|
||||
BeanDefinitionBuilder oauth2AuthorizationRequestRedirectFilterBuilder = BeanDefinitionBuilder
|
||||
@@ -210,8 +211,9 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
oauth2AuthorizationRequestRedirectFilterBuilder
|
||||
.addPropertyValue("authorizationRequestRepository", authorizationRequestRepository)
|
||||
.addPropertyValue("requestCache", requestCache);
|
||||
oauth2AuthorizationRequestRedirectFilter = oauth2AuthorizationRequestRedirectFilterBuilder.getBeanDefinition();
|
||||
.addPropertyValue("requestCache", this.requestCache);
|
||||
this.oauth2AuthorizationRequestRedirectFilter = oauth2AuthorizationRequestRedirectFilterBuilder
|
||||
.getBeanDefinition();
|
||||
|
||||
String authenticationSuccessHandlerRef = element.getAttribute(ATT_AUTHENTICATION_SUCCESS_HANDLER_REF);
|
||||
if (!StringUtils.isEmpty(authenticationSuccessHandlerRef)) {
|
||||
@@ -221,7 +223,7 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
else {
|
||||
BeanDefinitionBuilder successHandlerBuilder = BeanDefinitionBuilder.rootBeanDefinition(
|
||||
"org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler")
|
||||
.addPropertyValue("requestCache", requestCache);
|
||||
.addPropertyValue("requestCache", this.requestCache);
|
||||
oauth2LoginAuthenticationFilterBuilder.addPropertyValue("authenticationSuccessHandler",
|
||||
successHandlerBuilder.getBeanDefinition());
|
||||
}
|
||||
@@ -229,15 +231,15 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
String loginPage = element.getAttribute(ATT_LOGIN_PAGE);
|
||||
if (!StringUtils.isEmpty(loginPage)) {
|
||||
WebConfigUtils.validateHttpRedirect(loginPage, parserContext, source);
|
||||
oauth2LoginAuthenticationEntryPoint = BeanDefinitionBuilder
|
||||
this.oauth2LoginAuthenticationEntryPoint = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(LoginUrlAuthenticationEntryPoint.class).addConstructorArgValue(loginPage)
|
||||
.addPropertyValue("portMapper", portMapper).addPropertyValue("portResolver", portResolver)
|
||||
.addPropertyValue("portMapper", this.portMapper).addPropertyValue("portResolver", this.portResolver)
|
||||
.getBeanDefinition();
|
||||
}
|
||||
else {
|
||||
Map<RequestMatcher, AuthenticationEntryPoint> entryPoint = getLoginEntryPoint(element);
|
||||
if (entryPoint != null) {
|
||||
oauth2LoginAuthenticationEntryPoint = BeanDefinitionBuilder
|
||||
this.oauth2LoginAuthenticationEntryPoint = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(DelegatingAuthenticationEntryPoint.class).addConstructorArgValue(entryPoint)
|
||||
.addPropertyValue("defaultEntryPoint", new LoginUrlAuthenticationEntryPoint(DEFAULT_LOGIN_URI))
|
||||
.getBeanDefinition();
|
||||
@@ -254,13 +256,13 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
"org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler");
|
||||
failureHandlerBuilder.addConstructorArgValue(
|
||||
DEFAULT_LOGIN_URI + "?" + DefaultLoginPageGeneratingFilter.ERROR_PARAMETER_NAME);
|
||||
failureHandlerBuilder.addPropertyValue("allowSessionCreation", allowSessionCreation);
|
||||
failureHandlerBuilder.addPropertyValue("allowSessionCreation", this.allowSessionCreation);
|
||||
oauth2LoginAuthenticationFilterBuilder.addPropertyValue("authenticationFailureHandler",
|
||||
failureHandlerBuilder.getBeanDefinition());
|
||||
}
|
||||
|
||||
// prepare loginlinks
|
||||
oauth2LoginLinks = BeanDefinitionBuilder.rootBeanDefinition(Map.class)
|
||||
this.oauth2LoginLinks = BeanDefinitionBuilder.rootBeanDefinition(Map.class)
|
||||
.setFactoryMethodOnBean("getLoginLinks", oauth2LoginBeanConfigId).getBeanDefinition();
|
||||
|
||||
return oauth2LoginAuthenticationFilterBuilder.getBeanDefinition();
|
||||
@@ -354,23 +356,23 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
BeanDefinition getOAuth2AuthorizationRequestRedirectFilter() {
|
||||
return oauth2AuthorizationRequestRedirectFilter;
|
||||
return this.oauth2AuthorizationRequestRedirectFilter;
|
||||
}
|
||||
|
||||
BeanDefinition getOAuth2LoginAuthenticationEntryPoint() {
|
||||
return oauth2LoginAuthenticationEntryPoint;
|
||||
return this.oauth2LoginAuthenticationEntryPoint;
|
||||
}
|
||||
|
||||
BeanDefinition getOAuth2LoginAuthenticationProvider() {
|
||||
return oauth2LoginAuthenticationProvider;
|
||||
return this.oauth2LoginAuthenticationProvider;
|
||||
}
|
||||
|
||||
BeanDefinition getOAuth2LoginOidcAuthenticationProvider() {
|
||||
return oauth2LoginOidcAuthenticationProvider;
|
||||
return this.oauth2LoginOidcAuthenticationProvider;
|
||||
}
|
||||
|
||||
BeanDefinition getOAuth2LoginLinks() {
|
||||
return oauth2LoginLinks;
|
||||
return this.oauth2LoginLinks;
|
||||
}
|
||||
|
||||
private Map<RequestMatcher, AuthenticationEntryPoint> getLoginEntryPoint(Element element) {
|
||||
@@ -456,7 +458,7 @@ final class OAuth2LoginBeanDefinitionParser implements BeanDefinitionParser {
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
public Map<String, String> getLoginLinks() {
|
||||
Iterable<ClientRegistration> clientRegistrations = null;
|
||||
ClientRegistrationRepository clientRegistrationRepository = context
|
||||
ClientRegistrationRepository clientRegistrationRepository = this.context
|
||||
.getBean(ClientRegistrationRepository.class);
|
||||
ResolvableType type = ResolvableType.forInstance(clientRegistrationRepository).as(Iterable.class);
|
||||
if (type != ResolvableType.NONE && ClientRegistration.class.isAssignableFrom(type.resolveGenerics()[0])) {
|
||||
|
||||
@@ -136,7 +136,7 @@ class RememberMeBeanDefinitionParser implements BeanDefinitionParser {
|
||||
uds.setFactoryMethodName("cachingUserDetailsService");
|
||||
uds.getConstructorArgumentValues().addGenericArgumentValue(userServiceRef);
|
||||
|
||||
services.getConstructorArgumentValues().addGenericArgumentValue(key);
|
||||
services.getConstructorArgumentValues().addGenericArgumentValue(this.key);
|
||||
services.getConstructorArgumentValues().addGenericArgumentValue(uds);
|
||||
// tokenRepo is already added if it is a
|
||||
// PersistentTokenBasedRememberMeServices
|
||||
@@ -183,7 +183,7 @@ class RememberMeBeanDefinitionParser implements BeanDefinitionParser {
|
||||
filter.addPropertyReference("authenticationSuccessHandler", successHandlerRef);
|
||||
}
|
||||
|
||||
filter.addConstructorArgValue(authenticationManager);
|
||||
filter.addConstructorArgValue(this.authenticationManager);
|
||||
filter.addConstructorArgReference(servicesName);
|
||||
|
||||
pc.popAndRegisterContainingComponent();
|
||||
|
||||
@@ -46,7 +46,7 @@ public class UserDetailsServiceFactoryBean implements ApplicationContextAware {
|
||||
return getUserDetailsService();
|
||||
}
|
||||
|
||||
return (UserDetailsService) beanFactory.getBean(id);
|
||||
return (UserDetailsService) this.beanFactory.getBean(id);
|
||||
}
|
||||
|
||||
UserDetailsService cachingUserDetailsService(String id) {
|
||||
@@ -56,11 +56,11 @@ public class UserDetailsServiceFactoryBean implements ApplicationContextAware {
|
||||
// Overwrite with the caching version if available
|
||||
String cachingId = id + AbstractUserDetailsServiceBeanDefinitionParser.CACHING_SUFFIX;
|
||||
|
||||
if (beanFactory.containsBeanDefinition(cachingId)) {
|
||||
return (UserDetailsService) beanFactory.getBean(cachingId);
|
||||
if (this.beanFactory.containsBeanDefinition(cachingId)) {
|
||||
return (UserDetailsService) this.beanFactory.getBean(cachingId);
|
||||
}
|
||||
|
||||
return (UserDetailsService) beanFactory.getBean(id);
|
||||
return (UserDetailsService) this.beanFactory.getBean(id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -81,7 +81,7 @@ public class UserDetailsServiceFactoryBean implements ApplicationContextAware {
|
||||
uds = getUserDetailsService();
|
||||
}
|
||||
else {
|
||||
Object bean = beanFactory.getBean(name);
|
||||
Object bean = this.beanFactory.getBean(name);
|
||||
|
||||
if (bean instanceof AuthenticationUserDetailsService) {
|
||||
return (AuthenticationUserDetailsService) bean;
|
||||
@@ -131,11 +131,11 @@ public class UserDetailsServiceFactoryBean implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
private Map<String, ?> getBeansOfType(Class<?> type) {
|
||||
Map<String, ?> beans = beanFactory.getBeansOfType(type);
|
||||
Map<String, ?> beans = this.beanFactory.getBeansOfType(type);
|
||||
|
||||
// Check ancestor bean factories if they exist and the current one has none of the
|
||||
// required type
|
||||
BeanFactory parent = beanFactory.getParentBeanFactory();
|
||||
BeanFactory parent = this.beanFactory.getParentBeanFactory();
|
||||
while (parent != null && beans.size() == 0) {
|
||||
if (parent instanceof ListableBeanFactory) {
|
||||
beans = ((ListableBeanFactory) parent).getBeansOfType(type);
|
||||
|
||||
@@ -65,7 +65,7 @@ class ContextSourceSettingPostProcessor implements BeanFactoryPostProcessor, Ord
|
||||
+ "declared an explicit bean, do not use lazy-init");
|
||||
}
|
||||
|
||||
if (!bf.containsBean(BeanIds.CONTEXT_SOURCE) && defaultNameRequired) {
|
||||
if (!bf.containsBean(BeanIds.CONTEXT_SOURCE) && this.defaultNameRequired) {
|
||||
if (sources.length > 1) {
|
||||
throw new ApplicationContextException("More than one BaseLdapPathContextSource instance found. "
|
||||
+ "Please specify a specific server id using the 'server-ref' attribute when configuring your <"
|
||||
|
||||
@@ -65,7 +65,7 @@ public class LdapProviderBeanDefinitionParser implements BeanDefinitionParser {
|
||||
// TODO: Validate the pattern and make sure it is a valid DN.
|
||||
}
|
||||
else if (searchBean == null) {
|
||||
logger.info("No search information or DN pattern specified. Using default search filter '"
|
||||
this.logger.info("No search information or DN pattern specified. Using default search filter '"
|
||||
+ DEF_USER_SEARCH_FILTER + "'");
|
||||
BeanDefinitionBuilder searchBeanBuilder = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(LdapUserServiceBeanDefinitionParser.LDAP_SEARCH_CLASS);
|
||||
|
||||
@@ -186,7 +186,8 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
: expressionHandlerElt.getAttribute("ref");
|
||||
|
||||
if (StringUtils.hasText(expressionHandlerRef)) {
|
||||
logger.info("Using bean '" + expressionHandlerRef + "' as method ExpressionHandler implementation");
|
||||
this.logger.info(
|
||||
"Using bean '" + expressionHandlerRef + "' as method ExpressionHandler implementation");
|
||||
RootBeanDefinition lazyInitPP = new RootBeanDefinition(
|
||||
LazyInitBeanDefinitionRegistryPostProcessor.class);
|
||||
lazyInitPP.getConstructorArgumentValues().addGenericArgumentValue(expressionHandlerRef);
|
||||
@@ -215,7 +216,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
|
||||
expressionHandlerRef = pc.getReaderContext().generateBeanName(expressionHandler);
|
||||
pc.registerBeanComponent(new BeanComponentDefinition(expressionHandler, expressionHandlerRef));
|
||||
logger.info(
|
||||
this.logger.info(
|
||||
"Expressions were enabled for method security but no SecurityExpressionHandler was configured. "
|
||||
+ "All hasPermission() expressions will evaluate to false.");
|
||||
}
|
||||
@@ -485,11 +486,12 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
}
|
||||
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
synchronized (delegateMonitor) {
|
||||
if (delegate == null) {
|
||||
Assert.state(beanFactory != null, () -> "BeanFactory must be set to resolve " + authMgrBean);
|
||||
synchronized (this.delegateMonitor) {
|
||||
if (this.delegate == null) {
|
||||
Assert.state(this.beanFactory != null,
|
||||
() -> "BeanFactory must be set to resolve " + this.authMgrBean);
|
||||
try {
|
||||
delegate = beanFactory.getBean(authMgrBean, AuthenticationManager.class);
|
||||
this.delegate = this.beanFactory.getBean(this.authMgrBean, AuthenticationManager.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
if (BeanIds.AUTHENTICATION_MANAGER.equals(e.getBeanName())) {
|
||||
@@ -501,7 +503,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
}
|
||||
}
|
||||
|
||||
return delegate.authenticate(authentication);
|
||||
return this.delegate.authenticate(authentication);
|
||||
}
|
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
@@ -515,8 +517,8 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
private Jsr250MethodSecurityMetadataSource source = new Jsr250MethodSecurityMetadataSource();
|
||||
|
||||
public Jsr250MethodSecurityMetadataSource getBean() {
|
||||
source.setDefaultRolePrefix(this.rolePrefix);
|
||||
return source;
|
||||
this.source.setDefaultRolePrefix(this.rolePrefix);
|
||||
return this.source;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -526,8 +528,8 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
private DefaultMethodSecurityExpressionHandler handler = new DefaultMethodSecurityExpressionHandler();
|
||||
|
||||
public DefaultMethodSecurityExpressionHandler getBean() {
|
||||
handler.setDefaultRolePrefix(this.rolePrefix);
|
||||
return handler;
|
||||
this.handler.setDefaultRolePrefix(this.rolePrefix);
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -566,10 +568,10 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||
}
|
||||
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
|
||||
if (!registry.containsBeanDefinition(beanName)) {
|
||||
if (!registry.containsBeanDefinition(this.beanName)) {
|
||||
return;
|
||||
}
|
||||
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
|
||||
BeanDefinition beanDefinition = registry.getBeanDefinition(this.beanName);
|
||||
beanDefinition.setLazyInit(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class InterceptMethodsBeanDefinitionDecorator implements BeanDefinitionDe
|
||||
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
|
||||
MethodConfigUtils.registerDefaultMethodAccessManagerIfNecessary(parserContext);
|
||||
|
||||
return delegate.decorate(node, definition, parserContext);
|
||||
return this.delegate.decorate(node, definition, parserContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,8 +94,9 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
// supportedPrimitives.add(PointcutPrimitive.AT_WITHIN);
|
||||
// supportedPrimitives.add(PointcutPrimitive.AT_ARGS);
|
||||
// supportedPrimitives.add(PointcutPrimitive.AT_TARGET);
|
||||
parser = PointcutParser.getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(
|
||||
supportedPrimitives);
|
||||
this.parser = PointcutParser
|
||||
.getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(
|
||||
supportedPrimitives);
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
@@ -103,14 +104,14 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
}
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (processedBeans.contains(beanName)) {
|
||||
if (this.processedBeans.contains(beanName)) {
|
||||
// We already have the metadata for this bean
|
||||
return bean;
|
||||
}
|
||||
|
||||
synchronized (processedBeans) {
|
||||
synchronized (this.processedBeans) {
|
||||
// check again synchronized this time
|
||||
if (processedBeans.contains(beanName)) {
|
||||
if (this.processedBeans.contains(beanName)) {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
// Check to see if any of those methods are compatible with our pointcut
|
||||
// expressions
|
||||
for (Method method : methods) {
|
||||
for (PointcutExpression expression : pointCutExpressions) {
|
||||
for (PointcutExpression expression : this.pointCutExpressions) {
|
||||
// Try for the bean class directly
|
||||
if (attemptMatch(bean.getClass(), method, expression, beanName)) {
|
||||
// We've found the first expression that matches this method, so
|
||||
@@ -136,7 +137,7 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
processedBeans.add(beanName);
|
||||
this.processedBeans.add(beanName);
|
||||
}
|
||||
|
||||
return bean;
|
||||
@@ -148,7 +149,7 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
|
||||
// Handle accordingly
|
||||
if (matches) {
|
||||
List<ConfigAttribute> attr = pointcutMap.get(expression.getPointcutExpression());
|
||||
List<ConfigAttribute> attr = this.pointcutMap.get(expression.getPointcutExpression());
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("AspectJ pointcut expression '" + expression.getPointcutExpression()
|
||||
@@ -157,7 +158,7 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
+ "'");
|
||||
}
|
||||
|
||||
mapBasedMethodSecurityMetadataSource.addSecureMethod(targetClass, method, attr);
|
||||
this.mapBasedMethodSecurityMetadataSource.addSecureMethod(targetClass, method, attr);
|
||||
}
|
||||
|
||||
return matches;
|
||||
@@ -175,9 +176,9 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
|
||||
Assert.hasText(pointcutExpression, "An AspectJ pointcut expression is required");
|
||||
Assert.notNull(definition, "A List of ConfigAttributes is required");
|
||||
pointcutExpression = replaceBooleanOperators(pointcutExpression);
|
||||
pointcutMap.put(pointcutExpression, definition);
|
||||
this.pointcutMap.put(pointcutExpression, definition);
|
||||
// Parse the presented AspectJ pointcut expression and add it to the cache
|
||||
pointCutExpressions.add(parser.parsePointcutExpression(pointcutExpression));
|
||||
this.pointCutExpressions.add(this.parser.parsePointcutExpression(pointcutExpression));
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("AspectJ pointcut expression '" + pointcutExpression
|
||||
|
||||
@@ -42,7 +42,7 @@ public class UserDetailsManagerResourceFactoryBean
|
||||
|
||||
@Override
|
||||
public InMemoryUserDetailsManager getObject() throws Exception {
|
||||
Collection<UserDetails> users = userDetails.getObject();
|
||||
Collection<UserDetails> users = this.userDetails.getObject();
|
||||
return new InMemoryUserDetailsManager(users);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class UserDetailsManagerResourceFactoryBean
|
||||
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
userDetails.setResourceLoader(resourceLoader);
|
||||
this.userDetails.setResourceLoader(resourceLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -276,10 +276,10 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
|
||||
}
|
||||
ManagedList<Object> interceptors = new ManagedList();
|
||||
interceptors.add(new RootBeanDefinition(SecurityContextChannelInterceptor.class));
|
||||
if (!sameOriginDisabled) {
|
||||
if (!this.sameOriginDisabled) {
|
||||
interceptors.add(new RootBeanDefinition(CsrfChannelInterceptor.class));
|
||||
}
|
||||
interceptors.add(registry.getBeanDefinition(inboundSecurityInterceptorId));
|
||||
interceptors.add(registry.getBeanDefinition(this.inboundSecurityInterceptorId));
|
||||
|
||||
BeanDefinition inboundChannel = registry.getBeanDefinition(CLIENT_INBOUND_CHANNEL_BEAN_ID);
|
||||
PropertyValue currentInterceptorsPv = inboundChannel.getPropertyValues()
|
||||
@@ -297,7 +297,7 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
|
||||
}
|
||||
|
||||
private void addCsrfTokenHandshakeInterceptor(BeanDefinition bd) {
|
||||
if (sameOriginDisabled) {
|
||||
if (this.sameOriginDisabled) {
|
||||
return;
|
||||
}
|
||||
String interceptorPropertyName = "handshakeInterceptors";
|
||||
@@ -318,31 +318,31 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
|
||||
private PathMatcher delegate = new AntPathMatcher();
|
||||
|
||||
public boolean isPattern(String path) {
|
||||
return delegate.isPattern(path);
|
||||
return this.delegate.isPattern(path);
|
||||
}
|
||||
|
||||
public boolean match(String pattern, String path) {
|
||||
return delegate.match(pattern, path);
|
||||
return this.delegate.match(pattern, path);
|
||||
}
|
||||
|
||||
public boolean matchStart(String pattern, String path) {
|
||||
return delegate.matchStart(pattern, path);
|
||||
return this.delegate.matchStart(pattern, path);
|
||||
}
|
||||
|
||||
public String extractPathWithinPattern(String pattern, String path) {
|
||||
return delegate.extractPathWithinPattern(pattern, path);
|
||||
return this.delegate.extractPathWithinPattern(pattern, path);
|
||||
}
|
||||
|
||||
public Map<String, String> extractUriTemplateVariables(String pattern, String path) {
|
||||
return delegate.extractUriTemplateVariables(pattern, path);
|
||||
return this.delegate.extractUriTemplateVariables(pattern, path);
|
||||
}
|
||||
|
||||
public Comparator<String> getPatternComparator(String path) {
|
||||
return delegate.getPatternComparator(path);
|
||||
return this.delegate.getPatternComparator(path);
|
||||
}
|
||||
|
||||
public String combine(String pattern1, String pattern2) {
|
||||
return delegate.combine(pattern1, pattern2);
|
||||
return this.delegate.combine(pattern1, pattern2);
|
||||
}
|
||||
|
||||
void setPathMatcher(PathMatcher pathMatcher) {
|
||||
|
||||
@@ -32,24 +32,24 @@ public class BeanNameCollectingPostProcessor implements BeanPostProcessor {
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (beanName != null) {
|
||||
beforeInitPostProcessedBeans.add(beanName);
|
||||
this.beforeInitPostProcessedBeans.add(beanName);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (beanName != null) {
|
||||
afterInitPostProcessedBeans.add(beanName);
|
||||
this.afterInitPostProcessedBeans.add(beanName);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Set<String> getBeforeInitPostProcessedBeans() {
|
||||
return beforeInitPostProcessedBeans;
|
||||
return this.beforeInitPostProcessedBeans;
|
||||
}
|
||||
|
||||
public Set<String> getAfterInitPostProcessedBeans() {
|
||||
return afterInitPostProcessedBeans;
|
||||
return this.afterInitPostProcessedBeans;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,33 +42,33 @@ public class CollectingAppListener implements ApplicationListener {
|
||||
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (event instanceof AbstractAuthenticationEvent) {
|
||||
events.add(event);
|
||||
authenticationEvents.add((AbstractAuthenticationEvent) event);
|
||||
this.events.add(event);
|
||||
this.authenticationEvents.add((AbstractAuthenticationEvent) event);
|
||||
}
|
||||
if (event instanceof AbstractAuthenticationFailureEvent) {
|
||||
events.add(event);
|
||||
authenticationFailureEvents.add((AbstractAuthenticationFailureEvent) event);
|
||||
this.events.add(event);
|
||||
this.authenticationFailureEvents.add((AbstractAuthenticationFailureEvent) event);
|
||||
}
|
||||
if (event instanceof AbstractAuthorizationEvent) {
|
||||
events.add(event);
|
||||
authorizationEvents.add((AbstractAuthorizationEvent) event);
|
||||
this.events.add(event);
|
||||
this.authorizationEvents.add((AbstractAuthorizationEvent) event);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<ApplicationEvent> getEvents() {
|
||||
return events;
|
||||
return this.events;
|
||||
}
|
||||
|
||||
public Set<AbstractAuthenticationEvent> getAuthenticationEvents() {
|
||||
return authenticationEvents;
|
||||
return this.authenticationEvents;
|
||||
}
|
||||
|
||||
public Set<AbstractAuthenticationFailureEvent> getAuthenticationFailureEvents() {
|
||||
return authenticationFailureEvents;
|
||||
return this.authenticationFailureEvents;
|
||||
}
|
||||
|
||||
public Set<AbstractAuthorizationEvent> getAuthorizationEvents() {
|
||||
return authorizationEvents;
|
||||
return this.authorizationEvents;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ public class DataSourcePopulator implements InitializingBean {
|
||||
JdbcTemplate template;
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(template, "dataSource required");
|
||||
Assert.notNull(this.template, "dataSource required");
|
||||
|
||||
template.execute(
|
||||
this.template.execute(
|
||||
"CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(500) NOT NULL,ENABLED BOOLEAN NOT NULL);");
|
||||
template.execute(
|
||||
this.template.execute(
|
||||
"CREATE TABLE AUTHORITIES(USERNAME VARCHAR_IGNORECASE(50) NOT NULL,AUTHORITY VARCHAR_IGNORECASE(50) NOT NULL,CONSTRAINT FK_AUTHORITIES_USERS FOREIGN KEY(USERNAME) REFERENCES USERS(USERNAME));");
|
||||
template.execute("CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY);");
|
||||
this.template.execute("CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY);");
|
||||
|
||||
/*
|
||||
* Passwords encoded using MD5, NOT in Base64 format, with null as salt Encoded
|
||||
@@ -46,21 +46,21 @@ public class DataSourcePopulator implements InitializingBean {
|
||||
* is disabled) Encoded password for bill is "wombat" Encoded password for bob is
|
||||
* "wombat" Encoded password for jane is "wombat"
|
||||
*/
|
||||
template.execute("INSERT INTO USERS VALUES('rod','{noop}koala',TRUE);");
|
||||
template.execute("INSERT INTO USERS VALUES('dianne','{MD5}65d15fe9156f9c4bbffd98085992a44e',TRUE);");
|
||||
template.execute("INSERT INTO USERS VALUES('scott','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
template.execute("INSERT INTO USERS VALUES('peter','{MD5}22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
|
||||
template.execute("INSERT INTO USERS VALUES('bill','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
template.execute("INSERT INTO USERS VALUES('bob','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
template.execute("INSERT INTO USERS VALUES('jane','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_SUPERVISOR');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('bill','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('bob','ROLE_USER');");
|
||||
template.execute("INSERT INTO AUTHORITIES VALUES('jane','ROLE_USER');");
|
||||
this.template.execute("INSERT INTO USERS VALUES('rod','{noop}koala',TRUE);");
|
||||
this.template.execute("INSERT INTO USERS VALUES('dianne','{MD5}65d15fe9156f9c4bbffd98085992a44e',TRUE);");
|
||||
this.template.execute("INSERT INTO USERS VALUES('scott','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
this.template.execute("INSERT INTO USERS VALUES('peter','{MD5}22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
|
||||
this.template.execute("INSERT INTO USERS VALUES('bill','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
this.template.execute("INSERT INTO USERS VALUES('bob','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
this.template.execute("INSERT INTO USERS VALUES('jane','{MD5}2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_USER');");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('rod','ROLE_SUPERVISOR');");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_USER');");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('bill','ROLE_USER');");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('bob','ROLE_USER');");
|
||||
this.template.execute("INSERT INTO AUTHORITIES VALUES('jane','ROLE_USER');");
|
||||
}
|
||||
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
|
||||
@@ -59,25 +59,25 @@ public class FilterChainProxyConfigTests {
|
||||
public void loadContext() {
|
||||
System.setProperty("sec1235.pattern1", "/login");
|
||||
System.setProperty("sec1235.pattern2", "/logout");
|
||||
appCtx = new ClassPathXmlApplicationContext("org/springframework/security/util/filtertest-valid.xml");
|
||||
this.appCtx = new ClassPathXmlApplicationContext("org/springframework/security/util/filtertest-valid.xml");
|
||||
}
|
||||
|
||||
@After
|
||||
public void closeContext() {
|
||||
if (appCtx != null) {
|
||||
appCtx.close();
|
||||
if (this.appCtx != null) {
|
||||
this.appCtx.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normalOperation() throws Exception {
|
||||
FilterChainProxy filterChainProxy = appCtx.getBean("filterChain", FilterChainProxy.class);
|
||||
FilterChainProxy filterChainProxy = this.appCtx.getBean("filterChain", FilterChainProxy.class);
|
||||
doNormalOperation(filterChainProxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normalOperationWithNewConfig() throws Exception {
|
||||
FilterChainProxy filterChainProxy = appCtx.getBean("newFilterChainProxy", FilterChainProxy.class);
|
||||
FilterChainProxy filterChainProxy = this.appCtx.getBean("newFilterChainProxy", FilterChainProxy.class);
|
||||
filterChainProxy.setFirewall(new DefaultHttpFirewall());
|
||||
checkPathAndFilterOrder(filterChainProxy);
|
||||
doNormalOperation(filterChainProxy);
|
||||
@@ -85,7 +85,7 @@ public class FilterChainProxyConfigTests {
|
||||
|
||||
@Test
|
||||
public void normalOperationWithNewConfigRegex() throws Exception {
|
||||
FilterChainProxy filterChainProxy = appCtx.getBean("newFilterChainProxyRegex", FilterChainProxy.class);
|
||||
FilterChainProxy filterChainProxy = this.appCtx.getBean("newFilterChainProxyRegex", FilterChainProxy.class);
|
||||
filterChainProxy.setFirewall(new DefaultHttpFirewall());
|
||||
checkPathAndFilterOrder(filterChainProxy);
|
||||
doNormalOperation(filterChainProxy);
|
||||
@@ -93,7 +93,8 @@ public class FilterChainProxyConfigTests {
|
||||
|
||||
@Test
|
||||
public void normalOperationWithNewConfigNonNamespace() throws Exception {
|
||||
FilterChainProxy filterChainProxy = appCtx.getBean("newFilterChainProxyNonNamespace", FilterChainProxy.class);
|
||||
FilterChainProxy filterChainProxy = this.appCtx.getBean("newFilterChainProxyNonNamespace",
|
||||
FilterChainProxy.class);
|
||||
filterChainProxy.setFirewall(new DefaultHttpFirewall());
|
||||
checkPathAndFilterOrder(filterChainProxy);
|
||||
doNormalOperation(filterChainProxy);
|
||||
@@ -101,14 +102,15 @@ public class FilterChainProxyConfigTests {
|
||||
|
||||
@Test
|
||||
public void pathWithNoMatchHasNoFilters() {
|
||||
FilterChainProxy filterChainProxy = appCtx.getBean("newFilterChainProxyNoDefaultPath", FilterChainProxy.class);
|
||||
FilterChainProxy filterChainProxy = this.appCtx.getBean("newFilterChainProxyNoDefaultPath",
|
||||
FilterChainProxy.class);
|
||||
assertThat(filterChainProxy.getFilters("/nomatch")).isNull();
|
||||
}
|
||||
|
||||
// SEC-1235
|
||||
@Test
|
||||
public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() {
|
||||
FilterChainProxy fcp = appCtx.getBean("sec1235FilterChainProxy", FilterChainProxy.class);
|
||||
FilterChainProxy fcp = this.appCtx.getBean("sec1235FilterChainProxy", FilterChainProxy.class);
|
||||
|
||||
List<SecurityFilterChain> chains = fcp.getFilterChains();
|
||||
assertThat(getPattern(chains.get(0))).isEqualTo("/login*");
|
||||
|
||||
@@ -40,8 +40,8 @@ public class InvalidConfigurationTests {
|
||||
|
||||
@After
|
||||
public void closeAppContext() {
|
||||
if (appContext != null) {
|
||||
appContext.close();
|
||||
if (this.appContext != null) {
|
||||
this.appContext.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class InvalidConfigurationTests {
|
||||
}
|
||||
|
||||
private void setContext(String context) {
|
||||
appContext = new InMemoryXmlApplicationContext(context);
|
||||
this.appContext = new InMemoryXmlApplicationContext(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class PostProcessedMockUserDetailsService implements UserDetailsService {
|
||||
}
|
||||
|
||||
public String getPostProcessorWasHere() {
|
||||
return postProcessorWasHere;
|
||||
return this.postProcessorWasHere;
|
||||
}
|
||||
|
||||
public void setPostProcessorWasHere(String postProcessorWasHere) {
|
||||
|
||||
@@ -106,8 +106,8 @@ public class SecurityNamespaceHandlerTests {
|
||||
@Test
|
||||
public void filterNoClassDefFoundError() throws Exception {
|
||||
String className = "javax.servlet.Filter";
|
||||
thrown.expect(BeanDefinitionParsingException.class);
|
||||
thrown.expectMessage("NoClassDefFoundError: " + className);
|
||||
this.thrown.expect(BeanDefinitionParsingException.class);
|
||||
this.thrown.expectMessage("NoClassDefFoundError: " + className);
|
||||
spy(ClassUtils.class);
|
||||
doThrow(new NoClassDefFoundError(className)).when(ClassUtils.class, "forName", eq(FILTER_CHAIN_PROXY_CLASSNAME),
|
||||
any(ClassLoader.class));
|
||||
@@ -127,8 +127,8 @@ public class SecurityNamespaceHandlerTests {
|
||||
@Test
|
||||
public void filterChainProxyClassNotFoundException() throws Exception {
|
||||
String className = FILTER_CHAIN_PROXY_CLASSNAME;
|
||||
thrown.expect(BeanDefinitionParsingException.class);
|
||||
thrown.expectMessage("ClassNotFoundException: " + className);
|
||||
this.thrown.expect(BeanDefinitionParsingException.class);
|
||||
this.thrown.expectMessage("ClassNotFoundException: " + className);
|
||||
spy(ClassUtils.class);
|
||||
doThrow(new ClassNotFoundException(className)).when(ClassUtils.class, "forName",
|
||||
eq(FILTER_CHAIN_PROXY_CLASSNAME), any(ClassLoader.class));
|
||||
|
||||
@@ -28,7 +28,7 @@ class ConcereteSecurityConfigurerAdapter extends SecurityConfigurerAdapter<Objec
|
||||
|
||||
@Override
|
||||
public void configure(SecurityBuilder<Object> builder) {
|
||||
list = postProcess(list);
|
||||
this.list = postProcess(this.list);
|
||||
}
|
||||
|
||||
public ConcereteSecurityConfigurerAdapter list(List<Object> l) {
|
||||
|
||||
@@ -28,15 +28,15 @@ public class SecurityConfigurerAdapterTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
adapter = new ConcereteSecurityConfigurerAdapter();
|
||||
this.adapter = new ConcereteSecurityConfigurerAdapter();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessObjectPostProcessorsAreSorted() {
|
||||
adapter.addObjectPostProcessor(new OrderedObjectPostProcessor(Ordered.LOWEST_PRECEDENCE));
|
||||
adapter.addObjectPostProcessor(new OrderedObjectPostProcessor(Ordered.HIGHEST_PRECEDENCE));
|
||||
this.adapter.addObjectPostProcessor(new OrderedObjectPostProcessor(Ordered.LOWEST_PRECEDENCE));
|
||||
this.adapter.addObjectPostProcessor(new OrderedObjectPostProcessor(Ordered.HIGHEST_PRECEDENCE));
|
||||
|
||||
assertThat(adapter.postProcess("hi"))
|
||||
assertThat(this.adapter.postProcess("hi"))
|
||||
.isEqualTo("hi " + Ordered.HIGHEST_PRECEDENCE + " " + Ordered.LOWEST_PRECEDENCE);
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ public class SecurityConfigurerAdapterTests {
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
return this.order;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String postProcess(String object) {
|
||||
return object + " " + order;
|
||||
return object + " " + this.order;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class EnableGlobalAuthenticationTests {
|
||||
public void authenticationConfigurationWhenGetAuthenticationManagerThenNotNull() throws Exception {
|
||||
this.spring.register(Config.class).autowire();
|
||||
|
||||
AuthenticationConfiguration auth = spring.getContext().getBean(AuthenticationConfiguration.class);
|
||||
AuthenticationConfiguration auth = this.spring.getContext().getBean(AuthenticationConfiguration.class);
|
||||
|
||||
assertThat(auth.getAuthenticationManager()).isNotNull();
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class EnableGlobalAuthenticationTests {
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
return child;
|
||||
return this.child;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,15 +30,15 @@ public class LdapAuthenticationProviderConfigurerTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
configurer = new LdapAuthenticationProviderConfigurer<>();
|
||||
this.configurer = new LdapAuthenticationProviderConfigurer<>();
|
||||
}
|
||||
|
||||
// SEC-2557
|
||||
@Test
|
||||
public void getAuthoritiesMapper() throws Exception {
|
||||
assertThat(configurer.getAuthoritiesMapper()).isInstanceOf(SimpleAuthorityMapper.class);
|
||||
configurer.authoritiesMapper(new NullAuthoritiesMapper());
|
||||
assertThat(configurer.getAuthoritiesMapper()).isInstanceOf(NullAuthoritiesMapper.class);
|
||||
assertThat(this.configurer.getAuthoritiesMapper()).isInstanceOf(SimpleAuthorityMapper.class);
|
||||
this.configurer.authoritiesMapper(new NullAuthoritiesMapper());
|
||||
assertThat(this.configurer.getAuthoritiesMapper()).isInstanceOf(NullAuthoritiesMapper.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ public class UserDetailsManagerConfigurerTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
userDetailsManager = new InMemoryUserDetailsManager();
|
||||
this.userDetailsManager = new InMemoryUserDetailsManager();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allAttributesSupported() {
|
||||
UserDetails userDetails = new UserDetailsManagerConfigurer<AuthenticationManagerBuilder, InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>(
|
||||
userDetailsManager).withUser("user").password("password").roles("USER").disabled(true)
|
||||
this.userDetailsManager).withUser("user").password("password").roles("USER").disabled(true)
|
||||
.accountExpired(true).accountLocked(true).credentialsExpired(true).build();
|
||||
|
||||
assertThat(userDetails.getUsername()).isEqualTo("user");
|
||||
@@ -61,7 +61,7 @@ public class UserDetailsManagerConfigurerTests {
|
||||
SimpleGrantedAuthority authority = new SimpleGrantedAuthority("ROLE_USER");
|
||||
|
||||
UserDetails userDetails = new UserDetailsManagerConfigurer<AuthenticationManagerBuilder, InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>(
|
||||
userDetailsManager).withUser("user").password("password").authorities(authority).build();
|
||||
this.userDetailsManager).withUser("user").password("password").authorities(authority).build();
|
||||
|
||||
assertThat(userDetails.getAuthorities().stream().findFirst().get()).isEqualTo(authority);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class UserDetailsManagerConfigurerTests {
|
||||
String authority = "ROLE_USER";
|
||||
|
||||
UserDetails userDetails = new UserDetailsManagerConfigurer<AuthenticationManagerBuilder, InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>(
|
||||
userDetailsManager).withUser("user").password("password").authorities(authority).build();
|
||||
this.userDetailsManager).withUser("user").password("password").authorities(authority).build();
|
||||
|
||||
assertThat(userDetails.getAuthorities().stream().findFirst().get().getAuthority()).isEqualTo(authority);
|
||||
}
|
||||
@@ -81,7 +81,8 @@ public class UserDetailsManagerConfigurerTests {
|
||||
SimpleGrantedAuthority authority = new SimpleGrantedAuthority("ROLE_USER");
|
||||
|
||||
UserDetails userDetails = new UserDetailsManagerConfigurer<AuthenticationManagerBuilder, InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>(
|
||||
userDetailsManager).withUser("user").password("password").authorities(Arrays.asList(authority)).build();
|
||||
this.userDetailsManager).withUser("user").password("password").authorities(Arrays.asList(authority))
|
||||
.build();
|
||||
|
||||
assertThat(userDetails.getAuthorities().stream().findFirst().get()).isEqualTo(authority);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
Assert.notNull(myUserRepository);
|
||||
Assert.notNull(this.myUserRepository);
|
||||
return new AuthenticationProvider() {
|
||||
public boolean supports(Class<?> authentication) {
|
||||
return true;
|
||||
@@ -80,7 +80,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
Object principal = authentication.getPrincipal();
|
||||
String username = String.valueOf(principal);
|
||||
User user = myUserRepository.findByUsername(username);
|
||||
User user = SecurityConfig.this.myUserRepository.findByUsername(username);
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("No user for principal " + principal);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class User {
|
||||
private String password;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
@@ -44,7 +44,7 @@ public class User {
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
@@ -52,7 +52,7 @@ public class User {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
|
||||
@@ -38,89 +38,89 @@ public class DelegatingReactiveMessageService implements ReactiveMessageService
|
||||
|
||||
@Override
|
||||
public Mono<String> monoFindById(long id) {
|
||||
return delegate.monoFindById(id);
|
||||
return this.delegate.monoFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
public Mono<String> monoPreAuthorizeHasRoleFindById(long id) {
|
||||
return delegate.monoPreAuthorizeHasRoleFindById(id);
|
||||
return this.delegate.monoPreAuthorizeHasRoleFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostAuthorize("returnObject?.contains(authentication?.name)")
|
||||
public Mono<String> monoPostAuthorizeFindById(long id) {
|
||||
return delegate.monoPostAuthorizeFindById(id);
|
||||
return this.delegate.monoPostAuthorizeFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("@authz.check(#id)")
|
||||
public Mono<String> monoPreAuthorizeBeanFindById(long id) {
|
||||
return delegate.monoPreAuthorizeBeanFindById(id);
|
||||
return this.delegate.monoPreAuthorizeBeanFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostAuthorize("@authz.check(authentication, returnObject)")
|
||||
public Mono<String> monoPostAuthorizeBeanFindById(long id) {
|
||||
return delegate.monoPostAuthorizeBeanFindById(id);
|
||||
return this.delegate.monoPostAuthorizeBeanFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<String> fluxFindById(long id) {
|
||||
return delegate.fluxFindById(id);
|
||||
return this.delegate.fluxFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
public Flux<String> fluxPreAuthorizeHasRoleFindById(long id) {
|
||||
return delegate.fluxPreAuthorizeHasRoleFindById(id);
|
||||
return this.delegate.fluxPreAuthorizeHasRoleFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostAuthorize("returnObject?.contains(authentication?.name)")
|
||||
public Flux<String> fluxPostAuthorizeFindById(long id) {
|
||||
return delegate.fluxPostAuthorizeFindById(id);
|
||||
return this.delegate.fluxPostAuthorizeFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("@authz.check(#id)")
|
||||
public Flux<String> fluxPreAuthorizeBeanFindById(long id) {
|
||||
return delegate.fluxPreAuthorizeBeanFindById(id);
|
||||
return this.delegate.fluxPreAuthorizeBeanFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostAuthorize("@authz.check(authentication, returnObject)")
|
||||
public Flux<String> fluxPostAuthorizeBeanFindById(long id) {
|
||||
return delegate.fluxPostAuthorizeBeanFindById(id);
|
||||
return this.delegate.fluxPostAuthorizeBeanFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Publisher<String> publisherFindById(long id) {
|
||||
return delegate.publisherFindById(id);
|
||||
return this.delegate.publisherFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
public Publisher<String> publisherPreAuthorizeHasRoleFindById(long id) {
|
||||
return delegate.publisherPreAuthorizeHasRoleFindById(id);
|
||||
return this.delegate.publisherPreAuthorizeHasRoleFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostAuthorize("returnObject?.contains(authentication?.name)")
|
||||
public Publisher<String> publisherPostAuthorizeFindById(long id) {
|
||||
return delegate.publisherPostAuthorizeFindById(id);
|
||||
return this.delegate.publisherPostAuthorizeFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("@authz.check(#id)")
|
||||
public Publisher<String> publisherPreAuthorizeBeanFindById(long id) {
|
||||
return delegate.publisherPreAuthorizeBeanFindById(id);
|
||||
return this.delegate.publisherPreAuthorizeBeanFindById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostAuthorize("@authz.check(authentication, returnObject)")
|
||||
public Publisher<String> publisherPostAuthorizeBeanFindById(long id) {
|
||||
return delegate.publisherPostAuthorizeBeanFindById(id);
|
||||
return this.delegate.publisherPostAuthorizeBeanFindById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@After
|
||||
public void cleanup() {
|
||||
reset(delegate);
|
||||
reset(this.delegate);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@@ -80,11 +80,11 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@Test
|
||||
public void monoWhenPermitAllThenAopDoesNotSubscribe() {
|
||||
when(this.delegate.monoFindById(1L)).thenReturn(Mono.from(result));
|
||||
when(this.delegate.monoFindById(1L)).thenReturn(Mono.from(this.result));
|
||||
|
||||
this.delegate.monoFindById(1L);
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,35 +98,37 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void monoPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
||||
when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.just("result"));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L).subscriberContext(withAdmin);
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L)
|
||||
.subscriberContext(this.withAdmin);
|
||||
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void monoPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
||||
when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.from(result));
|
||||
when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.from(this.result));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void monoPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.from(result));
|
||||
when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.from(this.result));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L).subscriberContext(withUser);
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L)
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void monoPreAuthorizeBeanWhenGrantedThenSuccess() {
|
||||
when(this.delegate.monoPreAuthorizeBeanFindById(2L)).thenReturn(Mono.just("result"));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(2L).subscriberContext(withAdmin);
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(2L).subscriberContext(this.withAdmin);
|
||||
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -140,29 +142,29 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@Test
|
||||
public void monoPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
||||
when(this.delegate.monoPreAuthorizeBeanFindById(1L)).thenReturn(Mono.from(result));
|
||||
when(this.delegate.monoPreAuthorizeBeanFindById(1L)).thenReturn(Mono.from(this.result));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(1L);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void monoPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.monoPreAuthorizeBeanFindById(1L)).thenReturn(Mono.from(result));
|
||||
when(this.delegate.monoPreAuthorizeBeanFindById(1L)).thenReturn(Mono.from(this.result));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(1L).subscriberContext(withUser);
|
||||
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void monoPostAuthorizeWhenAuthorizedThenSuccess() {
|
||||
when(this.delegate.monoPostAuthorizeFindById(1L)).thenReturn(Mono.just("user"));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeFindById(1L).subscriberContext(withUser);
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -170,7 +172,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void monoPostAuthorizeWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.monoPostAuthorizeBeanFindById(1L)).thenReturn(Mono.just("not-authorized"));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(withUser);
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
}
|
||||
|
||||
@@ -178,7 +180,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void monoPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
||||
when(this.delegate.monoPostAuthorizeBeanFindById(2L)).thenReturn(Mono.just("user"));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(2L).subscriberContext(withUser);
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(2L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -194,7 +196,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void monoPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
||||
when(this.delegate.monoPostAuthorizeBeanFindById(1L)).thenReturn(Mono.just("not-authorized"));
|
||||
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(withUser);
|
||||
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
}
|
||||
|
||||
@@ -202,11 +204,11 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@Test
|
||||
public void fluxWhenPermitAllThenAopDoesNotSubscribe() {
|
||||
when(this.delegate.fluxFindById(1L)).thenReturn(Flux.from(result));
|
||||
when(this.delegate.fluxFindById(1L)).thenReturn(Flux.from(this.result));
|
||||
|
||||
this.delegate.fluxFindById(1L);
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,36 +222,38 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void fluxPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
||||
when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.just("result"));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L).subscriberContext(withAdmin);
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L)
|
||||
.subscriberContext(this.withAdmin);
|
||||
StepVerifier.create(findById).consumeNextWith(s -> AssertionsForClassTypes.assertThat(s).isEqualTo("result"))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluxPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
||||
when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.from(result));
|
||||
when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.from(this.result));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluxPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.from(result));
|
||||
when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.from(this.result));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L).subscriberContext(withUser);
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L)
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluxPreAuthorizeBeanWhenGrantedThenSuccess() {
|
||||
when(this.delegate.fluxPreAuthorizeBeanFindById(2L)).thenReturn(Flux.just("result"));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(2L).subscriberContext(withAdmin);
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(2L).subscriberContext(this.withAdmin);
|
||||
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -263,29 +267,29 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@Test
|
||||
public void fluxPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
||||
when(this.delegate.fluxPreAuthorizeBeanFindById(1L)).thenReturn(Flux.from(result));
|
||||
when(this.delegate.fluxPreAuthorizeBeanFindById(1L)).thenReturn(Flux.from(this.result));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(1L);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluxPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.fluxPreAuthorizeBeanFindById(1L)).thenReturn(Flux.from(result));
|
||||
when(this.delegate.fluxPreAuthorizeBeanFindById(1L)).thenReturn(Flux.from(this.result));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(1L).subscriberContext(withUser);
|
||||
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fluxPostAuthorizeWhenAuthorizedThenSuccess() {
|
||||
when(this.delegate.fluxPostAuthorizeFindById(1L)).thenReturn(Flux.just("user"));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeFindById(1L).subscriberContext(withUser);
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -293,7 +297,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void fluxPostAuthorizeWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.fluxPostAuthorizeBeanFindById(1L)).thenReturn(Flux.just("not-authorized"));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(withUser);
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
}
|
||||
|
||||
@@ -301,7 +305,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void fluxPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
||||
when(this.delegate.fluxPostAuthorizeBeanFindById(2L)).thenReturn(Flux.just("user"));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(2L).subscriberContext(withUser);
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(2L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -317,7 +321,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
public void fluxPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
||||
when(this.delegate.fluxPostAuthorizeBeanFindById(1L)).thenReturn(Flux.just("not-authorized"));
|
||||
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(withUser);
|
||||
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
}
|
||||
|
||||
@@ -325,11 +329,11 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@Test
|
||||
public void publisherWhenPermitAllThenAopDoesNotSubscribe() {
|
||||
when(this.delegate.publisherFindById(1L)).thenReturn(result);
|
||||
when(this.delegate.publisherFindById(1L)).thenReturn(this.result);
|
||||
|
||||
this.delegate.publisherFindById(1L);
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -344,30 +348,30 @@ public class EnableReactiveMethodSecurityTests {
|
||||
when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(publisherJust("result"));
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeHasRoleFindById(1L))
|
||||
.subscriberContext(withAdmin);
|
||||
.subscriberContext(this.withAdmin);
|
||||
StepVerifier.create(findById).consumeNextWith(s -> AssertionsForClassTypes.assertThat(s).isEqualTo("result"))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publisherPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
||||
when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(result);
|
||||
when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(this.result);
|
||||
|
||||
Publisher<String> findById = this.messageService.publisherPreAuthorizeHasRoleFindById(1L);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publisherPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(result);
|
||||
when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(this.result);
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeHasRoleFindById(1L))
|
||||
.subscriberContext(withUser);
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -375,7 +379,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
when(this.delegate.publisherPreAuthorizeBeanFindById(2L)).thenReturn(publisherJust("result"));
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeBeanFindById(2L))
|
||||
.subscriberContext(withAdmin);
|
||||
.subscriberContext(this.withAdmin);
|
||||
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -389,23 +393,23 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@Test
|
||||
public void publisherPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
||||
when(this.delegate.publisherPreAuthorizeBeanFindById(1L)).thenReturn(result);
|
||||
when(this.delegate.publisherPreAuthorizeBeanFindById(1L)).thenReturn(this.result);
|
||||
|
||||
Publisher<String> findById = this.messageService.publisherPreAuthorizeBeanFindById(1L);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publisherPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
||||
when(this.delegate.publisherPreAuthorizeBeanFindById(1L)).thenReturn(result);
|
||||
when(this.delegate.publisherPreAuthorizeBeanFindById(1L)).thenReturn(this.result);
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeBeanFindById(1L))
|
||||
.subscriberContext(withUser);
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
|
||||
result.assertNoSubscribers();
|
||||
this.result.assertNoSubscribers();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -413,7 +417,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
when(this.delegate.publisherPostAuthorizeFindById(1L)).thenReturn(publisherJust("user"));
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeFindById(1L))
|
||||
.subscriberContext(withUser);
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -422,7 +426,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
when(this.delegate.publisherPostAuthorizeBeanFindById(1L)).thenReturn(publisherJust("not-authorized"));
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(1L))
|
||||
.subscriberContext(withUser);
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
}
|
||||
|
||||
@@ -431,7 +435,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
when(this.delegate.publisherPostAuthorizeBeanFindById(2L)).thenReturn(publisherJust("user"));
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(2L))
|
||||
.subscriberContext(withUser);
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
||||
}
|
||||
|
||||
@@ -448,7 +452,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
when(this.delegate.publisherPostAuthorizeBeanFindById(1L)).thenReturn(publisherJust("not-authorized"));
|
||||
|
||||
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(1L))
|
||||
.subscriberContext(withUser);
|
||||
.subscriberContext(this.withUser);
|
||||
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
||||
}
|
||||
|
||||
@@ -467,7 +471,7 @@ public class EnableReactiveMethodSecurityTests {
|
||||
|
||||
@Bean
|
||||
public DelegatingReactiveMessageService defaultMessageService() {
|
||||
return new DelegatingReactiveMessageService(delegate);
|
||||
return new DelegatingReactiveMessageService(this.delegate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -437,7 +437,7 @@ public class NamespaceGlobalMethodSecurityTests {
|
||||
public void methodSecurityWhenCustomRunAsManagerThenRunAsWrapsAuthentication() {
|
||||
this.spring.register(CustomRunAsManagerConfig.class, MethodSecurityServiceConfig.class).autowire();
|
||||
|
||||
assertThat(service.runAs().getAuthorities())
|
||||
assertThat(this.service.runAs().getAuthorities())
|
||||
.anyMatch(authority -> "ROLE_RUN_AS_SUPER".equals(authority.getAuthority()));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ public class Sec2758Tests {
|
||||
|
||||
this.spring.register(SecurityConfig.class).autowire();
|
||||
|
||||
assertThatCode(() -> service.doJsr250()).doesNotThrowAnyException();
|
||||
assertThatCode(() -> this.service.doJsr250()).doesNotThrowAnyException();
|
||||
|
||||
assertThatCode(() -> service.doPreAuthorize()).doesNotThrowAnyException();
|
||||
assertThatCode(() -> this.service.doPreAuthorize()).doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
@EnableWebSecurity
|
||||
|
||||
@@ -60,14 +60,14 @@ public class HttpSecurityHeadersTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).addFilters(this.springSecurityFilterChain).build();
|
||||
}
|
||||
|
||||
// gh-2953
|
||||
// gh-3975
|
||||
@Test
|
||||
public void headerWhenSpringMvcResourceThenCacheRelatedHeadersReset() throws Exception {
|
||||
mockMvc.perform(get("/resources/file.js")).andExpect(status().isOk())
|
||||
this.mockMvc.perform(get("/resources/file.js")).andExpect(status().isOk())
|
||||
.andExpect(header().string(HttpHeaders.CACHE_CONTROL, "max-age=12345"))
|
||||
.andExpect(header().doesNotExist(HttpHeaders.PRAGMA))
|
||||
.andExpect(header().doesNotExist(HttpHeaders.EXPIRES));
|
||||
@@ -75,7 +75,7 @@ public class HttpSecurityHeadersTests {
|
||||
|
||||
@Test
|
||||
public void headerWhenNotSpringResourceThenCacheRelatedHeadersSet() throws Exception {
|
||||
mockMvc.perform(get("/notresource"))
|
||||
this.mockMvc.perform(get("/notresource"))
|
||||
.andExpect(header().string(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0, must-revalidate"))
|
||||
.andExpect(header().string(HttpHeaders.PRAGMA, "no-cache"))
|
||||
.andExpect(header().string(HttpHeaders.EXPIRES, "0"));
|
||||
|
||||
@@ -72,8 +72,8 @@ public class WebSecurityConfigurerAdapterPowermockTests {
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class AuthenticationPrincipalArgumentResolverTests {
|
||||
new UsernamePasswordAuthenticationToken(user, user.getPassword(), user.getAuthorities()));
|
||||
SecurityContextHolder.setContext(context);
|
||||
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
|
||||
|
||||
mockMvc.perform(get("/users/self")).andExpect(status().isOk()).andExpect(content().string("extracted-user"));
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class EnableWebSecurityTests {
|
||||
}
|
||||
|
||||
public Child getChild() {
|
||||
return child;
|
||||
return this.child;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ public class WebMvcSecurityConfigurationTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
authentication = new TestingAuthenticationToken("user", "password",
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
this.authentication = new TestingAuthenticationToken("user", "password",
|
||||
AuthorityUtils.createAuthorityList("ROLE_USER"));
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
SecurityContextHolder.getContext().setAuthentication(this.authentication);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -77,14 +77,15 @@ public class WebMvcSecurityConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void authenticationPrincipalResolved() throws Exception {
|
||||
mockMvc.perform(get("/authentication-principal")).andExpect(assertResult(authentication.getPrincipal()))
|
||||
this.mockMvc.perform(get("/authentication-principal"))
|
||||
.andExpect(assertResult(this.authentication.getPrincipal()))
|
||||
.andExpect(view().name("authentication-principal-view"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deprecatedAuthenticationPrincipalResolved() throws Exception {
|
||||
mockMvc.perform(get("/deprecated-authentication-principal"))
|
||||
.andExpect(assertResult(authentication.getPrincipal()))
|
||||
this.mockMvc.perform(get("/deprecated-authentication-principal"))
|
||||
.andExpect(assertResult(this.authentication.getPrincipal()))
|
||||
.andExpect(view().name("deprecated-authentication-principal-view"));
|
||||
}
|
||||
|
||||
@@ -93,7 +94,7 @@ public class WebMvcSecurityConfigurationTests {
|
||||
CsrfToken csrfToken = new DefaultCsrfToken("headerName", "paramName", "token");
|
||||
MockHttpServletRequestBuilder request = get("/csrf").requestAttr(CsrfToken.class.getName(), csrfToken);
|
||||
|
||||
mockMvc.perform(request).andExpect(assertResult(csrfToken));
|
||||
this.mockMvc.perform(request).andExpect(assertResult(csrfToken));
|
||||
}
|
||||
|
||||
private ResultMatcher assertResult(Object expected) {
|
||||
|
||||
@@ -35,12 +35,12 @@ public class AbstractConfigAttributeRequestMatcherRegistryTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
registry = new ConcreteAbstractRequestMatcherMappingConfigurer();
|
||||
this.registry = new ConcreteAbstractRequestMatcherMappingConfigurer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequestMatcherIsTypeRegexMatcher() {
|
||||
List<RequestMatcher> requestMatchers = registry.regexMatchers(HttpMethod.GET, "/a.*");
|
||||
List<RequestMatcher> requestMatchers = this.registry.regexMatchers(HttpMethod.GET, "/a.*");
|
||||
|
||||
for (RequestMatcher requestMatcher : requestMatchers) {
|
||||
assertThat(requestMatcher).isInstanceOf(RegexRequestMatcher.class);
|
||||
@@ -49,7 +49,7 @@ public class AbstractConfigAttributeRequestMatcherRegistryTests {
|
||||
|
||||
@Test
|
||||
public void testRequestMatcherIsTypeRegexMatcher() {
|
||||
List<RequestMatcher> requestMatchers = registry.regexMatchers("/a.*");
|
||||
List<RequestMatcher> requestMatchers = this.registry.regexMatchers("/a.*");
|
||||
|
||||
for (RequestMatcher requestMatcher : requestMatchers) {
|
||||
assertThat(requestMatcher).isInstanceOf(RegexRequestMatcher.class);
|
||||
@@ -58,7 +58,7 @@ public class AbstractConfigAttributeRequestMatcherRegistryTests {
|
||||
|
||||
@Test
|
||||
public void testGetRequestMatcherIsTypeAntPathRequestMatcher() {
|
||||
List<RequestMatcher> requestMatchers = registry.antMatchers(HttpMethod.GET, "/a.*");
|
||||
List<RequestMatcher> requestMatchers = this.registry.antMatchers(HttpMethod.GET, "/a.*");
|
||||
|
||||
for (RequestMatcher requestMatcher : requestMatchers) {
|
||||
assertThat(requestMatcher).isInstanceOf(AntPathRequestMatcher.class);
|
||||
@@ -67,7 +67,7 @@ public class AbstractConfigAttributeRequestMatcherRegistryTests {
|
||||
|
||||
@Test
|
||||
public void testRequestMatcherIsTypeAntPathRequestMatcher() {
|
||||
List<RequestMatcher> requestMatchers = registry.antMatchers("/a.*");
|
||||
List<RequestMatcher> requestMatchers = this.registry.antMatchers("/a.*");
|
||||
|
||||
for (RequestMatcher requestMatcher : requestMatchers) {
|
||||
assertThat(requestMatcher).isInstanceOf(AntPathRequestMatcher.class);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class ChannelSecurityConfigurerTests {
|
||||
public void requiresChannelWhenInvokesTwiceThenUsesOriginalRequiresSecure() throws Exception {
|
||||
this.spring.register(DuplicateInvocationsDoesNotOverrideConfig.class).autowire();
|
||||
|
||||
mvc.perform(get("/")).andExpect(redirectedUrl("https://localhost/"));
|
||||
this.mvc.perform(get("/")).andExpect(redirectedUrl("https://localhost/"));
|
||||
}
|
||||
|
||||
@EnableWebSecurity
|
||||
@@ -141,7 +141,7 @@ public class ChannelSecurityConfigurerTests {
|
||||
public void requestWhenRequiresChannelConfiguredInLambdaThenRedirectsToHttps() throws Exception {
|
||||
this.spring.register(RequiresChannelInLambdaConfig.class).autowire();
|
||||
|
||||
mvc.perform(get("/")).andExpect(redirectedUrl("https://localhost/"));
|
||||
this.mvc.perform(get("/")).andExpect(redirectedUrl("https://localhost/"));
|
||||
}
|
||||
|
||||
@EnableWebSecurity
|
||||
|
||||
@@ -41,8 +41,8 @@ public class CsrfConfigurerNoWebMvcTests {
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,21 +50,21 @@ public class CsrfConfigurerNoWebMvcTests {
|
||||
public void missingDispatcherServletPreventsCsrfRequestDataValueProcessor() {
|
||||
loadContext(EnableWebConfig.class);
|
||||
|
||||
assertThat(context.containsBeanDefinition("requestDataValueProcessor")).isTrue();
|
||||
assertThat(this.context.containsBeanDefinition("requestDataValueProcessor")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findDispatcherServletPreventsCsrfRequestDataValueProcessor() {
|
||||
loadContext(EnableWebMvcConfig.class);
|
||||
|
||||
assertThat(context.containsBeanDefinition("requestDataValueProcessor")).isTrue();
|
||||
assertThat(this.context.containsBeanDefinition("requestDataValueProcessor")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideCsrfRequestDataValueProcessor() {
|
||||
loadContext(EnableWebOverrideRequestDataConfig.class);
|
||||
|
||||
assertThat(context.getBean(RequestDataValueProcessor.class).getClass())
|
||||
assertThat(this.context.getBean(RequestDataValueProcessor.class).getClass())
|
||||
.isNotEqualTo(CsrfRequestDataValueProcessor.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,15 +55,15 @@ public class HttpSecurityAntMatchersTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
request = new MockHttpServletRequest("GET", "");
|
||||
response = new MockHttpServletResponse();
|
||||
chain = new MockFilterChain();
|
||||
this.request = new MockHttpServletRequest("GET", "");
|
||||
this.response = new MockHttpServletResponse();
|
||||
this.chain = new MockFilterChain();
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,11 +71,11 @@ public class HttpSecurityAntMatchersTests {
|
||||
@Test
|
||||
public void antMatchersMethodAndNoPatterns() throws Exception {
|
||||
loadConfig(AntMatchersNoPatternsConfig.class);
|
||||
request.setMethod("POST");
|
||||
this.request.setMethod("POST");
|
||||
|
||||
springSecurityFilterChain.doFilter(request, response, chain);
|
||||
this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
|
||||
|
||||
assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_FORBIDDEN);
|
||||
assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_FORBIDDEN);
|
||||
}
|
||||
|
||||
@EnableWebSecurity
|
||||
@@ -107,11 +107,11 @@ public class HttpSecurityAntMatchersTests {
|
||||
@Test
|
||||
public void antMatchersMethodAndEmptyPatterns() throws Exception {
|
||||
loadConfig(AntMatchersEmptyPatternsConfig.class);
|
||||
request.setMethod("POST");
|
||||
this.request.setMethod("POST");
|
||||
|
||||
springSecurityFilterChain.doFilter(request, response, chain);
|
||||
this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
|
||||
|
||||
assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_OK);
|
||||
assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_OK);
|
||||
}
|
||||
|
||||
@EnableWebSecurity
|
||||
@@ -141,11 +141,11 @@ public class HttpSecurityAntMatchersTests {
|
||||
}
|
||||
|
||||
public void loadConfig(Class<?>... configs) {
|
||||
context = new AnnotationConfigWebApplicationContext();
|
||||
context.register(configs);
|
||||
context.refresh();
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(configs);
|
||||
this.context.refresh();
|
||||
|
||||
context.getAutowireCapableBeanFactory().autowireBean(this);
|
||||
this.context.getAutowireCapableBeanFactory().autowireBean(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,15 +56,15 @@ public class HttpSecurityLogoutTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
request = new MockHttpServletRequest("GET", "");
|
||||
response = new MockHttpServletResponse();
|
||||
chain = new MockFilterChain();
|
||||
this.request = new MockHttpServletRequest("GET", "");
|
||||
this.response = new MockHttpServletResponse();
|
||||
this.chain = new MockFilterChain();
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,12 +76,12 @@ public class HttpSecurityLogoutTests {
|
||||
SecurityContext currentContext = SecurityContextHolder.createEmptyContext();
|
||||
currentContext.setAuthentication(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
|
||||
|
||||
request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
|
||||
this.request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
|
||||
currentContext);
|
||||
request.setMethod("POST");
|
||||
request.setServletPath("/logout");
|
||||
this.request.setMethod("POST");
|
||||
this.request.setServletPath("/logout");
|
||||
|
||||
springSecurityFilterChain.doFilter(request, response, chain);
|
||||
this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
|
||||
|
||||
assertThat(currentContext.getAuthentication()).isNotNull();
|
||||
}
|
||||
@@ -110,11 +110,11 @@ public class HttpSecurityLogoutTests {
|
||||
}
|
||||
|
||||
public void loadConfig(Class<?>... configs) {
|
||||
context = new AnnotationConfigWebApplicationContext();
|
||||
context.register(configs);
|
||||
context.refresh();
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(configs);
|
||||
this.context.refresh();
|
||||
|
||||
context.getAutowireCapableBeanFactory().autowireBean(this);
|
||||
this.context.getAutowireCapableBeanFactory().autowireBean(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class HttpSecurityRequestMatchersTests {
|
||||
public void mvcMatcherGetFiltersNoUnsupportedMethodExceptionFromDummyRequest() {
|
||||
loadConfig(MvcMatcherConfig.class);
|
||||
|
||||
assertThat(springSecurityFilterChain.getFilters("/path")).isNotEmpty();
|
||||
assertThat(this.springSecurityFilterChain.getFilters("/path")).isNotEmpty();
|
||||
}
|
||||
|
||||
@EnableWebSecurity
|
||||
|
||||
@@ -82,7 +82,7 @@ public class RememberMeConfigurerTests {
|
||||
public void postWhenNoUserDetailsServiceThenException() {
|
||||
this.spring.register(NullUserDetailsConfig.class).autowire();
|
||||
|
||||
assertThatThrownBy(() -> mvc.perform(post("/login").param("username", "user").param("password", "password")
|
||||
assertThatThrownBy(() -> this.mvc.perform(post("/login").param("username", "user").param("password", "password")
|
||||
.param("remember-me", "true").with(csrf()))).hasMessageContaining("UserDetailsService is required");
|
||||
}
|
||||
|
||||
|
||||
@@ -68,15 +68,15 @@ public class SessionManagementConfigurerServlet31Tests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
request = new MockHttpServletRequest("GET", "");
|
||||
response = new MockHttpServletResponse();
|
||||
chain = new MockFilterChain();
|
||||
this.request = new MockHttpServletRequest("GET", "");
|
||||
this.response = new MockHttpServletResponse();
|
||||
this.chain = new MockFilterChain();
|
||||
}
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,13 +91,13 @@ public class SessionManagementConfigurerServlet31Tests {
|
||||
request.setParameter("password", "password");
|
||||
HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
|
||||
CsrfToken token = repository.generateToken(request);
|
||||
repository.saveToken(token, request, response);
|
||||
repository.saveToken(token, request, this.response);
|
||||
request.setParameter(token.getParameterName(), token.getToken());
|
||||
request.getSession().setAttribute("attribute1", "value1");
|
||||
|
||||
loadConfig(SessionManagementDefaultSessionFixationServlet31Config.class);
|
||||
|
||||
springSecurityFilterChain.doFilter(request, response, chain);
|
||||
this.springSecurityFilterChain.doFilter(request, this.response, this.chain);
|
||||
|
||||
assertThat(request.getSession().getId()).isNotEqualTo(id);
|
||||
assertThat(request.getSession().getAttribute("attribute1")).isEqualTo("value1");
|
||||
@@ -137,7 +137,7 @@ public class SessionManagementConfigurerServlet31Tests {
|
||||
|
||||
private void login(Authentication auth) {
|
||||
HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
|
||||
HttpRequestResponseHolder requestResponseHolder = new HttpRequestResponseHolder(request, response);
|
||||
HttpRequestResponseHolder requestResponseHolder = new HttpRequestResponseHolder(this.request, this.response);
|
||||
repo.loadContext(requestResponseHolder);
|
||||
|
||||
SecurityContextImpl securityContextImpl = new SecurityContextImpl();
|
||||
|
||||
@@ -47,8 +47,9 @@ public class MessageSecurityMetadataSourceRegistryTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
messages = new MessageSecurityMetadataSourceRegistry();
|
||||
message = MessageBuilder.withPayload("Hi").setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "location")
|
||||
this.messages = new MessageSecurityMetadataSourceRegistry();
|
||||
this.message = MessageBuilder.withPayload("Hi")
|
||||
.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "location")
|
||||
.setHeader(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER, SimpMessageType.MESSAGE).build();
|
||||
}
|
||||
|
||||
@@ -57,85 +58,85 @@ public class MessageSecurityMetadataSourceRegistryTests {
|
||||
// https://jira.spring.io/browse/SPR-11660
|
||||
@Test
|
||||
public void simpDestMatchersCustom() {
|
||||
message = MessageBuilder.withPayload("Hi")
|
||||
this.message = MessageBuilder.withPayload("Hi")
|
||||
.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "price.stock.1.2").build();
|
||||
messages.simpDestPathMatcher(new AntPathMatcher(".")).simpDestMatchers("price.stock.*").permitAll();
|
||||
this.messages.simpDestPathMatcher(new AntPathMatcher(".")).simpDestMatchers("price.stock.*").permitAll();
|
||||
|
||||
assertThat(getAttribute()).isNull();
|
||||
|
||||
message = MessageBuilder.withPayload("Hi")
|
||||
this.message = MessageBuilder.withPayload("Hi")
|
||||
.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "price.stock.1.2").build();
|
||||
messages.simpDestPathMatcher(new AntPathMatcher(".")).simpDestMatchers("price.stock.**").permitAll();
|
||||
this.messages.simpDestPathMatcher(new AntPathMatcher(".")).simpDestMatchers("price.stock.**").permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersCustomSetAfterMatchersDoesNotMatter() {
|
||||
message = MessageBuilder.withPayload("Hi")
|
||||
this.message = MessageBuilder.withPayload("Hi")
|
||||
.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "price.stock.1.2").build();
|
||||
messages.simpDestMatchers("price.stock.*").permitAll().simpDestPathMatcher(new AntPathMatcher("."));
|
||||
this.messages.simpDestMatchers("price.stock.*").permitAll().simpDestPathMatcher(new AntPathMatcher("."));
|
||||
|
||||
assertThat(getAttribute()).isNull();
|
||||
|
||||
message = MessageBuilder.withPayload("Hi")
|
||||
this.message = MessageBuilder.withPayload("Hi")
|
||||
.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "price.stock.1.2").build();
|
||||
messages.simpDestMatchers("price.stock.**").permitAll().simpDestPathMatcher(new AntPathMatcher("."));
|
||||
this.messages.simpDestMatchers("price.stock.**").permitAll().simpDestPathMatcher(new AntPathMatcher("."));
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void pathMatcherNull() {
|
||||
messages.simpDestPathMatcher(null);
|
||||
this.messages.simpDestPathMatcher(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchersFalse() {
|
||||
messages.matchers(matcher).permitAll();
|
||||
this.messages.matchers(this.matcher).permitAll();
|
||||
|
||||
assertThat(getAttribute()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchersTrue() {
|
||||
when(matcher.matches(message)).thenReturn(true);
|
||||
messages.matchers(matcher).permitAll();
|
||||
when(this.matcher.matches(this.message)).thenReturn(true);
|
||||
this.messages.matchers(this.matcher).permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersExact() {
|
||||
messages.simpDestMatchers("location").permitAll();
|
||||
this.messages.simpDestMatchers("location").permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersMulti() {
|
||||
messages.simpDestMatchers("admin/**", "api/**").hasRole("ADMIN").simpDestMatchers("location").permitAll();
|
||||
this.messages.simpDestMatchers("admin/**", "api/**").hasRole("ADMIN").simpDestMatchers("location").permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersRole() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").hasRole("ADMIN").anyMessage().denyAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").hasRole("ADMIN").anyMessage().denyAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("hasRole('ROLE_ADMIN')");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersAnyRole() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").hasAnyRole("ADMIN", "ROOT").anyMessage().denyAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").hasAnyRole("ADMIN", "ROOT").anyMessage().denyAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("hasAnyRole('ROLE_ADMIN','ROLE_ROOT')");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersAuthority() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").hasAuthority("ROLE_ADMIN").anyMessage()
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").hasAuthority("ROLE_ADMIN").anyMessage()
|
||||
.fullyAuthenticated();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("hasAuthority('ROLE_ADMIN')");
|
||||
@@ -144,127 +145,128 @@ public class MessageSecurityMetadataSourceRegistryTests {
|
||||
@Test
|
||||
public void simpDestMatchersAccess() {
|
||||
String expected = "hasRole('ROLE_ADMIN') and fullyAuthenticated";
|
||||
messages.simpDestMatchers("admin/**", "location/**").access(expected).anyMessage().denyAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").access(expected).anyMessage().denyAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersAnyAuthority() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").hasAnyAuthority("ROLE_ADMIN", "ROLE_ROOT").anyMessage()
|
||||
.denyAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").hasAnyAuthority("ROLE_ADMIN", "ROLE_ROOT")
|
||||
.anyMessage().denyAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("hasAnyAuthority('ROLE_ADMIN','ROLE_ROOT')");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersRememberMe() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").rememberMe().anyMessage().denyAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").rememberMe().anyMessage().denyAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("rememberMe");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersAnonymous() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").anonymous().anyMessage().denyAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").anonymous().anyMessage().denyAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("anonymous");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersFullyAuthenticated() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").fullyAuthenticated().anyMessage().denyAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").fullyAuthenticated().anyMessage().denyAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("fullyAuthenticated");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMatchersDenyAll() {
|
||||
messages.simpDestMatchers("admin/**", "location/**").denyAll().anyMessage().permitAll();
|
||||
this.messages.simpDestMatchers("admin/**", "location/**").denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("denyAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMessageMatchersNotMatch() {
|
||||
messages.simpMessageDestMatchers("admin/**").denyAll().anyMessage().permitAll();
|
||||
this.messages.simpMessageDestMatchers("admin/**").denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestMessageMatchersMatch() {
|
||||
messages.simpMessageDestMatchers("location/**").denyAll().anyMessage().permitAll();
|
||||
this.messages.simpMessageDestMatchers("location/**").denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("denyAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestSubscribeMatchersNotMatch() {
|
||||
messages.simpSubscribeDestMatchers("location/**").denyAll().anyMessage().permitAll();
|
||||
this.messages.simpSubscribeDestMatchers("location/**").denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpDestSubscribeMatchersMatch() {
|
||||
message = MessageBuilder.fromMessage(message)
|
||||
this.message = MessageBuilder.fromMessage(this.message)
|
||||
.setHeader(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER, SimpMessageType.SUBSCRIBE).build();
|
||||
|
||||
messages.simpSubscribeDestMatchers("location/**").denyAll().anyMessage().permitAll();
|
||||
this.messages.simpSubscribeDestMatchers("location/**").denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("denyAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullDestMatcherNotMatches() {
|
||||
messages.nullDestMatcher().denyAll().anyMessage().permitAll();
|
||||
this.messages.nullDestMatcher().denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullDestMatcherMatch() {
|
||||
message = MessageBuilder.withPayload("Hi")
|
||||
this.message = MessageBuilder.withPayload("Hi")
|
||||
.setHeader(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER, SimpMessageType.CONNECT).build();
|
||||
|
||||
messages.nullDestMatcher().denyAll().anyMessage().permitAll();
|
||||
this.messages.nullDestMatcher().denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("denyAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpTypeMatchersMatch() {
|
||||
messages.simpTypeMatchers(SimpMessageType.MESSAGE).denyAll().anyMessage().permitAll();
|
||||
this.messages.simpTypeMatchers(SimpMessageType.MESSAGE).denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("denyAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpTypeMatchersMatchMulti() {
|
||||
messages.simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.MESSAGE).denyAll().anyMessage().permitAll();
|
||||
this.messages.simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.MESSAGE).denyAll().anyMessage()
|
||||
.permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("denyAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpTypeMatchersNotMatch() {
|
||||
messages.simpTypeMatchers(SimpMessageType.CONNECT).denyAll().anyMessage().permitAll();
|
||||
this.messages.simpTypeMatchers(SimpMessageType.CONNECT).denyAll().anyMessage().permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpTypeMatchersNotMatchMulti() {
|
||||
messages.simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.DISCONNECT).denyAll().anyMessage()
|
||||
this.messages.simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.DISCONNECT).denyAll().anyMessage()
|
||||
.permitAll();
|
||||
|
||||
assertThat(getAttribute()).isEqualTo("permitAll");
|
||||
}
|
||||
|
||||
private String getAttribute() {
|
||||
MessageSecurityMetadataSource source = messages.createMetadataSource();
|
||||
Collection<ConfigAttribute> attrs = source.getAttributes(message);
|
||||
MessageSecurityMetadataSource source = this.messages.createMetadataSource();
|
||||
Collection<ConfigAttribute> attrs = source.getAttributes(this.message);
|
||||
if (attrs == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user