diff --git a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfigDemo.java b/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfigDemo.java deleted file mode 100644 index 0e80b7bc9c..0000000000 --- a/spring-security-oauth/spring-security-oauth-resource/src/main/java/org/baeldung/config/OAuth2ResourceServerConfigDemo.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.baeldung.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; -import org.springframework.security.oauth2.provider.token.TokenStore; -import org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore; - -//@Configuration -//@EnableResourceServer -public class OAuth2ResourceServerConfigDemo extends ResourceServerConfigurerAdapter { - - // - - @Override - public void configure(final HttpSecurity http) throws Exception { - // @formatter:off - http - .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) - .and().authorizeRequests().anyRequest().authenticated(); - ; - // @formatter:on - } - - @Bean - public TokenStore tokenStore() { - return new InMemoryTokenStore(); - } - -} diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfigDemo.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfigDemo.java deleted file mode 100644 index e37cd93e63..0000000000 --- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/OAuth2AuthorizationServerConfigDemo.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.baeldung.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; -import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; -import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; -import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; -import org.springframework.security.oauth2.provider.token.TokenStore; -import org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore; - -//@Configuration -//@EnableAuthorizationServer -public class OAuth2AuthorizationServerConfigDemo extends AuthorizationServerConfigurerAdapter { - - @Autowired - @Qualifier("authenticationManagerBean") - private AuthenticationManager authenticationManager; - - // - - @Override - public void configure(final AuthorizationServerSecurityConfigurer oauthServer) throws Exception { - oauthServer.tokenKeyAccess("permitAll()").checkTokenAccess("isAuthenticated()"); - } - - @Override - public void configure(final ClientDetailsServiceConfigurer clients) throws Exception { // @formatter:off - clients.inMemory() - .withClient("fooClientIdPassword") - .secret("secret") - .authorizedGrantTypes("password", "authorization_code", "refresh_token") - .scopes("foo", "read", "write") - .accessTokenValiditySeconds(3600) // 1 hour - .refreshTokenValiditySeconds(2592000) // 30 days - ; - } // @formatter:on - - @Override - public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception { - endpoints.tokenStore(tokenStore()).authenticationManager(authenticationManager); - } - - @Bean - public TokenStore tokenStore() { - return new InMemoryTokenStore(); - } - -}