3434})
3535@ EnableWebSecurity
3636@ EnableMethodSecurity (securedEnabled = true )
37- public class WebSecurityConfig /* extends WebSecurityConfigurerAdapter implements WebSecurityConfigurer<WebSecurity> */ {
37+ public class WebSecurityConfig {
3838
39- //private final AuthenticationManagerBuilder authenticationManagerBuilder;
40- //private final AuthenticationSuccessHandler authenticationSuccessHandler;
41- //private final AuthenticationManager authenticationManager;
4239 private final ApplicationUserDetailsService applicationUserDetailsService ;
4340 private final SimpleworklistProperties simpleworklistProperties ;
4441
4542 @ Autowired
4643 public WebSecurityConfig (
47- //AuthenticationManagerBuilder auth,
48- //AuthenticationSuccessHandler authenticationSuccessHandler,
49- //AuthenticationManager authenticationManager,
5044 ApplicationUserDetailsService applicationUserDetailsService ,
5145 SimpleworklistProperties simpleworklistProperties
5246 ) {
53- //this.authenticationManagerBuilder = auth;
54- //this.authenticationSuccessHandler = authenticationSuccessHandler;
55- //this.authenticationManager = authenticationManager;
5647 this .applicationUserDetailsService = applicationUserDetailsService ;
5748 this .simpleworklistProperties = simpleworklistProperties ;
5849 }
@@ -72,173 +63,6 @@ public PasswordEncoder encoder(){
7263 return new BCryptPasswordEncoder (strength );
7364 }
7465
75- /*
76- @Bean
77- public AuthenticationManager authenticationManager() throws Exception {
78- return authenticationManagerBuilder
79- .userDetailsService(userDetailsService())
80- .passwordEncoder(encoder()).and().build();
81- }
82- */
83-
84- /*
85- @Bean
86- public AuthenticationManager authenticationManager(
87- AuthenticationConfiguration authenticationConfiguration
88- ) throws Exception {
89- return authenticationConfiguration.getAuthenticationManager();
90- }
91-
92- @Bean
93- public UsernamePasswordAuthenticationFilter authenticationFilter() throws Exception {
94- UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter();
95- filter.setAuthenticationManager(authenticationManager);
96- filter.setFilterProcessesUrl(simpleworklistProperties.getWebSecurity().getLoginProcessingUrl());
97- return filter;
98- }
99-
100- private AuthenticationManagerBuilder authenticationBuilder;
101-
102- private AuthenticationManagerBuilder localConfigureAuthenticationBldr;
103-
104- private ApplicationContext context;
105-
106- private HttpSecurity http;
107-
108- private boolean disableDefaults;
109-
110- private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
111-
112- private ContentNegotiationStrategy contentNegotiationStrategy = new HeaderContentNegotiationStrategy();
113-
114- private ObjectPostProcessor<Object> objectPostProcessor = new ObjectPostProcessor<Object>() {
115- @Override
116- public <T> T postProcess(T object) {
117- throw new IllegalStateException(ObjectPostProcessor.class.getName()
118- + " is a required bean. Ensure you have used @EnableWebSecurity and @Configuration");
119- }
120- };
121-
122- private AuthenticationEventPublisher getAuthenticationEventPublisher() {
123- if (this.context.getBeanNamesForType(AuthenticationEventPublisher.class).length > 0) {
124- return this.context.getBean(AuthenticationEventPublisher.class);
125- }
126- return this.objectPostProcessor.postProcess(new DefaultAuthenticationEventPublisher());
127- }
128- */
129-
130- /**
131- * Creates the shared objects
132- * @return the shared Objects
133- */
134- /*
135- private Map<Class<?>, Object> createSharedObjects() {
136- Map<Class<?>, Object> sharedObjects = new HashMap<>();
137- sharedObjects.putAll(this.localConfigureAuthenticationBldr.getSharedObjects());
138- sharedObjects.put(UserDetailsService.class, userDetailsService());
139- sharedObjects.put(ApplicationContext.class, this.context);
140- sharedObjects.put(ContentNegotiationStrategy.class, this.contentNegotiationStrategy);
141- sharedObjects.put(AuthenticationTrustResolver.class, this.trustResolver);
142- return sharedObjects;
143- }
144-
145- private void applyDefaultConfiguration(HttpSecurity http) throws Exception {
146- http.csrf();
147- http.addFilter(new WebAsyncManagerIntegrationFilter());
148- http.exceptionHandling();
149- http.headers();
150- http.sessionManagement();
151- http.securityContext();
152- http.requestCache();
153- http.anonymous();
154- http.servletApi();
155- http.apply(new DefaultLoginPageConfigurer<>());
156- http.logout();
157- }
158- */
159- /**
160- * Creates the {@link HttpSecurity} or returns the current instance
161- * @return the {@link HttpSecurity}
162- * @throws Exception
163- */
164- @ SuppressWarnings ({ "rawtypes" , "unchecked" })
165- /*
166- protected final HttpSecurity getHttp() throws Exception {
167- if (this.http != null) {
168- return this.http;
169- }
170- AuthenticationEventPublisher eventPublisher = getAuthenticationEventPublisher();
171- this.localConfigureAuthenticationBldr.authenticationEventPublisher(eventPublisher);
172- this.authenticationBuilder.parentAuthenticationManager(authenticationManager);
173- Map<Class<?>, Object> sharedObjects = createSharedObjects();
174- this.http = new HttpSecurity(this.objectPostProcessor, this.authenticationBuilder, sharedObjects);
175- if (!this.disableDefaults) {
176- applyDefaultConfiguration(this.http);
177- ClassLoader classLoader = this.context.getClassLoader();
178- List<AbstractHttpConfigurer> defaultHttpConfigurers = SpringFactoriesLoader
179- .loadFactories(AbstractHttpConfigurer.class, classLoader);
180- for (AbstractHttpConfigurer configurer : defaultHttpConfigurers) {
181- this.http.apply(configurer);
182- }
183- }
184- configure(this.http);
185- return this.http;
186- }
187-
188-
189- ///@Override
190- public void init(WebSecurity web) throws Exception {
191- HttpSecurity http = getHttp();
192- web.addSecurityFilterChainBuilder(http).postBuildAction(() -> {
193- FilterSecurityInterceptor securityInterceptor = http.getSharedObject(FilterSecurityInterceptor.class);
194- web.securityInterceptor(securityInterceptor);
195- });
196- }
197-
198-
199- //@Override
200- public void configure(WebSecurity builder) throws Exception {
201-
202- }
203- */
204-
205- /*
206- public void configure(HttpSecurity builder) throws Exception {
207-
208- http
209- .headers((headers) -> headers.disable() )
210- .authorizeRequests((authorizeRequests) -> authorizeRequests
211- .antMatchers(
212- simpleworklistProperties.getWebSecurity().getAntPatternsPublic()
213- )
214- .permitAll()
215- .anyRequest()
216- .fullyAuthenticated()
217- )
218- .csrf()
219- .and()
220- .formLogin((formLogin) -> formLogin
221- .loginPage(simpleworklistProperties.getWebSecurity().getLoginPage())
222- .usernameParameter(simpleworklistProperties.getWebSecurity().getUsernameParameter())
223- .passwordParameter(simpleworklistProperties.getWebSecurity().getPasswordParameter())
224- .loginProcessingUrl(simpleworklistProperties.getWebSecurity().getLoginProcessingUrl())
225- .failureForwardUrl(simpleworklistProperties.getWebSecurity().getFailureForwardUrl())
226- .defaultSuccessUrl(simpleworklistProperties.getWebSecurity().getDefaultSuccessUrl())
227- //.successHandler(authenticationSuccessHandler)
228- .permitAll()
229- )
230- .csrf()
231- .and()
232- .logout((logout)-> logout
233- .logoutUrl(simpleworklistProperties.getWebSecurity().getLogoutUrl())
234- .deleteCookies(simpleworklistProperties.getWebSecurity().getCookieNamesToClear())
235- .invalidateHttpSession(simpleworklistProperties.getWebSecurity().getInvalidateHttpSession())
236- .permitAll()
237- );
238-
239- }
240- */
241-
24266 @ Bean
24367 public AuthenticationProvider authenticationProvider (){
24468 DaoAuthenticationProvider d = new DaoAuthenticationProvider ();
0 commit comments