package pl.relayonit.prtr.configuration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.security.web.authentication.HttpStatusEntryPoint; import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import org.springframework.security.web.util.matcher.NegatedRequestMatcher; import org.springframework.security.web.util.matcher.OrRequestMatcher; import org.springframework.security.web.util.matcher.RequestMatcher; import pl.relayonit.prtr.repository.UserRepository; import pl.relayonit.prtr.security.JwtConfigurer; import pl.relayonit.prtr.security.JwtTokenProvider; import pl.relayonit.prtr.security.NoRedirectStrategy; import javax.servlet.http.HttpServletResponse; @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class WebSecurityConfig extends WebSecurityConfigurerAdapter { private static final RequestMatcher PUBLIC_URL = new OrRequestMatcher( new AntPathRequestMatcher("/auth/**")); private static final RequestMatcher PROTECTED_URL = new NegatedRequestMatcher(PUBLIC_URL); private final JwtTokenProvider jwtTokenProvider; private final PasswordEncoder passwordEncoder; public WebSecurityConfig(JwtTokenProvider jwtTokenProvider, PasswordEncoder passwordEncoder) { this.jwtTokenProvider = jwtTokenProvider; //this.userDetailsService = userDetailsService; this.passwordEncoder = passwordEncoder; } @Bean @Override return super.authenticationManagerBean(); } @Bean public AuthenticationEntryPoint unauthorizedEntryPoint() { return (request, response, authExcepition) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } @Override { auth.userDetailsService(userDetailsService()).passwordEncoder((PasswordEncoder) passwordEncoder); } @Override { web.ignoring().requestMatchers(PUBLIC_URL); } @Override { http .httpBasic().disable() .csrf().disable() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .authorizeRequests() .antMatchers("/auth/login", "/auth/register").permitAll() .antMatchers("/api/v1/**").hasRole("ADMIN") .antMatchers("/api/v1/**").hasRole("GIOS_ADMIN") .antMatchers("/api/v1/**").hasRole("OPERATOR_WIOS") .antMatchers("/api/v1/**").hasRole("OPERATOR_INSTALACJI") .anyRequest().authenticated() .and() .csrf().disable() .exceptionHandling().authenticationEntryPoint(unauthorizedEntryPoint()) .and() .apply(new JwtConfigurer(jwtTokenProvider)); /* http.authorizeRequests() .antMatchers("/oauth/token").permitAll() .anyRequest().authenticated() .and() .httpBasic() .and() .csrf().disable() .formLogin().disable();*/ } @Bean AuthenticationSuccessHandler successHandler() { final SimpleUrlAuthenticationSuccessHandler successHandler = new SimpleUrlAuthenticationSuccessHandler(); successHandler.setRedirectStrategy(new NoRedirectStrategy()); return successHandler; } @Bean AuthenticationEntryPoint forbiddenEntyry() { return new HttpStatusEntryPoint(HttpStatus.FORBIDDEN); } }
Standard input is empty
Main.java:34: error: class WebSecurityConfig is public, should be declared in a file named WebSecurityConfig.java public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ^ Main.java:3: error: package org.springframework.context.annotation does not exist import org.springframework.context.annotation.Bean; ^ Main.java:4: error: package org.springframework.context.annotation does not exist import org.springframework.context.annotation.Configuration; ^ Main.java:5: error: package org.springframework.http does not exist import org.springframework.http.HttpStatus; ^ Main.java:6: error: package org.springframework.security.authentication does not exist import org.springframework.security.authentication.AuthenticationManager; ^ Main.java:7: error: package org.springframework.security.config.annotation.authentication.builders does not exist import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; ^ Main.java:8: error: package org.springframework.security.config.annotation.method.configuration does not exist import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; ^ Main.java:9: error: package org.springframework.security.config.annotation.web.builders does not exist import org.springframework.security.config.annotation.web.builders.HttpSecurity; ^ Main.java:10: error: package org.springframework.security.config.annotation.web.builders does not exist import org.springframework.security.config.annotation.web.builders.WebSecurity; ^ Main.java:11: error: package org.springframework.security.config.annotation.web.configuration does not exist import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; ^ Main.java:12: error: package org.springframework.security.config.annotation.web.configuration does not exist import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; ^ Main.java:13: error: package org.springframework.security.config.http does not exist import org.springframework.security.config.http.SessionCreationPolicy; ^ Main.java:14: error: package org.springframework.security.crypto.password does not exist import org.springframework.security.crypto.password.PasswordEncoder; ^ Main.java:15: error: package org.springframework.security.web does not exist import org.springframework.security.web.AuthenticationEntryPoint; ^ Main.java:16: error: package org.springframework.security.web.authentication does not exist import org.springframework.security.web.authentication.AuthenticationSuccessHandler; ^ Main.java:17: error: package org.springframework.security.web.authentication does not exist import org.springframework.security.web.authentication.HttpStatusEntryPoint; ^ Main.java:18: error: package org.springframework.security.web.authentication does not exist import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; ^ Main.java:19: error: package org.springframework.security.web.util.matcher does not exist import org.springframework.security.web.util.matcher.AntPathRequestMatcher; ^ Main.java:20: error: package org.springframework.security.web.util.matcher does not exist import org.springframework.security.web.util.matcher.NegatedRequestMatcher; ^ Main.java:21: error: package org.springframework.security.web.util.matcher does not exist import org.springframework.security.web.util.matcher.OrRequestMatcher; ^ Main.java:22: error: package org.springframework.security.web.util.matcher does not exist import org.springframework.security.web.util.matcher.RequestMatcher; ^ Main.java:23: error: package pl.relayonit.prtr.repository does not exist import pl.relayonit.prtr.repository.UserRepository; ^ Main.java:24: error: package pl.relayonit.prtr.security does not exist import pl.relayonit.prtr.security.JwtConfigurer; ^ Main.java:25: error: package pl.relayonit.prtr.security does not exist import pl.relayonit.prtr.security.JwtTokenProvider; ^ Main.java:26: error: package pl.relayonit.prtr.security does not exist import pl.relayonit.prtr.security.NoRedirectStrategy; ^ Main.java:28: error: package javax.servlet.http does not exist import javax.servlet.http.HttpServletResponse; ^ Main.java:34: error: cannot find symbol public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ^ symbol: class WebSecurityConfigurerAdapter Main.java:31: error: cannot find symbol @Configuration ^ symbol: class Configuration Main.java:32: error: cannot find symbol @EnableWebSecurity ^ symbol: class EnableWebSecurity Main.java:33: error: cannot find symbol @EnableGlobalMethodSecurity(prePostEnabled = true) ^ symbol: class EnableGlobalMethodSecurity Main.java:36: error: cannot find symbol private static final RequestMatcher PUBLIC_URL = new OrRequestMatcher( new AntPathRequestMatcher("/auth/**")); ^ symbol: class RequestMatcher location: class WebSecurityConfig Main.java:37: error: cannot find symbol private static final RequestMatcher PROTECTED_URL = new NegatedRequestMatcher(PUBLIC_URL); ^ symbol: class RequestMatcher location: class WebSecurityConfig Main.java:39: error: cannot find symbol private final JwtTokenProvider jwtTokenProvider; ^ symbol: class JwtTokenProvider location: class WebSecurityConfig Main.java:42: error: cannot find symbol private final PasswordEncoder passwordEncoder; ^ symbol: class PasswordEncoder location: class WebSecurityConfig Main.java:44: error: cannot find symbol public WebSecurityConfig(JwtTokenProvider jwtTokenProvider, PasswordEncoder passwordEncoder) { ^ symbol: class JwtTokenProvider location: class WebSecurityConfig Main.java:44: error: cannot find symbol public WebSecurityConfig(JwtTokenProvider jwtTokenProvider, PasswordEncoder passwordEncoder) { ^ symbol: class PasswordEncoder location: class WebSecurityConfig Main.java:53: error: cannot find symbol public AuthenticationManager authenticationManagerBean() throws Exception { ^ symbol: class AuthenticationManager location: class WebSecurityConfig Main.java:58: error: cannot find symbol public AuthenticationEntryPoint unauthorizedEntryPoint() { ^ symbol: class AuthenticationEntryPoint location: class WebSecurityConfig Main.java:63: error: cannot find symbol protected void configure(AuthenticationManagerBuilder auth) throws Exception ^ symbol: class AuthenticationManagerBuilder location: class WebSecurityConfig Main.java:69: error: cannot find symbol public void configure(final WebSecurity web) throws Exception ^ symbol: class WebSecurity location: class WebSecurityConfig Main.java:75: error: cannot find symbol protected void configure(final HttpSecurity http) throws Exception ^ symbol: class HttpSecurity location: class WebSecurityConfig Main.java:106: error: cannot find symbol AuthenticationSuccessHandler successHandler() { ^ symbol: class AuthenticationSuccessHandler location: class WebSecurityConfig Main.java:113: error: cannot find symbol AuthenticationEntryPoint forbiddenEntyry() { ^ symbol: class AuthenticationEntryPoint location: class WebSecurityConfig Main.java:51: error: cannot find symbol @Bean ^ symbol: class Bean location: class WebSecurityConfig Main.java:57: error: cannot find symbol @Bean ^ symbol: class Bean location: class WebSecurityConfig Main.java:105: error: cannot find symbol @Bean ^ symbol: class Bean location: class WebSecurityConfig Main.java:112: error: cannot find symbol @Bean ^ symbol: class Bean location: class WebSecurityConfig Main.java:36: error: cannot find symbol private static final RequestMatcher PUBLIC_URL = new OrRequestMatcher( new AntPathRequestMatcher("/auth/**")); ^ symbol: class OrRequestMatcher location: class WebSecurityConfig Main.java:36: error: cannot find symbol private static final RequestMatcher PUBLIC_URL = new OrRequestMatcher( new AntPathRequestMatcher("/auth/**")); ^ symbol: class AntPathRequestMatcher location: class WebSecurityConfig Main.java:37: error: cannot find symbol private static final RequestMatcher PROTECTED_URL = new NegatedRequestMatcher(PUBLIC_URL); ^ symbol: class NegatedRequestMatcher location: class WebSecurityConfig Main.java:52: error: method does not override or implement a method from a supertype @Override ^ Main.java:54: error: cannot find symbol return super.authenticationManagerBean(); ^ symbol: variable super location: class WebSecurityConfig Main.java:59: error: cannot find symbol return (request, response, authExcepition) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); ^ symbol: variable HttpServletResponse location: class WebSecurityConfig Main.java:62: error: method does not override or implement a method from a supertype @Override ^ Main.java:65: error: cannot find symbol auth.userDetailsService(userDetailsService()).passwordEncoder((PasswordEncoder) passwordEncoder); ^ symbol: class PasswordEncoder location: class WebSecurityConfig Main.java:65: error: cannot find symbol auth.userDetailsService(userDetailsService()).passwordEncoder((PasswordEncoder) passwordEncoder); ^ symbol: method userDetailsService() location: class WebSecurityConfig Main.java:68: error: method does not override or implement a method from a supertype @Override ^ Main.java:74: error: method does not override or implement a method from a supertype @Override ^ Main.java:93: error: cannot find symbol .apply(new JwtConfigurer(jwtTokenProvider)); ^ symbol: class JwtConfigurer location: class WebSecurityConfig Main.java:80: error: cannot find symbol .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) ^ symbol: variable SessionCreationPolicy location: class WebSecurityConfig Main.java:107: error: cannot find symbol final SimpleUrlAuthenticationSuccessHandler successHandler = new SimpleUrlAuthenticationSuccessHandler(); ^ symbol: class SimpleUrlAuthenticationSuccessHandler location: class WebSecurityConfig Main.java:107: error: cannot find symbol final SimpleUrlAuthenticationSuccessHandler successHandler = new SimpleUrlAuthenticationSuccessHandler(); ^ symbol: class SimpleUrlAuthenticationSuccessHandler location: class WebSecurityConfig Main.java:108: error: cannot find symbol successHandler.setRedirectStrategy(new NoRedirectStrategy()); ^ symbol: class NoRedirectStrategy location: class WebSecurityConfig Main.java:114: error: cannot find symbol return new HttpStatusEntryPoint(HttpStatus.FORBIDDEN); ^ symbol: class HttpStatusEntryPoint location: class WebSecurityConfig Main.java:114: error: cannot find symbol return new HttpStatusEntryPoint(HttpStatus.FORBIDDEN); ^ symbol: variable HttpStatus location: class WebSecurityConfig 65 errors
Standard output is empty