Я следую этому уроку для аутентификации ldap весной mvc с unboundid ldap. Я запускаю его без каких-либо ошибок на сервере wildfly, но он переходит на «http://localhost: 8080 / SpringExampleJavaBase / » с исключением 404 (страница не найдена). Если кто-нибудь может помочь мне с этим. Спасибо. Файлы конфигурации следующие: SecurityConfig
package com.bsf.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().fullyAuthenticated().and().formLogin();
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication().userDnPatterns("uid={0},ou=people").groupSearchBase("ou=groups").contextSource()
.url("ldap://localhost:8389/dc=springframework,dc=org").and().passwordCompare()
.passwordEncoder(new BCryptPasswordEncoder()).passwordAttribute("userPassword");
}
}
SpringFrontController
package com.bsf.config;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class SpringFrontController extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[] { SpringConfig.class, SecurityConfig.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
SpringConfig
package com.bsf.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.bsf")
public class SpringConfig {
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setViewClass(JstlView.class);
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
}
WellcomeController
package com.bsf.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class WellcomeController {
@GetMapping("/")
public String index() {
return "Welcome to the home page!";
}
}
application.properties
spring.ldap.embedded.ldif=classpath:test-server.ldif
spring.ldap.embedded.base-dn=dc=springframework,dc=org
spring.ldap.embedded.port=8389
Журналы, которые печатаются после его запуска
[org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Infinity Minus ONE +2' 9.4.14.Final
11:43:39,176 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 76) WFLYCLINF0002: Started client-mappings cache from ejb container
11:43:39,658 INFO [io.undertow.servlet] (ServerService Thread Pool -- 90) 1 Spring WebApplicationInitializers detected on classpath
11:43:39,873 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 90) Initializing Mojarra 2.3.9.SP02 for context '/SpringExampleJavaBase'
11:43:41,335 INFO [io.undertow.servlet] (ServerService Thread Pool -- 90) Initializing Spring DispatcherServlet 'dispatcher'
11:43:41,336 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 90) Initializing Servlet 'dispatcher'
11:43:42,526 INFO [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 90) HV000001: Hibernate Validator 6.0.16.Final
11:43:42,973 INFO [org.springframework.security.ldap.DefaultSpringSecurityContextSource] (ServerService Thread Pool -- 90) URL 'ldap://localhost:8389/dc=springframework,dc=org', root DN is 'dc=springframework,dc=org'
11:43:42,976 INFO [org.springframework.ldap.core.support.AbstractContextSource] (ServerService Thread Pool -- 90) Property 'userDn' not set - anonymous context will be used for read-write operations
11:43:43,102 INFO [org.springframework.security.web.DefaultSecurityFilterChain] (ServerService Thread Pool -- 90) Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5e1a7ff, org.springframework.security.web.context.SecurityContextPersistenceFilter@3f0acc08, org.springframework.security.web.header.HeaderWriterFilter@4e89b458, org.springframework.security.web.csrf.CsrfFilter@2be1d17, org.springframework.security.web.authentication.logout.LogoutFilter@6ce911fb, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@366ac18b, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@76f4d2ec, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@dcdd606, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@7eea1a2f, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@393ffd0b, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@528678c7, org.springframework.security.web.session.SessionManagementFilter@791c3eba, org.springframework.security.web.access.ExceptionTranslationFilter@28af9f2d, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@713037ed]
11:43:43,142 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 90) Completed initialization in 1806 ms
11:43:43,142 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 90) WFLYUT0021: Registered web context: '/SpringExampleJavaBase' for server 'default-server'
11:43:43,256 INFO [org.jboss.as.server] (ServerService Thread Pool -- 44) WFLYSRV0010: Deployed "SpringExampleJavaBase.war" (runtime-name : "SpringExampleJavaBase.war")
11:43:43,335 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
11:43:43,342 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
11:43:43,342 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
11:43:43,343 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 17.0.1.Final (WildFly Core 9.0.2.Final) started in 14809ms - Started 850 of 1076 services (376 services are lazy, passive or on-demand)