How to authenticate contentService in workflow

cancel
Showing results for 
Search instead for 
Did you mean: 
pnature
Established Member

How to authenticate contentService in workflow

Hi

I am new on Alfresco. I am using community version 5.2 

In my workflow I have service task with java class. There I get Alfresco service registry

             // Get services
            Map<Object, Object> registeredBeans = Context.getProcessEngineConfiguration().getBeans();
            ServiceRegistry registry = (ServiceRegistry)registeredBeans.get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
            ContentService contentService = registry.getContentService();

I want to use content service to read content of document associated with workflow

// Get Document
ActivitiScriptNode scriptNode = (ActivitiScriptNode) execution.getVariable("docnode");
docref = new NodeRef("workspace://SpacesStore/18fb353f-d525-4dbc-98ec-d91a3faccbe0"); //test with fixed existing file in repo
ContentReader reader = contentService.getReader(docref, ContentModel.PROP_CONTENT);
originalInputStream = reader.getContentInputStream();
filename = scriptNode.getName();

Unfortunately contentService.getReader ends up with excetion

Caused by: net.sf.acegisecurity.providers.ProviderNotFoundException: No authentication provider for net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken

Help me plesase how to get rid of it.

Thank you in advance.

4 Replies
afaust
Master

Re: How to authenticate contentService in workflow

You may need to provide additional information about your workflow. Specifically I would be interested to know how the service task is integrated into the execution flow, e.g. if it is an asynchronous service task, triggered by a timer or some other condition that can lead to it being executed without an active user authentication.

pnature
Established Member

Re: How to authenticate contentService in workflow

Hi, thank you for response.

As I wrote service task is java class type

<serviceTask id="servicetask1" name="Send Mail" activiti:class="com.comp.sendMailProcess.task.sendMail"/>

Implementation I described in question above. There is not any other condition.

afaust
Master

Re: How to authenticate contentService in workflow

That doesn't help at all - it'd probably be best/easiest for you to just attach the BPMN file...

pnature
Established Member

Re: How to authenticate contentService in workflow

Hi. I have attached BPMN, java class and java script to start process.