AnsweredAssumed Answered

get session ticket on share

Question asked by michaelp on Aug 1, 2014
Latest reply on Aug 5, 2014 by michaelp

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
    <shortname>Get current ticket</shortname>
    <description>Returns a valid ticket for the currently logged in user</description>
    <format default="js">extension</format>

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

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

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.

                  url: Alfresco.constants.PROXY_URI + "/auth/getTicket.json",
                     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
                     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!