对于带有JSF应用程序的SocialAuthManager库,重定向后SocialAuthManager对象(';manager';)将变为NULL?

对于带有JSF应用程序的SocialAuthManager库,重定向后SocialAuthManager对象(';manager';)将变为NULL?,jsf,jsf-2,socialauth,Jsf,Jsf 2,Socialauth,我在JSF应用程序中使用Socialuth库提供“使用google/facebook登录”。如下所示,它要求我在会话中存储SocialAuthManager对象(“manager”),然后重定向到“google/facebook”URL //Create an instance of SocialAuthManager and set config SocialAuthManager manager = new SocialAuthManager(); manager.setSocialAuth

我在JSF应用程序中使用Socialuth库提供“使用google/facebook登录”。如下所示,它要求我在会话中存储SocialAuthManager对象(“manager”),然后重定向到“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/redirect的成功/失败重定向会话中获取“管理器”,如下所示:

// 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,并因此成为“管理器”

换句话说,如果发生从“我的应用程序到facebook到我的应用程序”的重定向,则会失败。如果我已经登录到facebook,那么重定向就不会发生,而且可以正常工作

有人能帮忙吗?
注意:这在IE中非常有效,但在Chrome&Mozila中不起作用。这种行为的原因是您正在从不同的域调用重定向的页面,因此当页面重定向发生时,您的会话数据将丢失。 请看一下这个链接


您是如何在这里创建会话的???不,我使用的是同一个域,唯一的区别是启动发生在bean上,重定向发生在servlet上