10-28-2019 10:16 AM
Hi all!
This one is unusual so I hope it will be a challenge for alfresco veterans
I need to make a windows authenticated REST API call from a behavior bound to a onContentRead policy. Windows authentication must be provided from a user that triggered onContentRead event. Is there any possible way to do this?
10-30-2019 10:37 AM
Are you trying to call out to an external (non Alfresco API) from within your behavior code? Not quite sure I understand the question here.
11-04-2019 03:26 AM
Sorry i wasn't clear in the start: I'm trying to call external REST using windows authentication of the user that triggered the event.
I'm using AuthenticationUtils and I can get the username of the user that initiated the event but I can't seem to get NTML authentication provider to use with http client making the request. Also, I tried to use the Apache WinHttpCLient to make the REST API call but with no success. This is the code:
CloseableHttpClient client = WinHttpClients.createDefault(); try { URI uri = URI.create(uriString); HttpGet httpGet = new HttpGet(uri); HttpResponse response = client.execute(httpGet); HttpEntity responseEntity = response.getEntity(); String responseString = EntityUtils.toString(responseEntity, "UTF-8"); client.close(); return responseString; } catch (ParseException | IOException e) { e.printStackTrace(); logger.error("executeImpl Error: " + e.toString()); return "error"; }
It's interesting that the above code works when sending POST to external REST service from the ServiceTask in Process Services (in the implementation of the JavaDelegate interface).
Any help would be appreciated.
Explore our Alfresco products with the links below. Use labels to filter content by product module.