Some formatting fixes for HttpSecurity Javadoc

This commit is contained in:
Rob Winch 2016-03-09 16:45:43 -06:00
parent 2f4610e8b7
commit be36ddb614

View File

@ -88,12 +88,12 @@ import org.springframework.util.Assert;
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class FormLoginSecurityConfig extends WebSecurityConfigurerAdapter { * public class FormLoginSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin(); * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -144,13 +144,13 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class OpenIDLoginConfig extends WebSecurityConfigurerAdapter { * public class OpenIDLoginConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) { * protected void configure(HttpSecurity http) {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().openidLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().openidLogin()
* .permitAll(); * .permitAll();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication() * auth.inMemoryAuthentication()
@ -171,7 +171,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class OpenIDLoginConfig extends WebSecurityConfigurerAdapter { * public class OpenIDLoginConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) { * protected void configure(HttpSecurity http) {
* http.authorizeRequests() * http.authorizeRequests()
@ -197,7 +197,7 @@ public final class HttpSecurity extends
* .type("http://schema.openid.net/namePerson").required(true); * .type("http://schema.openid.net/namePerson").required(true);
* } * }
* } * }
* *
* public class AutoProvisioningUserDetailsService implements * public class AutoProvisioningUserDetailsService implements
* AuthenticationUserDetailsService<OpenIDAuthenticationToken> { * AuthenticationUserDetailsService<OpenIDAuthenticationToken> {
* public UserDetails loadUserDetails(OpenIDAuthenticationToken token) * public UserDetails loadUserDetails(OpenIDAuthenticationToken token)
@ -227,7 +227,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter { * public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http * http
@ -253,7 +253,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter { * public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http * http
@ -273,7 +273,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter { * public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http * http
@ -331,14 +331,14 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class SessionManagementSecurityConfig extends WebSecurityConfigurerAdapter { * public class SessionManagementSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().anyRequest().hasRole("USER").and().formLogin() * http.authorizeRequests().anyRequest().hasRole("USER").and().formLogin()
* .permitAll().and().sessionManagement().maximumSessions(1) * .permitAll().and().sessionManagement().maximumSessions(1)
* .expiredUrl("/login?expired"); * .expiredUrl("/login?expired");
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -388,7 +388,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class PortMapperSecurityConfig extends WebSecurityConfigurerAdapter { * public class PortMapperSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
@ -396,7 +396,7 @@ public final class HttpSecurity extends
* // Example portMapper() configuration * // Example portMapper() configuration
* .portMapper().http(9090).mapsTo(9443).http(80).mapsTo(443); * .portMapper().http(9090).mapsTo(9443).http(80).mapsTo(443);
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -426,7 +426,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class JeeSecurityConfig extends WebSecurityConfigurerAdapter { * public class JeeSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and()
@ -449,7 +449,7 @@ public final class HttpSecurity extends
* <form-error-page>/login?error</form-error-page> * <form-error-page>/login?error</form-error-page>
* </form-login-config> * </form-login-config>
* </login-config> * </login-config>
* *
* <security-role> * <security-role>
* <role-name>ROLE_USER</role-name> * <role-name>ROLE_USER</role-name>
* </security-role> * </security-role>
@ -497,7 +497,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class X509SecurityConfig extends WebSecurityConfigurerAdapter { * public class X509SecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and()
@ -528,12 +528,12 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class RememberMeSecurityConfig extends WebSecurityConfigurerAdapter { * public class RememberMeSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
* } * }
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
@ -564,12 +564,12 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class AuthorizeUrlsSecurityConfig extends WebSecurityConfigurerAdapter { * public class AuthorizeUrlsSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin(); * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER") * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER")
@ -586,13 +586,13 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class AuthorizeUrlsSecurityConfig extends WebSecurityConfigurerAdapter { * public class AuthorizeUrlsSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/admin/**").hasRole("ADMIN") * http.authorizeRequests().antMatchers("/admin/**").hasRole("ADMIN")
* .antMatchers("/**").hasRole("USER").and().formLogin(); * .antMatchers("/**").hasRole("USER").and().formLogin();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER") * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER")
@ -679,7 +679,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter { * public class CsrfSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http * http
@ -713,7 +713,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class LogoutSecurityConfig extends WebSecurityConfigurerAdapter { * public class LogoutSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
@ -722,7 +722,7 @@ public final class HttpSecurity extends
* .logout().logout().deleteCookies("remove").invalidateHttpSession(false) * .logout().logout().deleteCookies("remove").invalidateHttpSession(false)
* .logoutUrl("/custom-logout").logoutSuccessUrl("/logout-success"); * .logoutUrl("/custom-logout").logoutSuccessUrl("/logout-success");
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -753,7 +753,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class AnononymousSecurityConfig extends WebSecurityConfigurerAdapter { * public class AnononymousSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
@ -761,7 +761,7 @@ public final class HttpSecurity extends
* // sample anonymous customization * // sample anonymous customization
* .anonymous().authorities("ROLE_ANON"); * .anonymous().authorities("ROLE_ANON");
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -777,7 +777,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class AnononymousSecurityConfig extends WebSecurityConfigurerAdapter { * public class AnononymousSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
@ -785,7 +785,7 @@ public final class HttpSecurity extends
* // sample anonymous customization * // sample anonymous customization
* .anonymous().disabled(); * .anonymous().disabled();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -816,12 +816,12 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class FormLoginSecurityConfig extends WebSecurityConfigurerAdapter { * public class FormLoginSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin(); * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -835,7 +835,7 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class FormLoginSecurityConfig extends WebSecurityConfigurerAdapter { * public class FormLoginSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
@ -847,7 +847,7 @@ public final class HttpSecurity extends
* // with an HTTP * // with an HTTP
* // post * // post
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -880,13 +880,13 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class ChannelSecurityConfig extends WebSecurityConfigurerAdapter { * public class ChannelSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin() * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin()
* .and().requiresChannel().anyRequest().requiresSecure(); * .and().requiresChannel().anyRequest().requiresSecure();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -916,12 +916,12 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class HttpBasicSecurityConfig extends WebSecurityConfigurerAdapter { * public class HttpBasicSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and().httpBasic(); * http.authorizeRequests().antMatchers("/**").hasRole("USER").and().httpBasic();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
@ -953,7 +953,7 @@ public final class HttpSecurity extends
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.springframework.security.config.annotation.web.HttpBuilder#authenticationProvider * org.springframework.security.config.annotation.web.HttpBuilder#authenticationProvider
* (org.springframework.security.authentication.AuthenticationProvider) * (org.springframework.security.authentication.AuthenticationProvider)
@ -966,7 +966,7 @@ public final class HttpSecurity extends
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.springframework.security.config.annotation.web.HttpBuilder#userDetailsService * org.springframework.security.config.annotation.web.HttpBuilder#userDetailsService
* (org.springframework.security.core.userdetails.UserDetailsService) * (org.springframework.security.core.userdetails.UserDetailsService)
@ -983,7 +983,7 @@ public final class HttpSecurity extends
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.springframework.security.config.annotation.web.HttpBuilder#addFilterAfter(javax * org.springframework.security.config.annotation.web.HttpBuilder#addFilterAfter(javax
* .servlet.Filter, java.lang.Class) * .servlet.Filter, java.lang.Class)
@ -995,7 +995,7 @@ public final class HttpSecurity extends
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.springframework.security.config.annotation.web.HttpBuilder#addFilterBefore( * org.springframework.security.config.annotation.web.HttpBuilder#addFilterBefore(
* javax.servlet.Filter, java.lang.Class) * javax.servlet.Filter, java.lang.Class)
@ -1008,7 +1008,7 @@ public final class HttpSecurity extends
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.springframework.security.config.annotation.web.HttpBuilder#addFilter(javax. * org.springframework.security.config.annotation.web.HttpBuilder#addFilter(javax.
* servlet.Filter) * servlet.Filter)
@ -1048,16 +1048,24 @@ public final class HttpSecurity extends
* @Configuration * @Configuration
* @EnableWebSecurity * @EnableWebSecurity
* public class RequestMatchersSecurityConfig extends WebSecurityConfigurerAdapter { * public class RequestMatchersSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @Override * @Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.requestMatchers().antMatchers("/api/**", "/oauth/**").and() * http
* .authorizeRequests().antMatchers("/**").hasRole("USER").and().httpBasic(); * .requestMatchers()
* .antMatchers("/api/**", "/oauth/**")
* .and()
* .authorizeRequests()
* .antMatchers("/**").hasRole("USER")
* .and()
* .httpBasic();
* } * }
* *
* @Override * @Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); * auth
* .inMemoryAuthentication()
* .withUser("user").password("password").roles("USER");
* } * }
* } * }
* </pre> * </pre>
@ -1068,16 +1076,25 @@ public final class HttpSecurity extends
* &#064;Configuration * &#064;Configuration
* &#064;EnableWebSecurity * &#064;EnableWebSecurity
* public class RequestMatchersSecurityConfig extends WebSecurityConfigurerAdapter { * public class RequestMatchersSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* &#064;Override * &#064;Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.requestMatchers().antMatchers(&quot;/api/**&quot;).antMatchers(&quot;/oauth/**&quot;).and() * http
* .authorizeRequests().antMatchers(&quot;/**&quot;).hasRole(&quot;USER&quot;).and().httpBasic(); * .requestMatchers()
* .antMatchers(&quot;/api/**&quot;)
* .antMatchers(&quot;/oauth/**&quot;)
* .and()
* .authorizeRequests()
* .antMatchers(&quot;/**&quot;).hasRole(&quot;USER&quot;)
* .and()
* .httpBasic();
* } * }
* *
* &#064;Override * &#064;Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;); * auth
* .inMemoryAuthentication()
* .withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;);
* } * }
* } * }
* </pre> * </pre>
@ -1088,17 +1105,27 @@ public final class HttpSecurity extends
* &#064;Configuration * &#064;Configuration
* &#064;EnableWebSecurity * &#064;EnableWebSecurity
* public class RequestMatchersSecurityConfig extends WebSecurityConfigurerAdapter { * public class RequestMatchersSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* &#064;Override * &#064;Override
* protected void configure(HttpSecurity http) throws Exception { * protected void configure(HttpSecurity http) throws Exception {
* http.requestMatchers().antMatchers(&quot;/api/**&quot;).and().requestMatchers() * http
* .antMatchers(&quot;/oauth/**&quot;).and().authorizeRequests().antMatchers(&quot;/**&quot;) * .requestMatchers()
* .hasRole(&quot;USER&quot;).and().httpBasic(); * .antMatchers(&quot;/api/**&quot;)
* .and()
* .requestMatchers()
* .antMatchers(&quot;/oauth/**&quot;)
* .and()
* .authorizeRequests()
* .antMatchers(&quot;/**&quot;).hasRole(&quot;USER&quot;)
* .and()
* .httpBasic();
* } * }
* *
* &#064;Override * &#064;Override
* protected void configure(AuthenticationManagerBuilder auth) throws Exception { * protected void configure(AuthenticationManagerBuilder auth) throws Exception {
* auth.inMemoryAuthentication().withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;); * auth
* .inMemoryAuthentication()
* .withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;);
* } * }
* } * }
* </pre> * </pre>