对于带有JSF应用程序的SocialAuth库,重定向后的SocialAuthManager对象("manager")是否为NULL? [英] SocialAuthManager object ('manager') becomes NULL after redirection in case of SocialAuth libraries with JSF application?

查看:89
本文介绍了对于带有JSF应用程序的SocialAuth库,重定向后的SocialAuthManager对象("manager")是否为NULL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JSF应用程序中使用SocialAuth库提供使用google/facebook登录".如下所示,它要求我在会话中存储SocialAuthManager对象("manager"),然后重定向到"google/facebook" URL

I am using SocialAuth libraries in my JSF application for providing 'login with google/facebook'. As shown below it requires me to stores the SocialAuthManager object ('manager') in the session and then redirect to 'google/facebook' URL

//Create an instance of SocialAuthManager and set config
SocialAuthManager manager = new SocialAuthManager();
manager.setSocialAuthConfig(config);

// URL of YOUR application which will be called after authentication
String successUrl= "http://opensource.brickred.com/socialauthdemo/socialAuthSuccessAction.do";

// get Provider URL to which you should redirect for authentication.
// id can have values "facebook", "twitter", "yahoo" etc. or the OpenID URL
String url = manager.getAuthenticationUrl(id, successUrl);

// Store in session
session.setAttribute("authManager", manager);

然后从会话中获取来自Facebook/重定向的succssfull/失败重定向的经理",如下所示:

Then get the 'manager' from session on succssfull/failure redirection from facebook/redirect as shown below:

// get the social auth manager from session
SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");

// call connect method of manager which returns the provider object.
// Pass request parameter map while calling connect method.    
AuthProvider provider = manager.connect(SocialAuthUtil.getRequestParametersMap(request));

// get profile
Profile p = provider.getUserProfile();

问题是,如果我已经在浏览器的选项卡"之一中登录了Facebook或google,则可以正常运行.但是,如果我尚未登录,则会话将变为NULL,因此也将变为"manager".

The problem is if I am already logged in to facebook or google in a one of the 'tab' of the browser then this works perfectly OK. But if I am not logged in already then session becomes NULL and consequently 'manager' as well.

换句话说,如果发生从我的应用程序到Facebook到我的应用程序"的重定向,则它将失败.如果我已经登录到Facebook,那么重定向不会发生,并且可以正常工作.

In other words if redirection from 'my application to facebook to my application' happens then it fails. If I am already logged in to facebook then redirection does not happens and it works.

有人可以帮忙吗? 注意:这在IE情况下效果很好,但在Chrome&莫齐拉

Can someone help? NOTE: this works perfectly well in case of IE but does not work in case of Chrome & Mozila

推荐答案

此行为的原因是您正在从不同的域调用重定向的页面,因此当页面重定向发生时,您的会话数据将丢失. 请查看此链接

the reason for this behavior is that you are calling the redirected page from different domain so when page redirection happens your session data is lost. please have a look at this link

http://31stdimension.blogspot. in/2012/04/how-to-connect-facebook-using-jsfjava.html

这篇关于对于带有JSF应用程序的SocialAuth库,重定向后的SocialAuthManager对象("manager")是否为NULL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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