cancel
Showing results for 
Search instead for 
Did you mean: 

get session ticket on share

michaelp
Confirmed Champ
Confirmed Champ
Hello,

I want to get the session ticket of the currently logged in user to copy it to the clipboard (Internet Explorer).
Afterwards a java web start application should load this ticket from the clipboard to log in into the Alfresco Repository using CMIS and download a document (copying the nodeRef to the clipboard works).

Got it working:

The repo tier webscript to get the ticket:

### get-ticket.get.desc.xml
<webscript>
    <shortname>Get current ticket</shortname>
    <description>Returns a valid ticket for the currently logged in user</description>
    <url>/auth/get-ticket.js</url>
    <url>/auth/get-ticket.json.ftl</url>
    <format default="js">extension</format>
    <authentication>user</authentication>
    <transaction>none</transaction>
</webscript>

### get-ticket.get.js
function main() {
   model.sessionTicket = session.getTicket();
}
main();

### get-ticket.get.json.ftl
<#escape x as jsonUtils.encodeJSONString(x)>
{
   "ticket": "${sessionTicket}"
}
</#escape>


Client side javascript ajax call: ajax call to share tier webscript -> share tier calls repo tier webscript -> repo ws return the ticket -> share ws parses the ticket as response to the client side javascript.


                  Alfresco.util.Ajax.jsonGet(
               {
                  url: Alfresco.constants.PROXY_URI + "/auth/getTicket.json",
                  successCallback:
                  {
                     fn: function(response)
                     {
                        try {
                           var json = JSON.parse(response.serverResponse.responseText);
                           var ticket = json["ticket"];
                           if (ticket.substring(0, 6) == "TICKET") {
                              clipboardData.setData("Text", ticket);
                           } else {
                           }
                        } catch (e) {
                        }
                        
                     },
                     scope: this
                  },
                  
                  failureCallback:
                  {
                     fn: function(response)
                     {
                        
                     },
                     scope: this
                  }
               });


NOTE: you also need the share tier webscript (here "/auth/getTicket.json") which parses the ticket from the repo tier webscript!
4 REPLIES 4

kaynezhang
World-Class Innovator
World-Class Innovator
There is no such webscirpt –get-ticket.get.desc.xml out of box ,did you customize it your self?
And where are you stuck right now?

kaynezhang
World-Class Innovator
World-Class Innovator
There is no such webscirpt –get-ticket.get.desc.xml out of box ,did you customize it your self?
And where are you stuck right now?

I created the webscript by myselfe. I already got it working Smiley Happy
But thank you for wanting to help me anyway Smiley Happy

tarn2206
Champ in-the-making
Champ in-the-making
https://forums.alfresco.com/comment/155311#comment-155311

Root level object "session" is changed to "sessionticket"

Try with sessionticket.getTicket()