AnsweredAssumed Answered

'401 Unauthorized' when accessing to webscript from indicator in Alfresco Share

Question asked by ardamose123 on Nov 12, 2013
Latest reply on Nov 14, 2013 by ardamose123
I have a Share indicator whose evaluator must retrieve the result of an Alfresco webscript.

import org.alfresco.web.evaluator.BaseEvaluator;
import org.json.simple.JSONObject;
import org.springframework.extensions.webscripts.connector.Connector;

public class CustomEvaluator extends BaseEvaluator
   public boolean evaluate(JSONObject node)
         Connector conn = ThreadLocalRequestContext.getRequestContext().getServiceRegistry().getConnectorService().getConnector("alfresco");
         return"/some/webscript/run?nodeRef=" + (String) node.get("nodeRef")).getResponse().equals("YES");
      catch (ConnectorServiceException ex)
         return false;

However, when the evaluator gets executed, Alfresco returns a 401 Unauthorized HTTP response status code every time.

Other observations:
<li>If I try to access the webscript directly from the browser (since it's a simple GET method), it works fine.
<li>If I access the webscript as a Share document library action, it works fine.
<li>In the last two observations, cookies are sent in the HTTP request (JSESSION, something starting with "alf", some PHP-specific). In the evaluator one, no cookies are sent.

So, the problem must be in the way I'm trying to access it from an evaluator.

Is there any way to include the authentication information of the current session using the Connector Service to access webscripts which require authentication?