[xwiki-devs] Setting a session variable in the Xwiki Context to a value defined in HTTP session
My instance of Xwiki is using custom authentication. I have a new requirement to add Yubikey based authentication now. I believe in order to pull it off, I need to set a session attribute in the Xwiki context with a value defined in a JSP file. I tried to set it in the current HTTP session, with the code below but it is not showing up in the Xwiki context session when the checkAuth method is called ... session.setAttribute("okc_sso_username", username); ... public XWikiUser checkAuth(XWikiContext context) throws XWikiException { .... String okc_sso_username = (String)context.getRequest().getSession().getAttribute("okc_sso_username"); .... } Any idea on how to bind the two to make a JSP session variable available in the XwikiContext? -- View this message in context: http://xwiki.475771.n2.nabble.com/Setting-a-session-variable-in-the-Xwiki-Co... Sent from the XWiki- Dev mailing list archive at Nabble.com.
On 09/13/2012 02:55 PM, echocoder wrote:
My instance of Xwiki is using custom authentication. I have a new requirement to add Yubikey based authentication now. I believe in order to pull it off, I need to set a session attribute in the Xwiki context with a value defined in a JSP file.
I tried to set it in the current HTTP session, with the code below but it is not showing up in the Xwiki context session when the checkAuth method is called
... session.setAttribute("okc_sso_username", username); ...
public XWikiUser checkAuth(XWikiContext context) throws XWikiException { .... String okc_sso_username = (String)context.getRequest().getSession().getAttribute("okc_sso_username"); .... }
Any idea on how to bind the two to make a JSP session variable available in the XwikiContext?
Well, a session is usually valid inside one application. Since XWiki doesn't use JSP, I'm assuming that the JSP file is either in a different application, or you added a custom page to the XWiki webapp. Are you sure the two contexts share the same session? If you added the file to XWiki, then the session should be the same. Make sure you're using the right API calls to get to the session object. If you have two distinct applications, you could configure your container to use server-wide sessions. -- Sergiu Dumitriu http://purl.org/net/sergiu/
I think the problem is that the sessions are different. What is set in one is not available in the other. I am not able to embed the JSP page into the Xwiki because this particular JSP page is a login form to construct user credentials for a custom Xwiki authentication class. My guess is that the user would have to be authenticated to see any of the Xwiki pages due to the setup. I am using Tomcat as the container, trying to determine how to implement server-wide sessions now. If the session values I am trying to set are XML strings with user credentials, I am thinking that setting up the session to span the server may be problematic when others attempt a concurrent login. -- View this message in context: http://xwiki.475771.n2.nabble.com/Setting-a-session-variable-in-the-Xwiki-Co... Sent from the XWiki- Dev mailing list archive at Nabble.com.
participants (2)
-
echocoder -
Sergiu Dumitriu