Я пытаюсь войти в веб-приложение MVC с весенней загрузкой. но я получаю следующую ошибку.
java.lang.NoSuchMethodError: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken org.springframework.security.authentication.UsernamePasswordAuthenticationToken.unauthenticated(java.lang.Object, java.lang.Object)'
at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:81) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:227) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:217) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:359) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1735) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
@Configuration
@ComponentScan(basePackages="com.matoshree")
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
public class WebSecurityMultiConfig {
@Order(1)
@Configuration
public static class RestConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private MatoshreeUserDetailsService userDetailsService;
@Autowired
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
// @Autowired
// private JwtRequestFilter jwtRequestFilter;
@Autowired
private JwtProvider jwtProvider;
@Bean
public BCryptPasswordEncoder passwordEncoder() {
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(12);
//System.out.println("in WebSecurityConfig passwordEncoder bCryptPasswordEncoder:"+bCryptPasswordEncoder);
return bCryptPasswordEncoder;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
System.out.println("WebSecurityMultiConfig RestConfiguration configure");
http
.antMatcher("/matoshree/**")
.cors()
.and()
.csrf().disable()
// dont authenticate this particular request
.authorizeRequests().antMatchers("/matoshree/rest/loginUserWithJWT",
"/matoshree/rest/GetTransKey","matoshree/rest/registeruser","matoshree/rest/updateFCMToken",
"matoshree/rest/validateOtp","matoshree/rest/generateOtp","matoshree/rest/loginuser").permitAll().
// all other requests need to be authenticated
anyRequest().authenticated()
.and()
// .addFilter(new JwtTokenFilter(userDetailsService,jwtProvider))
// .addFilter(new JwtTokenFilter(userDetailsService,jwtProvider))
//.anyRequest().authenticated().and().
// make sure we use stateless session; session won't be used to
// store user's state.
.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
// .csrf()
// .disable() // we don't need CSRF because our token is invulnerable
// .authorizeRequests()
// .antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll()
// .antMatchers(RESET_PASSWORD_URL).permitAll()
// .anyRequest().authenticated()
// .and()
// .addFilter(new JWTAuthenticationFilter(authenticationManager()))
// .addFilter(new JWTAuthorizationFilter(authenticationManager()))
// // this disables session creation on Spring Security
// .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
// Add a filter to validate the tokens with every request
http.addFilterBefore(new JwtTokenFilter(userDetailsService,jwtProvider), UsernamePasswordAuthenticationFilter.class);
}
@Override
public void configure(AuthenticationManagerBuilder authBuilder) throws Exception {
// authBuilder.authenticationProvider(CustomAuthenticationProvider );
authBuilder.userDetailsService(userDetailsService);
}
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception{
System.out.println("in c authenticationManagerBean ");
return super.authenticationManagerBean();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// configure AuthenticationManager so that it knows from where to load
// user for matching credentials
// Use BCryptPasswordEncoder
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
}
// @Order(2)
// @Configuration
// public static class AskRestConfiguration extends WebSecurityConfigurerAdapter {
// @Autowired
// AuthenticationEntryPoint authenticationEntryPoint;
//
// @Override
// protected void configure(HttpSecurity http) throws Exception {
//// http
//// .antMatcher(ASKFAST_API + "/**")
//// .csrf().disable()
//// .authorizeRequests()
//// .anyRequest().authenticated()
//// .and()
//// .httpBasic()
//// .authenticationEntryPoint(authenticationEntryPoint)
//// .and()
//// .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) //We don't need sessions to be created.
//// ;
// }
// }
@Order(2)
@Configuration
public static class WebConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private MatoshreeUserDetailsService userDetailsService;
@Autowired
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
@Bean
public BCryptPasswordEncoder passwordEncoder() {
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(12);
//System.out.println("in WebSecurityConfig passwordEncoder bCryptPasswordEncoder:"+bCryptPasswordEncoder);
return bCryptPasswordEncoder;
}
// @Bean
// public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
// http
// //.authorizeHttpRequests()
// .authorizeRequests()
// .antMatchers("/", "/home","/login","/goToLogin").permitAll()
// .anyRequest().authenticated()
// .and()
// .formLogin()
// .loginPage("/goToLogin")
// .permitAll()
// .and()
// .logout()
// .permitAll();
//
// return http.build();
// }
@Override
protected void configure(HttpSecurity http) throws Exception {
System.out.println("WebSecurityMultiConfig WebConfiguration configure");
http.exceptionHandling().accessDeniedPage("/403");
// http
// //.authorizeHttpRequests()
// .authorizeRequests()
// //.antMatchers("/", "/home","/login","/goToLogin").permitAll()
// .anyRequest().authenticated();
// http
// .csrf().disable()
// .antMatcher("/**").authorizeRequests()
// .antMatchers("/resources/**").permitAll()
// //.antMatchers("/**").hasRole("ADMIN")
// .anyRequest().authenticated()
// .and().formLogin();
//
// http.sessionManagement().maximumSessions(1).expiredUrl("/goToLogin");
// .and()
// .formLogin()
// .loginPage("/goToLogin")
// .permitAll()
// .and()
// .logout()
// .permitAll();
// http
// .antMatcher("/**")
// // .csrf().disable()
// // .authorizeRequests()
// //.and()
//// .authorizeRequests()
//// .antMatchers("/**/favicon.ico", "/**/*.css", "/**/*.js","/**/*.jpg", "/**/*.png", "/**/*.xlsx", "/fonts/**", "/logout").permitAll()
//// .antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui.html", "/webjars/**").permitAll()
// //.antMatchers( "/goToLogin","/home","/login","/goToRegistration","/registeruser","/search").permitAll()
// //.anyRequest().authenticated()
// // .and()
// .formLogin()
// .loginPage("/goToLogin")
// .permitAll()
// .and()
// .logout()
// .permitAll();
//////
http
.antMatcher("/**")
// .csrf()
//.and()
.csrf().disable()
.authorizeRequests()
// .antMatchers("/**/favicon.ico", "/**/*.css", "/**/*.js", "/**/*.png", "/**/*.xlsx", "/fonts/**", "/logout").permitAll()
// .antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui.html", "/webjars/**").permitAll()
.antMatchers("/goToLogin","/home","/login","/goToRegistration","/registeruser","/403"/*,"/goToSearch"*/).permitAll()
.antMatchers("/search","/goToSearch").hasAnyAuthority("ROLE_ADMIN", "ROLE_SSR","ROLE_CSR","ADMIN", "SSR","CSR")
//.antMatchers(RESET_PASSWORD_PAGE_URL, PRIVACY_POLICY).permitAll()
//.anyRequest().hasAnyRole("ROLE_ADMIN", "ROLE_SSR","ROLE_CSR")
.anyRequest().authenticated()
.and()
.formLogin()
.permitAll()
.loginPage("/login")
.usernameParameter("emailId")
.passwordParameter("password")
.loginProcessingUrl("/doLogin")
// .defaultSuccessUrl("/login_success")
// .failureUrl("/login_error")
// .successForwardUrl("/login_success_handler")
// .failureForwardUrl("/login_failure_handler")
//.permitAll()
//.defaultSuccessUrl(EMPLOYEE_MVC, true)
.and()
.logout()
.logoutSuccessUrl("/login?logout");
http
.sessionManagement()
.maximumSessions(1).sessionRegistry(sessionRegistry());
}
@Bean
public SessionRegistry sessionRegistry() {
return new SessionRegistryImpl();
}
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers(
HttpMethod.GET,
"/",
"/*.html",
"/**/favicon.ico",
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.xlsx",
"/**/*.png",
"/**/*.jpg"
) ;
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
System.out.println("WebSecurityMultiConfig WebConfiguration authenticationProvider userDetailsService:"+userDetailsService);
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService);
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
System.out.println("WebSecurityMultiConfig WebConfiguration configure auth:"+auth);
auth.authenticationProvider(authenticationProvider());
}
// @Autowired
// public void configureInMemoryAuthentication(AuthenticationManagerBuilder auth) throws Exception
// {
// // auth.inMemoryAuthentication().withUser("ankush.shejal04@gmail.com").password(passwordEncoder().encode("Ankush@123")).roles("CSR");
// auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
// }
// @Override
// public void configure(AuthenticationManagerBuilder authBuilder) throws Exception {
// // authBuilder.authenticationProvider(CustomAuthenticationProvider );
// authBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
//// authBuilder.inMemoryAuthentication()
//// .withUser("ankush.shejal04@gmail.com")
//// .password(passwordEncoder().encode("Ankush@123"))
//// .authorities("ROLE_CSR");
// }
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception{
System.out.println("in c authenticationManagerBean ");
return super.authenticationManagerBean();
}
//
// @Autowired
// public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// // configure AuthenticationManager so that it knows from where to load
// // user for matching credentials
// // Use BCryptPasswordEncoder
// auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
//// auth.inMemoryAuthentication()
//// .withUser("ankush.shejal04@gmail.com")
//// .password(passwordEncoder().encode("Ankush@123"))
//// .authorities("ROLE_CSR");
// }
}
}
Подробнее здесь: https://stackoverflow.com/questions/741 ... cationtoke
Java.lang.NoSuchMethodError: '.authentication.UsernamePasswordAuthenticationToken .unauthenticated(java.lang.Object, jav ⇐ JAVA
Программисты JAVA общаются здесь
1729845497
Anonymous
Я пытаюсь войти в веб-приложение MVC с весенней загрузкой. но я получаю следующую ошибку.
java.lang.NoSuchMethodError: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken org.springframework.security.authentication.UsernamePasswordAuthenticationToken.unauthenticated(java.lang.Object, java.lang.Object)'
at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:81) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:227) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:217) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) ~[spring-security-web-5.7.1.jar:5.7.1]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.16.jar:5.3.16]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.16.jar:5.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:359) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1735) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.58.jar:9.0.58]
at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
@Configuration
@ComponentScan(basePackages="com.matoshree")
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
public class WebSecurityMultiConfig {
@Order(1)
@Configuration
public static class RestConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private MatoshreeUserDetailsService userDetailsService;
@Autowired
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
// @Autowired
// private JwtRequestFilter jwtRequestFilter;
@Autowired
private JwtProvider jwtProvider;
@Bean
public BCryptPasswordEncoder passwordEncoder() {
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(12);
//System.out.println("in WebSecurityConfig passwordEncoder bCryptPasswordEncoder:"+bCryptPasswordEncoder);
return bCryptPasswordEncoder;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
System.out.println("WebSecurityMultiConfig RestConfiguration configure");
http
.antMatcher("/matoshree/**")
.cors()
.and()
.csrf().disable()
// dont authenticate this particular request
.authorizeRequests().antMatchers("/matoshree/rest/loginUserWithJWT",
"/matoshree/rest/GetTransKey","matoshree/rest/registeruser","matoshree/rest/updateFCMToken",
"matoshree/rest/validateOtp","matoshree/rest/generateOtp","matoshree/rest/loginuser").permitAll().
// all other requests need to be authenticated
anyRequest().authenticated()
.and()
// .addFilter(new JwtTokenFilter(userDetailsService,jwtProvider))
// .addFilter(new JwtTokenFilter(userDetailsService,jwtProvider))
//.anyRequest().authenticated().and().
// make sure we use stateless session; session won't be used to
// store user's state.
.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
// .csrf()
// .disable() // we don't need CSRF because our token is invulnerable
// .authorizeRequests()
// .antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll()
// .antMatchers(RESET_PASSWORD_URL).permitAll()
// .anyRequest().authenticated()
// .and()
// .addFilter(new JWTAuthenticationFilter(authenticationManager()))
// .addFilter(new JWTAuthorizationFilter(authenticationManager()))
// // this disables session creation on Spring Security
// .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
// Add a filter to validate the tokens with every request
http.addFilterBefore(new JwtTokenFilter(userDetailsService,jwtProvider), UsernamePasswordAuthenticationFilter.class);
}
@Override
public void configure(AuthenticationManagerBuilder authBuilder) throws Exception {
// authBuilder.authenticationProvider(CustomAuthenticationProvider );
authBuilder.userDetailsService(userDetailsService);
}
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception{
System.out.println("in c authenticationManagerBean ");
return super.authenticationManagerBean();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// configure AuthenticationManager so that it knows from where to load
// user for matching credentials
// Use BCryptPasswordEncoder
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
}
// @Order(2)
// @Configuration
// public static class AskRestConfiguration extends WebSecurityConfigurerAdapter {
// @Autowired
// AuthenticationEntryPoint authenticationEntryPoint;
//
// @Override
// protected void configure(HttpSecurity http) throws Exception {
//// http
//// .antMatcher(ASKFAST_API + "/**")
//// .csrf().disable()
//// .authorizeRequests()
//// .anyRequest().authenticated()
//// .and()
//// .httpBasic()
//// .authenticationEntryPoint(authenticationEntryPoint)
//// .and()
//// .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) //We don't need sessions to be created.
//// ;
// }
// }
@Order(2)
@Configuration
public static class WebConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private MatoshreeUserDetailsService userDetailsService;
@Autowired
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
@Bean
public BCryptPasswordEncoder passwordEncoder() {
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(12);
//System.out.println("in WebSecurityConfig passwordEncoder bCryptPasswordEncoder:"+bCryptPasswordEncoder);
return bCryptPasswordEncoder;
}
// @Bean
// public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
// http
// //.authorizeHttpRequests()
// .authorizeRequests()
// .antMatchers("/", "/home","/login","/goToLogin").permitAll()
// .anyRequest().authenticated()
// .and()
// .formLogin()
// .loginPage("/goToLogin")
// .permitAll()
// .and()
// .logout()
// .permitAll();
//
// return http.build();
// }
@Override
protected void configure(HttpSecurity http) throws Exception {
System.out.println("WebSecurityMultiConfig WebConfiguration configure");
http.exceptionHandling().accessDeniedPage("/403");
// http
// //.authorizeHttpRequests()
// .authorizeRequests()
// //.antMatchers("/", "/home","/login","/goToLogin").permitAll()
// .anyRequest().authenticated();
// http
// .csrf().disable()
// .antMatcher("/**").authorizeRequests()
// .antMatchers("/resources/**").permitAll()
// //.antMatchers("/**").hasRole("ADMIN")
// .anyRequest().authenticated()
// .and().formLogin();
//
// http.sessionManagement().maximumSessions(1).expiredUrl("/goToLogin");
// .and()
// .formLogin()
// .loginPage("/goToLogin")
// .permitAll()
// .and()
// .logout()
// .permitAll();
// http
// .antMatcher("/**")
// // .csrf().disable()
// // .authorizeRequests()
// //.and()
//// .authorizeRequests()
//// .antMatchers("/**/favicon.ico", "/**/*.css", "/**/*.js","/**/*.jpg", "/**/*.png", "/**/*.xlsx", "/fonts/**", "/logout").permitAll()
//// .antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui.html", "/webjars/**").permitAll()
// //.antMatchers( "/goToLogin","/home","/login","/goToRegistration","/registeruser","/search").permitAll()
// //.anyRequest().authenticated()
// // .and()
// .formLogin()
// .loginPage("/goToLogin")
// .permitAll()
// .and()
// .logout()
// .permitAll();
//////
http
.antMatcher("/**")
// .csrf()
//.and()
.csrf().disable()
.authorizeRequests()
// .antMatchers("/**/favicon.ico", "/**/*.css", "/**/*.js", "/**/*.png", "/**/*.xlsx", "/fonts/**", "/logout").permitAll()
// .antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui.html", "/webjars/**").permitAll()
.antMatchers("/goToLogin","/home","/login","/goToRegistration","/registeruser","/403"/*,"/goToSearch"*/).permitAll()
.antMatchers("/search","/goToSearch").hasAnyAuthority("ROLE_ADMIN", "ROLE_SSR","ROLE_CSR","ADMIN", "SSR","CSR")
//.antMatchers(RESET_PASSWORD_PAGE_URL, PRIVACY_POLICY).permitAll()
//.anyRequest().hasAnyRole("ROLE_ADMIN", "ROLE_SSR","ROLE_CSR")
.anyRequest().authenticated()
.and()
.formLogin()
.permitAll()
.loginPage("/login")
.usernameParameter("emailId")
.passwordParameter("password")
.loginProcessingUrl("/doLogin")
// .defaultSuccessUrl("/login_success")
// .failureUrl("/login_error")
// .successForwardUrl("/login_success_handler")
// .failureForwardUrl("/login_failure_handler")
//.permitAll()
//.defaultSuccessUrl(EMPLOYEE_MVC, true)
.and()
.logout()
.logoutSuccessUrl("/login?logout");
http
.sessionManagement()
.maximumSessions(1).sessionRegistry(sessionRegistry());
}
@Bean
public SessionRegistry sessionRegistry() {
return new SessionRegistryImpl();
}
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers(
HttpMethod.GET,
"/",
"/*.html",
"/**/favicon.ico",
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.xlsx",
"/**/*.png",
"/**/*.jpg"
) ;
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
System.out.println("WebSecurityMultiConfig WebConfiguration authenticationProvider userDetailsService:"+userDetailsService);
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService);
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
System.out.println("WebSecurityMultiConfig WebConfiguration configure auth:"+auth);
auth.authenticationProvider(authenticationProvider());
}
// @Autowired
// public void configureInMemoryAuthentication(AuthenticationManagerBuilder auth) throws Exception
// {
// // auth.inMemoryAuthentication().withUser("ankush.shejal04@gmail.com").password(passwordEncoder().encode("Ankush@123")).roles("CSR");
// auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
// }
// @Override
// public void configure(AuthenticationManagerBuilder authBuilder) throws Exception {
// // authBuilder.authenticationProvider(CustomAuthenticationProvider );
// authBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
//// authBuilder.inMemoryAuthentication()
//// .withUser("ankush.shejal04@gmail.com")
//// .password(passwordEncoder().encode("Ankush@123"))
//// .authorities("ROLE_CSR");
// }
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception{
System.out.println("in c authenticationManagerBean ");
return super.authenticationManagerBean();
}
//
// @Autowired
// public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// // configure AuthenticationManager so that it knows from where to load
// // user for matching credentials
// // Use BCryptPasswordEncoder
// auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
//// auth.inMemoryAuthentication()
//// .withUser("ankush.shejal04@gmail.com")
//// .password(passwordEncoder().encode("Ankush@123"))
//// .authorities("ROLE_CSR");
// }
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/74177440/java-lang-nosuchmethoderror-authentication-usernamepasswordauthenticationtoke[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия