Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Process Manager (Stardust) » Logging in and creating user programmatically
Logging in and creating user programmatically [message #1701159] Thu, 09 July 2015 15:05 Go to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011

I would like to embed Stardust into my Spring-based web application. I created the tables for Stardust in my database and I'm trying to create a new user through the UserService interface in code.

userService.createUser(request.getUsername(), null, null, null, request.getPassword(), null, null, null);

The above code results in an AccessForbiddenException with the following error code: AUTHx00101 - Not logged in.
The UserService interface doesn't have a login method but I looked up the UserServiceBean class and it has it. I logged into the default domain and partition with the default (motu) user with the code below:

Map<String, String> properties = new HashMap<String, String>();
properties.put(SecurityProperties.PARTITION, "default");
properties.put(SecurityProperties.DOMAIN, "default");
((UserServiceBean) userService).login("motu", "motu", properties);

The login method returns a LoggedInUser object for the motu account. Now if after this I call the UserService.createUser(...) method I get the same error code what I described above. I also tried to call the UserService.startSession(...) method after login but that didn't work either.

What is the proper way to do this? Do I really have to authenticate myself in code to perform a user creation operation? Having to cast the interface to a concrete class doesn't seem right to me, the other option would be to cast it to ManagedService I guess but that doesn't feel right either. What am I missing here?
Re: Logging in and creating user programmatically [message #1701201 is a reply to message #1701159] Thu, 09 July 2015 19:46 Go to previous messageGo to next message
Jan Hendrik Scheufen is currently offline Jan Hendrik ScheufenFriend
Messages: 77
Registered: October 2011


when interacting with the Stardust API an authentication is always required. Especially creating users can only be done with an Administrator account, like "motu".
You should start by acquiring a ServiceFactory instance which is typically done through the ServiceFactoryLocator, e.g.:


The ServiceFactoryLocator uses the file on your classpath to determine which kind of ServiceFactory is to be created, e.g. one that uses Spring HTTP Remoting.

Please see the documentation here:


Re: Logging in and creating user programmatically [message #1701238 is a reply to message #1701201] Fri, 10 July 2015 07:54 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Is using the ServiceFactoryLocator the proper way for Spring-based applications? I generated a standalone Spring-based Stardust application with the tc7-ipp-portal-war Maven archetype and it defines service beans in the carnot-spring-services-context.xml file this way:

   <bean id="carnotWorkflowService"
      class="org.eclipse.stardust.engine.api.spring.WorkflowServiceBean" />

   <bean id="carnotUserService"
      class="org.eclipse.stardust.engine.api.spring.UserServiceBean" />

   <bean id="carnotQueryService"
      class="org.eclipse.stardust.engine.api.spring.QueryServiceBean" />

   <bean id="carnotAdministrationService"
      class="org.eclipse.stardust.engine.api.spring.AdministrationServiceBean" />

   <bean id="carnotDocumentManagementService"
      class="org.eclipse.stardust.engine.api.spring.DocumentManagementServiceBean" />

   <bean id="carnotReportingService" lazy-init="true"
      class="org.eclipse.stardust.reporting.rt.service.spring.ReportingServiceBean" />

   <bean abstract="true" id="abstractCarnotService"
      <property name="carnotProperties" ref="customCarnotProperties" />
      <property name="transactionManager" ref="carnotTxManager" />
      <property name="dataSource" ref="xaAuditTrailConnectionFactory" />
      <property name="jcaResourceProvider" ref="carnotJcaResourceResolver" />
      <property name="jmsResourceProvider" ref="carnotJmsResourceResolver" />
    <bean abstract="true" name="abstractPublicCarnotService"
      <!--property name="principalProvider" ref="whatever" / -->

My problem is that services acquired through the ServiceFactoryLocator won't be part of the ApplicationContext, thus they won't be managed by the Spring IoC-container at all.
Re: Logging in and creating user programmatically [message #1701246 is a reply to message #1701238] Fri, 10 July 2015 08:35 Go to previous message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
OK, I figured it out. There's a SpringServiceFactory class which implements Spring's ApplicationContextAware interface. You have to define this class as the value of the Client.ServiceFactory property in the When you call the ServiceFactoryLocator for a ServiceFactory it knows it needs to return a SpringServiceFactory based on this property, and this factory has access to the application context and your service beans defined in it since it's implementing the ApplicationContextAware interface.
Previous Topic:Example Spring Test Project
Next Topic:Activity instance not created when starting process instance programmatically
Goto Forum:

Current Time: Fri Dec 08 20:42:06 GMT 2023

Powered by FUDForum. Page generated in 1.01726 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top