Spring social NoSuchMethodError SocialAuthenticationFilter.getFilterProcessesUrl() [英] Spring social NoSuchMethodError SocialAuthenticationFilter.getFilterProcessesUrl()

查看:552
本文介绍了Spring social NoSuchMethodError SocialAuthenticationFilter.getFilterProcessesUrl()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用spring security登录。现在我正在尝试添加spring social facebook登录,但是我收到很多错误信息。

I use spring security login. Now I'm trying to add spring social facebook login, but I get many error information.

首先,当我尝试使用像春季社交指南,我不能 @Autowired私人Facebook facebook

First, when I try to use the same method like spring social guide, I can't @Autowired private Facebook facebook

我找到了解决方案

@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook(ConnectionRepository repository) {
    Connection<Facebook> connection = repository
            .findPrimaryConnection(Facebook.class);
    return connection != null ? connection.getApi() : null;
}

接下来,我收到错误找不到bean。我必须添加:

Next, I get the error "cannot find bean". I have to add:

 @Bean
 public ConnectionRepository connectionRepository() {
 Authentication authentication = SecurityContextHolder.getContext()
 .getAuthentication();
 if (authentication == null) {
 throw new IllegalStateException(
 "Unable to get a ConnectionRepository: no user signed in");
 }
 return usersConnectionRepository().createConnectionRepository(
 authentication.getName());
 }

@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
    ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();

     registry.addConnectionFactory(new FacebookConnectionFactory(facebookid,
                facebookSecure));

    return registry;
}

@Bean
public AuthenticationNameUserIdSource authenticationNameUserIdSource(){
    return new  AuthenticationNameUserIdSource();
}


@Bean
public ConnectController connectController(
        ConnectionFactoryLocator connectionFactoryLocator,
        ConnectionRepository connectionRepository) {
    return new ConnectController(connectionFactoryLocator,
            connectionRepository);
}

@Bean
public UsersConnectionRepository usersConnectionRepository() {
    return new JdbcUsersConnectionRepository(dataSource,
            connectionFactoryLocator(), Encryptors.noOpText());
}

之后,我还有其他问题 java.lang .NoSuchMethodError:org.springframework.social.security.SocialAuthenticationFilter.getFilterProcessesUrl()Ljava / lang / String;

After that, I have other issue java.lang.NoSuchMethodError: org.springframework.social.security.SocialAuthenticationFilter.getFilterProcessesUrl()Ljava/lang/String;

@Bean
  public SocialAuthenticationServiceLocator socialAuthenticationServiceLocator() {
    SocialAuthenticationServiceRegistry registry = new SocialAuthenticationServiceRegistry();
    registry.addConnectionFactory(new FacebookConnectionFactory(facebookid,
            facebookSecure));
    return registry;
}

     @Bean
 public SocialAuthenticationFilter socialAuthenticationFilter()
 throws Exception {
 SocialAuthenticationFilter filter = new SocialAuthenticationFilter(
 authenticationManager(), authenticationNameUserIdSource(),
 usersConnectionRepository(), socialAuthenticationServiceLocator());
 filter.setFilterProcessesUrl("/login");
 filter.setSignupUrl("/signup");
 filter.setConnectionAddedRedirectUrl("/home");
 filter.setPostLoginUrl("/home"); // always open account profile
 // page after login
 // filter.setRememberMeServices(rememberMeServices());
 return filter;
 }

但总是一样。

这是我的http配置

        http.csrf()
            .disable()
            .authorizeRequests()
            .antMatchers("/home", "/css/**", "/**/*.css*", "/", "/signup",
                    "/facebook", "/signup.xhtml").permitAll().anyRequest()
               .authenticated().and().formLogin().loginPage("/login").loginProcessingUrl("/login/authenticate")
            .defaultSuccessUrl("/home").failureUrl("/login")

            .permitAll().and().logout().logoutUrl("/logout")
            .invalidateHttpSession(true).logoutSuccessUrl("/").and()
            .apply(new SpringSocialConfigurer());

和控制器

@RequestMapping(value = "/login", method = RequestMethod.GET)
 public String loginPage() {
 return "redirect:/login/authenticate/connect/facebook";

 }

我做了一整个教程。接下来,我删除了 SocialConfigurer 实现并创建了相同的(不是 @Override ,只有 @Bean 社交文件

I did a whole tutorial. Next, I removed SocialConfigurer implementation and created the same (not @Override, only @Bean) social documentation.

'正常登录'(春季安全)工作正常,但我无法使用spring security配置spring社交。我使用 JSF .XHTML 文件。

'Normal login '(spring security) works fine, but I can't configure spring social with spring security. I use JSF and .XHTML files.

也许有人知道我犯了哪些错误吗?

Maybe someone knows where I make the mistakes?

感谢您的帮助。

推荐答案

请注意,春季安全4不接受春季社交1.1.0。请将所有spring社交依赖项(config,core,security和web)升级到1.1.2.RELEASE。你可以将你的春季社交Facebook留给1.1.0

Please notice that spring security 4 will not accept spring social 1.1.0. Please upgrade all spring social dependencies(config, core, security and web) to 1.1.2.RELEASE. You can leave your spring social Facebook to 1.1.0

这篇关于Spring social NoSuchMethodError SocialAuthenticationFilter.getFilterProcessesUrl()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆