cancel
Showing results for 
Search instead for 
Did you mean: 

Tickets getting lost?

mcirwin
Champ in-the-making
Champ in-the-making
I have written a simple a small set of classes which make use of the Alfresco Web Services.  The unit tests all work when run inside Eclipse and I thought everything was fine.  I then bundled my classes in a SWT repository client and started to get the following exception:

Ticket could not be found when calling callback handler.

I am guessing that this simply means Alfresco is "forgetting" who I am.  How do I resolve this?  I am using the AuthenticationUtils to start the session and then just invoking the repository service.
Starting the session from one class:

    AuthenticationUtils.startSession(m_loginInfo.getLoginName(), m_loginInfo.getPwd());
    m_authDetails = AuthenticationUtils.getAuthenticationDetails();
and trying to use it in another (I have access to the authentication details here as well):
    RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();

    Reference spacesStoreRef = new Reference();
    spacesStoreRef.setStore(m_spacesStore);
    spacesStoreRef.setPath("/");

    QueryResult qr = repositoryService.queryChildren(spacesStoreRef);

    return getObjectImp(qr);

I tried re-writing the start session code to use the Authentication Service directly, as well as adding the ticket to the Repository Service.  Now the unit tests are failing witht he exact same problem.

    AuthenticationServiceSoapBindingStub authenticationService = WebServiceFactory.getAuthenticationService();
    m_authResult = authenticationService.startSession(m_loginInfo.getLoginName(), m_loginInfo.getPwd());
and trying to use it in another (I have access to the authentication result here as well):
    RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
    repositoryService.setPassword(m_ticket);

    Reference spacesStoreRef = new Reference();
    spacesStoreRef.setStore(m_spacesStore);
    spacesStoreRef.setPath("/");

    QueryResult qr = repositoryService.queryChildren(spacesStoreRef);

    return getObjectImp(qr);

How do I resolve this?  None of the examples I have looked at seem to show having to set tickets or anything.
What is the correct way to handle authentication?
3 REPLIES 3

mcirwin
Champ in-the-making
Champ in-the-making
I know this is something to do with the ticket callback handler in AuthenticationUtils, but how do I solve it?  There's no examples in the documentation I can see.

I know people must be using Web Services in Tomcat etc as I can see enough posts relating to them.  Please, how are you guys handling the callback?

libman
Champ in-the-making
Champ in-the-making
I get an error which looks nearly the same. The SDK examples worked. When using it in Alfresco itself (with .jar files) I got the following error:
org.alfresco.webservice.util.WebServiceException: Error starting session.
   at org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:94)
   at org.alfresco.sample.CreateMyProjectWizardTemp.finishImpl(CreateMyProjectWizardTemp.java:281)
   at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:121)
   at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:118)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:294)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:209)
   at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:127)
   at org.alfresco.sample.CreateMyProjectWizardTemp.finish(CreateMyProjectWizardTemp.java:259)
   at org.alfresco.web.bean.wizard.WizardManager.finish(WizardManager.java:580)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
   at javax.faces.component.UICommand.broadcast(UICommand.java:109)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.alfresco.module.vti.VtiContextFilter.doFilter(VtiContextFilter.java:94)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
   at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.ConnectException: Connection refused: connect
   at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
   at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.webservice.authentication.AuthenticationServiceSoapBindingStub.startSession(AuthenticationServiceSoapBindingStub.java:187)
   at org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:79)
   … 41 more
Caused by: java.net.ConnectException: Connection refused: connect
   at java.net.PlainSocketImpl.socketConnect(Native Method)
   at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
   at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
   at java.net.Socket.connect(Socket.java:519)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
   at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
   at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
   at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
   at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
   … 52 more
I thought maybe, because it's the user who executes, no (extra) authentication (the 2 first lines) where needed. But then it says something like password not found and then also something with tickets.

I must also add, that I didn't add the following code described in http://wiki.alfresco.com/wiki/Web_Service_Samples_for_Java (Using Tickets). The reason is that I don't know where to add it and if it is necessary:

<deployment xmlns='http://xml.apache.org/axis/wsdd/'
               xmlns:java='http://xml.apache.org/axis/wsdd/providers/java'>
      <transport name='http'
                 pivot='java:org.apache.axis.transport.http.HTTPSender'/>
      <globalConfiguration >
         <requestFlow >
            <handler type='java:org.apache.ws.axis.security.WSDoAllSender' >
               <parameter name='action' value='UsernameToken'/>
               <parameter name='user' value='ticket'/>
               <parameter name='passwordCallbackClass'
                value='org.alfresco.example.webservice.sample.WebServiceSample1'/>
               <parameter name='passwordType' value='PasswordText'/>
            </handler>
         </requestFlow >
      </globalConfiguration>
    </deployment>

Thanks by advance.

libman
Champ in-the-making
Champ in-the-making
I was using it in the server self (.jar). I used the Java API for remote connection, the reason I had the error.