/*
 * Copyright 2002-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.security.config.annotation.web.configuration;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.annotation.authentication.configuration.EnableGlobalAuthentication;
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;

/**
 * Add this annotation to an {@code @Configuration} class to have the Spring Security
 * configuration defined in any {@link WebSecurityConfigurer} or more likely by extending
 * the {@link WebSecurityConfigurerAdapter} base class and overriding individual methods:
 *
 * <pre class="code">
 * &#064;Configuration
 * &#064;EnableWebSecurity
 * public class MyWebSecurityConfiguration extends WebSecurityConfigurerAdapter {
 *
 * 	&#064;Override
 * 	public void configure(WebSecurity web) throws Exception {
 * 		web.ignoring()
 * 		// Spring Security should completely ignore URLs starting with /resources/
 * 				.antMatchers(&quot;/resources/**&quot;);
 * 	}
 *
 * 	&#064;Override
 * 	protected void configure(HttpSecurity http) throws Exception {
 * 		http.authorizeRequests().antMatchers(&quot;/public/**&quot;).permitAll().anyRequest()
 * 				.hasRole(&quot;USER&quot;).and()
 * 				// Possibly more configuration ...
 * 				.formLogin() // enable form based log in
 * 				// set permitAll for all URLs associated with Form Login
 * 				.permitAll();
 * 	}
 *
 * 	&#064;Override
 * 	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
 * 		auth
 * 		// enable in memory based authentication with a user named &quot;user&quot; and &quot;admin&quot;
 * 		.inMemoryAuthentication().withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;)
 * 				.and().withUser(&quot;admin&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;, &quot;ADMIN&quot;);
 * 	}
 *
 * 	// Possibly more overridden methods ...
 * }
 * </pre>
 *
 * @see WebSecurityConfigurer
 * @see WebSecurityConfigurerAdapter
 *
 * @author Rob Winch
 * @since 3.2
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@Import({ WebSecurityConfiguration.class, SpringWebMvcImportSelector.class, OAuth2ImportSelector.class,
		HttpSecurityConfiguration.class })
@EnableGlobalAuthentication
@Configuration
public @interface EnableWebSecurity {

	/**
	 * Controls debugging support for Spring Security. Default is false.
	 * @return if true, enables debug support with Spring Security
	 */
	boolean debug() default false;

}

@@ -17,17 +17,17 @@
 2002-202
-0
+2
  the ori
@@ -1199,16 +1199,77 @@
 figurer;
+%0Aimport org.springframework.security.web.SecurityFilterChain;
 %0A%0A/**%0A *
@@ -1438,30 +1438,27 @@
 y ex
-tend
+pos
 ing
+ a
 %0A *
- the
  %7B@link 
 WebS
@@ -1449,35 +1449,32 @@
 a%0A * %7B@link 
-Web
 Security
 ConfigurerAd
@@ -1465,71 +1465,25 @@
 rity
-ConfigurerAdapter%7D base class and overriding individual methods
+FilterChain%7D bean
 :%0A *
@@ -1602,45 +1602,8 @@
 ion 
-extends WebSecurityConfigurerAdapter 
 %7B%0A *
@@ -1609,32 +1609,28 @@
 *%0A * %09&#064;
-Override
+Bean
 %0A * %09public 
@@ -1633,64 +1633,77 @@
 lic 
-void configure(WebSecurity web) throws Exception %7B%0A * %09%09
+WebSecurityCustomizer webSecurityCustomizer() %7B%0A * %09%09return (web) -%3E 
 web.
@@ -1864,45 +1864,63 @@
 064;
-Override%0A * %09protected void configure
+Bean%0A * %09public SecurityFilterChain securityFilterChain
 (Htt
@@ -2268,267 +2268,180 @@
  * %09
-%7D%0A *%0A * %09&#064;Override%0A * %09protected void configure(AuthenticationManagerBuilder auth) throws Exception %7B%0A * %09%09auth%0A * %09%09// enable in memory based authentication with a user named &quot;user&quot; and &quot;admin&quot;%0A * %09%09.inMemoryAuthentication().withUser
+%09return http.build();%0A * %09%7D%0A *%0A * %09&#064;Bean%0A * %09public UserDetailsService userDetailsService() %7B%0A * %09%09UserDetails user = User.withDefaultPasswordEncoder()%0A * %09%09%09.username
 (&qu
@@ -2450,24 +2450,31 @@
 ;user&quot;)
+%0A * %09%09%09
 .password(&q
@@ -2484,32 +2484,39 @@
 ;password&quot;)
+%0A * %09%09%09
 .roles(&quot;USE
@@ -2534,24 +2534,92 @@
  %09%09%09
-%09.and().withUser
+.build();%0A * %09%09UserDetails admin = User.withDefaultPasswordEncoder()%0A * %09%09%09.username
 (&qu
@@ -2633,16 +2633,23 @@
 n&quot;)
+%0A * %09%09%09
 .passwor
@@ -2671,16 +2671,23 @@
 d&quot;)
+%0A * %09%09%09
 .roles(&
@@ -2687,28 +2687,29 @@
 roles(&quot;
-USER
+ADMIN
 &quot;, &quo
@@ -2714,20 +2714,91 @@
 uot;
-ADMIN
+USER
 &quot;)
+%0A * %09%09%09.build();%0A * %09%09return new InMemoryUserDetailsManager(user, admin)
 ;%0A *
@@ -2829,17 +2829,11 @@
 ore 
-overridde
+bea
 n me
@@ -2894,45 +2894,8 @@
 rer%0A
- * @see WebSecurityConfigurerAdapter%0A
  *%0A 

Remove references to WebSecurityConfigurerAdapter in EnableWebSecurity