自定义登录表单

时间:2014-11-12 13:17:37

标签: java spring authentication spring-security ldap

我从Spring框架网站上获取了Spring Security示例,并使其工作。现在我必须扩展它,以便我可以使用由我自定义的登录表单。我想我需要改变这种方法:

  

protected void configure(HttpSecurity http)

有谁知道怎么做?`

    package hello;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;

@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

     @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/css/**").permitAll().anyRequest()
                .fullyAuthenticated().and().formLogin();


    @Configuration
    protected static class AuthenticationConfiguration extends
            GlobalAuthenticationConfigurerAdapter {

        @Override
        public void init(AuthenticationManagerBuilder auth) throws Exception {
            auth.ldapAuthentication().userDnPatterns("uid={0},ou=otherpeople")
                    .groupSearchBase("ou=groups").contextSource()
                    .ldif("classpath:test-server.ldif");
        }
    }
}

0 个答案:

没有答案
相关问题