cancel
Showing results for 
Search instead for 
Did you mean: 

TICKET problem in Alfresco Session

alexcocia
Champ in-the-making
Champ in-the-making
Hi all,

I want to keep Alfresco session along with my app session, and when navigating through the tree, some times (no reason or patron seen), it shows the following error, when trying to get a node's children

this is how I get the node's children:
queryResult = WebServiceFactory.getRepositoryService().queryChildren(reference);

and it's output:
WSDoAllSender: password callback failed; nested exception is:
org.alfresco.webservice.util.WebServiceException: Ticket could not be found when calling callback handler.

I'm not using clustering in the server…..

Any ideas?
Thanks in advance….
18 REPLIES 18

robertoroberto
Champ in-the-making
Champ in-the-making
I have the same problem. The ticket go lost.
Smiley Sad

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

The CookieHandler, as you will have noticed, is not required for the web service call to work.  However, what it does do is ensure that the JSESSION id cookie value is mantained on web service calls to the applicaiton server.

This is important because it prevents web sessions, perticularily in Tomcat, from being created everytime a web service request is made.  Instead by maintaining the JSESSION only one web serssion per ticket is create.  So its worth looking at using the cookie header if you've reimplemenated AuthenticationUtils to ensure you don't run into this silent issue.

Cheers,
Roy

robertoroberto
Champ in-the-making
Champ in-the-making
Hi, I have problem with Authentication web service.
I have a web application with some users.

1. I access with a username, I call authentication web service and i get the ticket.
2. I access to a myspaces web script with that ticket and all is OK.
3. I do logout and I call AuthenticationUtils.endSession
4. I access with an other username,  I call authentication web service and i get another the ticket.
5. When I access to myspaces web script it redirect on alfresco login page.

I must open an other browser session to correctly access to myspaces webscript with an other user.
Onyone can help me? is there a solution or there are bug in authentication web service?

sorry for my english

naples78
Champ in-the-making
Champ in-the-making
Hi,

I've a similar problem. I get authentication to alfresco via web service and access to user space via http given the ticket id in the url.(/alfresco/navigate/browse.jsp?ticket="TICKET_……")
When i perform a logout and logon with a different user ( with the same procedure webservice+http) alfresco shows the previous user space.

I  have seen that the problem is about the two calls, web service and http, because two different sessions are created.
I call endSession via webservice to invalidate the session(created after the startSession) but the http session is still valid.

Then when the session is not created the ticket has importance but when the session is already open with the browser the ticket has not importance!!

It is a bug or normal function?
Is there a solution to use the same session id?

(please sorry for my bad English)

Thanks,
Guido

robertoroberto
Champ in-the-making
Champ in-the-making
Hi, How I can modify code of Authentication webService?
regards

vanhoeck
Champ in-the-making
Champ in-the-making
I also have a similar problem. We would like to do a Lucene-Query, by using only a ticket to authorize. The problem here is that we don't have Authentication Details from previous sessions. Anyone have an idea on how to fix that?

Greetings,
Tim

madnicow
Champ in-the-making
Champ in-the-making
I had the same problem as Naples78 but I found why I can't logout and then login with a different user using a different ticket.
It's because when we lauch a new web session, the first time, the ticket provided in the url is used to authenticate the user.
At this moment, the  user object is maintain in the session.The next time you try to enter a new ticket in the url, the ticket will be ignored and this is the user object  in the web session that is used. (You can easily see that if try to open a new session with a different valid ticket, you will see that you will be connected with the other user).

In order to solve this problem, I forced Alfresco to use the ticket provided in the url and not the object in the web session. You have to overwrite the org.alfresco.web.app.servlet.AuthenticationHelper class.
In authenticate(ServletContext context, HttpServletRequest httpRequest, HttpServletResponse httpResponse, String ticket) method in order to not use the User object in session if the ticket is different.

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi Alexcocia

As i seen that you have solved ticket problem, me also facing the same.
I am passing the ticket id after the URL then also it is showing the login screen and then it is not taking admin (username) and admin(password).

If i paste this URL(with ticket id) in a new browser then it is showing the following error—

System Error

java.lang.IllegalStateException: Cannot create a session after the response has been committed


Is there any configuration required in alfresco server for getting the valid ticket.
Bold line (regarding NTLM) in the below document is not clear to me.I got the following documentation which i am following —-

Security
Access to content or pages in the web-client is protected by the same node level security as any other API within Alfresco. If a request for node content is made without an appropriate security context, a login page will be presented. If NTLM or other single sign-on authentication is present, then it will be used if applicable. Guest Access or a Ticket URL Argument can also be used if appropriate to avoid the login page.

Guest Access
Guest access is now supported for all Alfresco URLs. The URL parameter guest=true can be appended to any Alfresco URL and the login page will not be displayed before the URL is processed. The Guest user must have access to the item referenced by the URL or the access attempt will fail. For example:

http://myserver:8080/alfresco/download/attach/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf?g...
Guest access allows URLs to be sent in emails etc. to provide external access to content or template rendering results to users who do not have an Alfresco login. If the Guest login is successful then the URL will not require a login page, however if guest access fails the Login page is shown as normal. Also, if a permissions check to the template or node referenced by the URL fails then the Login page is shown.

Ticket URL Argument
If the API you are using wishes to use a servlet directly and does not require the Alfresco web-client screen for security authentication, then you must aquire a valid Authentication ticket from the appropriate API call - you can use a Web-Services API call to request a ticket.

This can then be appended to any servlet URL as the ticket argument to provide authentication without login, for example:

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




Kindly help me.

Regards
Nishant

mayanksahai
Champ in-the-making
Champ in-the-making
Hi sylvain ,

thanks for interesting post. i implemented the code provided by you but while calling service.Query it throws excception
that – PASSWORD NOT FOUND.

i am writing the code to upload bulk of files from file system to alfresco repository.
my logic is :

1) I use "admin" admin as username password combination and establishes a session.
2) use ur code to store the Authentication details.
3) use Executor Service to spool threads – each thread performing an upload in alfresco repository.
4) my issue is that i want to share authentication details with call to service in each thread.
i see that service is having the ticket information associated with it but still it says passowrd not found.

code is :

public boolean serve(){
       try{
        details = WebServiceClient.startSession(username, password);
       }catch(AuthenticationFault f){
          f.printStackTrace();
       }
      String[] files = generatefileName();
      for(String name : files)
         pool.execute( new Handler(name , details)); ———— spooling thread to upload files.
      WebServiceClient.endSession(details); – i feel error could be here…..calling thread may be clsoing the session.
      return uploaded;
   }
   
   
   public class Handler implements Runnable{
      private String fileName;
      private AuthenticationDetails authDetails;
         
      public Handler(String fileName , AuthenticationDetails details){
         this.fileName = fileName;
         this.authDetails = details;
      }

      public void run() {
            
           try{
           
           String customerId = "1";      
         // start session using authentication util.
           String[] files = {fileName};
         String name = "PATH:\"app:company_home/cm:TaxPlanning/*\"" ;
         logger.log(Level.DEBUG, name);
         RepositoryServiceSoapBindingStub service = WebServiceClient.getRepositoryService(authDetails);
         //service.setPassword("admin");
         Query query = new Query(Constants.QUERY_LANG_LUCENE,name );
         QueryResult queryResult = service.query(STORE, query, true);
         logger.log(Level.DEBUG, " query result size is ::"+queryResult.getResultSet().getTotalRowCount() );
         // bind to content service.
         ContentServiceSoapBindingStub contentService =WebServiceClient.getContentService(authDetails);
         //contentService.setPassword("admin");
         // create parent reference
         ParentReference companyHomeParent = new ParentReference(STORE, null, "/app:company_home/cm:TaxPlanning",
                  Constants.ASSOC_CONTAINS, "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + "TaxDocs");
         NamedValue[] contentProps = new NamedValue[3];
         NamedValue[] titledProps = new NamedValue[2];
         CML cml = new CML();
         Query query1 = new Query();
         for(String fileName : files){
          // Assign name to children
          companyHomeParent.setChildName("{http://www.alfresco.org/model/content/1.0}" + fileName);
          //
          ContentFormat contentFormat = new ContentFormat("Adobe PDF Document", "UTF-8");
          contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, fileName);
          contentProps[1] = Utils.createNamedValue(Constants.PROP_CONTENT, contentFormat.getMimetype());
          contentProps[2] = Utils.createNamedValue(Constants.PROP_USER_ORGID, customerId);
          //Construct CML statement to add titled aspect
          titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, fileName);
          titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "Tax Document for customer");
         
          CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_VERSIONABLE, contentProps, null, "1");
          // query to search for existing file with same name
          query1 = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"app:company_home/cm:TaxPlanning/cm:" + fileName + "\"");
          ResultSet rs =service.query(STORE, query1, false).getResultSet();
          // file already exist, then, delete it and create a new one
          if(rs.getTotalRowCount() > 0){
             System.out.println("file found ::" + fileName);
             ResultSetRow[] rsRows = rs.getRows();
             System.out.println("Removing file " + rsRows[0].getColumns(3).getValue()); //show file name
             Reference reference = new Reference(STORE, rsRows[0].getNode().getId(), null);
             System.out.println("removing reference" + rsRows[0].getNode().getId());
             Predicate predicate = new Predicate(new Reference[]{reference}, null, null);
             CMLDelete delete = new CMLDelete(predicate);
             cml.setDelete(new CMLDelete[] {delete});
             service.update(cml);
          }
          logger.log(Level.INFO, "creating new content from scratch");
          //create content
          // Construct CML statement to create content node
          // Note: Assign "1" as a local id, so we can refer to it in subsequent
          // CML statements within the same CML block
          CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, Constants.PROP_CONTENT, contentProps);
          // Construct CML Block
          cml = new CML();
          cml.setAddAspect(new CMLAddAspect[] {addAspect});
          cml.setCreate(new CMLCreate[] {create});
          // Issue CML statement via Repository Web Service and retrieve result
          // Note: Batching of multiple statements into a single web call
          UpdateResult[] result = service.update(cml);
          Reference content = result[0].getDestination();
         
          // Write some content
          //ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
          FileInputStream fi = new FileInputStream("/home/mayank/Desktop/" + "ITR Doc.pdf");
          BufferedInputStream is = new BufferedInputStream(fi);
          byte[] bytes = ContentUtils.convertToByteArray(is);
          ContentFormat format = new ContentFormat("application/pdf", "UTF-8");
             // Write the content
          contentService.write(content, Constants.PROP_CONTENT, bytes, format);
         }
         uploaded = true;
         
       }