cancel
Showing results for 
Search instead for 
Did you mean: 

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

sam69
Champ in-the-making
Champ in-the-making
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-ac..." + ticket;
    System.out.println(urlDetail);
    String urlDownload = "http://dimension_1:8080/alfresco/download/attach/workspace/SpacesStore/66c17658-01fd-11db-ac8c-fd68b...;
    System.out.println(urlDownload);
I got my 2 urls :
http://dimension_1:8080/alfresco/navigate/showDocDetails/workspace/SpacesStore/66c17658-01fd-11db-ac...
http://dimension_1:8080/alfresco/download/attach/workspace/SpacesStore/66c17658-01fd-11db-ac8c-fd68b...
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
13 REPLIES 13

kevinr
Star Contributor
Star Contributor
I don't think you should remove the TICKET_ prefix - it is part of the string the authentication service expects. Try this again and don't modify the ticket string returned from the service.

Thanks,

Kevin

sam69
Champ in-the-making
Champ in-the-making
Thank you very much Kevin !
It's working now Smiley Happy
It was the wiki documentation that lead me wrong :
http://wiki.alfresco.com/wiki/URL_Addressability#Ticket_URL_Argument

/alfresco/download/attach/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf?ticket=1234567890

I thought that it needs only the number… My mistake.
Maybe I can modify this part of the wiki to make it clear ?

sam69
Champ in-the-making
Champ in-the-making
I have another question :
Is there a timout on tickets life ? Because I will provide a lot of url with different new tickets, and I don't want to overload Alfresco…

sam69
Champ in-the-making
Champ in-the-making
Looking the table 'alf_trasaction', it seems that the ticket are not automatically deleted.
I would like to end the session via webservices, but I can't know when the user don't need it anymore…
Perhaps I don't use the good way to do add a ticket to the url. Is there somewhere an example of code doing that ?

sam69
Champ in-the-making
Champ in-the-making
If we don't close the transaction manually, the transaction is never deleted…
So I manage to store the open transactions and close them where the user logout of my application.
But a session time out on alfresco would be great 😉

bindiya
Champ in-the-making
Champ in-the-making
Hi

I try to open document from alfresco content server in new window of my remote application , but when i click on the following link, the window opens with login page of alfresco. Even while i have provided the ticket to the url, it is still asking me to login. And then when i login it dont get to view the document.

http://localhost:8080/alfresco/download/attach/workspace/SpacesStore/4fc1e6e2-9037-11db-974b-c3e8250...

Is there anything else am missing?

Thanks,
Bindiya

sam69
Champ in-the-making
Champ in-the-making
Hi

Your url looks ok. It should works…

Are you using alfresco 1.4 ?
Your webservice transaction is still open ?
The UID of the document Guardian Form.doc is correct ? (you can check it in the detail of the document with the alfresco web client)
You can also check the alfresco log file (ex. tomcat/log) to see if there is an exception).

Cheers,
Samuel

bindiya
Champ in-the-making
Champ in-the-making
Thanks for your reply.

Yes am using alfresco 1.4 version.

Can you please elaborate on the question you asked me

Your webservice transaction is still open ?

Thanks,
Bindiya

sam69
Champ in-the-making
Champ in-the-making
If you close the session after getting the ticket, the ticket is no more available.
Ex :

String ticket = WebServiceFactory.getAuthenticationService().startSession("admin", "admin").getTicket();
    String urlDownload = "http://dimension_1:8080/alfresco/download/attach/workspace/SpacesStore/66c17658-01fd-11db-ac8c-fd68b...;
    System.out.println(urlDownload);
//If I close the session, the ticket is no more available :
WebServiceFactory.getAuthenticationService().stopSession();
//Here my url doesnt work


So if you want to keep the session open, you must not close the session.

Cheers,
Samuel