[xwiki-devs] passing a session variable to the XwikiLogin page
I would like to pass in a variable from a JSP page, named mySession, to the login page of Xwiki, such as: So when the user has valid credentials they will be redirected here: /xwiki/bin/login/XWiki/XWikiLogin/?mySession=" + session.getId(); There is some a custom authentication class written in Java that extends XwikiAuthServiceImpl and inside of the checkAuth(XWikiContext context) method I am trying to retrieve the value I passed in from the JSP page. String mySession = (String)context.getRequest().getSession().getAttribute("mySession"); The value of mySession is always null. Does anyone know where I went wrong in trying to accomplish this? -- View this message in context: http://xwiki.475771.n2.nabble.com/passing-a-session-variable-to-the-XwikiLog... Sent from the XWiki- Dev mailing list archive at Nabble.com.
I'd do this with a filter on top of the XWiki (struts?) servlet. A session object (request.getSession()) is allocated by the servlet container as soon as the browser touches it, I believe. paul Le 27 sept. 2012 à 02:46, echocoder a écrit :
I would like to pass in a variable from a JSP page, named mySession, to the login page of Xwiki, such as:
So when the user has valid credentials they will be redirected here:
/xwiki/bin/login/XWiki/XWikiLogin/?mySession=" + session.getId();
There is some a custom authentication class written in Java that extends XwikiAuthServiceImpl and inside of the checkAuth(XWikiContext context) method I am trying to retrieve the value I passed in from the JSP page.
String mySession = (String)context.getRequest().getSession().getAttribute("mySession");
The value of mySession is always null. Does anyone know where I went wrong in trying to accomplish this?
-- View this message in context: http://xwiki.475771.n2.nabble.com/passing-a-session-variable-to-the-XwikiLog... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Paul, could you tell me more about the filter process you use? -- View this message in context: http://xwiki.475771.n2.nabble.com/passing-a-session-variable-to-the-XwikiLog... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Not sure it's that, but I think there should not be an ending '/' before '?mySession=...' /xwiki/bin/login/XWiki/XWikiLogin?mySession=" + session.getId(); 2012/9/27 echocoder <[email protected]>:
I would like to pass in a variable from a JSP page, named mySession, to the login page of Xwiki, such as:
So when the user has valid credentials they will be redirected here:
/xwiki/bin/login/XWiki/XWikiLogin/?mySession=" + session.getId();
There is some a custom authentication class written in Java that extends XwikiAuthServiceImpl and inside of the checkAuth(XWikiContext context) method I am trying to retrieve the value I passed in from the JSP page.
String mySession = (String)context.getRequest().getSession().getAttribute("mySession");
The value of mySession is always null. Does anyone know where I went wrong in trying to accomplish this?
-- View this message in context: http://xwiki.475771.n2.nabble.com/passing-a-session-variable-to-the-XwikiLog... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Jerem, I tried to add the ending / before posting and it did not work as expected. -- View this message in context: http://xwiki.475771.n2.nabble.com/passing-a-session-variable-to-the-XwikiLog... Sent from the XWiki- Dev mailing list archive at Nabble.com.
On Thu, Sep 27, 2012 at 3:46 AM, echocoder <[email protected]> wrote:
I would like to pass in a variable from a JSP page, named mySession, to the login page of Xwiki, such as:
So when the user has valid credentials they will be redirected here:
/xwiki/bin/login/XWiki/XWikiLogin/?mySession=" + session.getId();
In this case "mySession" is a _request_ parameter (part of the request URL query string).
There is some a custom authentication class written in Java that extends XwikiAuthServiceImpl and inside of the checkAuth(XWikiContext context) method I am trying to retrieve the value I passed in from the JSP page.
String mySession = (String)context.getRequest().getSession().getAttribute("mySession");
Where did you set "mySession" as a session attribute? You only passed it as a request parameter, so you have to retrieve it with: String mySession = context.getRequest().getParameter("mySession"); Hope this helps, Marius
The value of mySession is always null. Does anyone know where I went wrong in trying to accomplish this?
-- View this message in context: http://xwiki.475771.n2.nabble.com/passing-a-session-variable-to-the-XwikiLog... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Thanks Marius! I set the mySession variable in a JSP file and then redirected the user to the Xwiki. I believe you are right in the fact that I overlooked getAttribute vs. getParameter. I ended up saving the value to a cookie in the JSP file, then reading the cookie from the custom authentication class. That worked for what I was trying to do. I appreciate your feedback! -Jason -- View this message in context: http://xwiki.475771.n2.nabble.com/passing-a-session-variable-to-the-XwikiLog... Sent from the XWiki- Dev mailing list archive at Nabble.com.
participants (4)
-
echocoder -
Jeremie BOUSQUET -
Marius Dumitru Florea -
Paul Libbrecht