AnsweredAssumed Answered

Pb : Add a ticket to an Alfresco url to avoid logging

Question asked by sam69 on Nov 7, 2006
Latest reply on Feb 26, 2007 by lalli
Hello !

I want to provide a link from my webapp, pointing to an Alfresco space or document.
But I want to avoid the user to login again (as the user is already logged on my website).
So the ticket url argument looks like what I need :
http://wiki.alfresco.com/wiki/URL_Addressability#Ticket_URL_Argument

I manage to get a ticket through webservice, and append it to my url, but it  doesn't work.
Here is my test code :

//get ticket :
    String ticket = WebServiceFactory.getAuthenticationService().startSession("admin", "admin").getTicket();
    //remove "TICKET_" prefixe and add "?ticket="
    ticket = "?ticket=" + ticket.substring("TICKET_".length());
    String urlDetail = "http://dimension_1:8080/alfresco/navigate/showDocDetails/workspace/SpacesStore/66c17658-01fd-11db-ac8c-fd68b7f6067a" + ticket;
    System.out.println(urlDetail);
    String urlDownload = "http://dimension_1:8080/alfresco/download/attach/workspace/SpacesStore/66c17658-01fd-11db-ac8c-fd68b7f6067a/DojoToolkitInPractice.pdf'+ticket;
    System.out.println(urlDownload);
I got my 2 urls :
http://dimension_1:8080/alfresco/navigate/showDocDetails/workspace/SpacesStore/66c17658-01fd-11db-ac8c-fd68b7f6067a?ticket=fe6b936a-0200-11db-a1da-5f639c2effba
http://dimension_1:8080/alfresco/download/attach/workspace/SpacesStore/66c17658-01fd-11db-ac8c-fd68b7f6067a/DojoToolkitInPractice.pdf?ticket=fe6b936a-0200-11db-a1da-5f639c2effba
Just after, I past it in IE -> I have a servlet exception :

java.lang.IllegalStateException: Impossible de cr?er une sessionapr?s que la r?ponse ait ?t? envoy?e
Translation of the message : Unable to create a session after response has been sent.
org.apache.catalina.connector.Request.doGetSession(Request.java:2206)
   org.apache.catalina.connector.Request.getSession(Request.java:2024)
   org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:831)
   org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:842)
   org.alfresco.web.app.servlet.BaseServlet.redirectToLoginPage(BaseServlet.java:158)
   org.alfresco.web.app.servlet.BaseServlet.servletAuthenticate(BaseServlet.java:129)
   org.alfresco.web.app.servlet.DownloadContentServlet.doGet(DownloadContentServlet.java:108)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

And when I try the urls in firefox, I don't have an exception but I get the alfresco's identification screen. If I login, it show the right page.

I run the 1.4.0 version of alfresco on Windows XP Pro.

Does the ticket argument is working ? Somebody manage to get it work with a ticket obtain from web services ?

Thanks,
Samuel

Outcomes