cancel
Showing results for 
Search instead for 
Did you mean: 

Authentication using user and ticket

isloat
Champ in-the-making
Champ in-the-making
Hi,
I'm trying to authenticate with the Alfresco ticket to the repository from an external web app. I'm doing the following:

String SERVER = "http://alfrescoserver:8080/alfresco/api";
WebServiceFactory.setEndpointAddress(SERVER);
//Authentication
AuthenticationDetails authDetails = new AuthenticationDetails(user,ticket, null);
AuthenticationUtils.setAuthenticationDetails(authDetails);

The ticket is valid, because the function "AuthenticationUtils.isCurrentTicketTimedOut()" returns "false".
But it throws this error: The security token could not be authenticated or authorized
I've tried to add the SessionId in the AuthenticationDetails constructor, but the exception remains.

Is any way to authenticate doing this? Or the only chance is using "startSession(USER, PASS);"?

Thanks!
2 REPLIES 2

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi isloat,

You have to first get the alfresco ticket from another webscript i.e.

http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin

This will return the alfresco ticket like

<ticket>TICKET_9d59e7ab9c6e55c9bdfe60e2c2ea3bdd605f547b</ticket>

Get the ticket from the string by  doing string operations . For e.g.

if (ticket != null && ticket.contains("TICKET"))
        {
            this.authenticationTicket = ticket.substring(ticket.lastIndexOf("TICKET"), ticket.lastIndexOf("</ticket>"));
        }

Pass the ticket in your webscript by appending the ticket in the url  as
alf_ticket=authenticationTicket .

Thanks,

isloat
Champ in-the-making
Champ in-the-making
Thank you Smiley Happy
But I already have the ticket, I don't have the password.

So, Is any way to authenticate with a valid ticket without re-typing user & pass ?

Thanks!