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?
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.
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.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.