Customizing a user signup workflow in WSO2 API Manager

Vishanth Bala
Jul 5, 2017 · 3 min read

You can follow the steps provided in the Adding a User Signup Workflow [1] for the simple steps in adding a User Signup Workflow.

Here I am going to talk about customizing the workflow to send more user claim values to the Business Process and Human Task.

You can get the sample custom signup workflow from custom-workflow-executor [2].

In the sample project I have created, the sample payload looks like below

public static final String REGISTER_USER_PAYLOAD_CUSTOM =
" <wor:UserSignupProcessRequest xmlns:wor=\"\">\n" +
" <wor:userName>$1</wor:userName>\n" +
" <wor:tenantDomain>$2</wor:tenantDomain>\n" +
" <wor:workflowExternalRef>$3</wor:workflowExternalRef>\n" +
" <wor:callBackURL>$4</wor:callBackURL>\n" +
" <wor:organization>$5</wor:organization>\n" +
" <wor:country>$6</wor:country>\n" +
" </wor:UserSignupProcessRequest>";

The code below shows how I am getting the user claim values via realm service and setting it to the payload.

String payload = REGISTER_USER_PAYLOAD_CUSTOM;//getting the user store manager
RealmService realmService = ServiceReferenceHolder.getInstance().getRealmService();
UserRealm realm = realmService.getBootstrapRealm();
UserStoreManager manager = realm.getUserStoreManager();

//getting the user claim value
String organization = manager.getUserClaimValue(tenantAwareUserName, "", null);
String country = manager.getUserClaimValue(tenantAwareUserName, "", null);
payload = payload.replace("$5", organization);
payload = payload.replace("$6", country);

You can modify the payload in CustomUserSignUpWSWorkflowExecutor class as per your requirement. Currently in the sample, I have added organization and country to the payload.

After you modify the project, build it and copy the “custom-usersignup-workflow-executor-1.0.0.jar” jar found at “workflow-executor/target” and place it at “<APIM_HOME>/repository/components/dropins”. Note: This requires a server restart.

Log in to APIM management console (https://<Server Host>:9443/carbon) and select Browse under Resources.

Go to /_system/governance/apimgt/applicationdata/workflow-extensions.xml resource, disable the Simple Workflow Executor and disable WS Workflow Executor. Then add the following UserSignUp executor for your custom signup workflow executor.

<UserSignUp executor="org.wso2.sample.workflow.executor.CustomUserSignUpWSWorkflowExecutor">
<Property name="serviceEndpoint">http://localhost:9765/services/UserSignupProcess/</Property>
<Property name="username">admin</Property>
<Property name="password">admin</Property>
<Property name="callbackURL">https://localhost:8243/services/WorkflowCallbackService</Property>

Changes to the Business Process

You can find the modified Business Process to cater the sample from the following locations

Added the following in the


<htd:presentationParameter name="organization" type="xsd:string">
<htd:presentationParameter name="country" type="xsd:string">
<htd:subject xml:lang="en-US">
Subject: Approve APIStore signup request done by $userName$ from the tenant domain $tenantDomain$
<htd:description xml:lang="en-US" contentType="text/plain">
Description: Hi Admin, please approve APIStore signup request done by $userName$ from the tenant domain $tenantDomain$, organization: $organization$, country: $country$

Added the following in the UserApprovalTash.wsdl

<xsd:complexType name="UserApprovalDataType">

<xsd:element name="organization" type="xsd:string" />
<xsd:element name="country" type="xsd:string" />

Added the following in the UserSignupProcess.bpel

<tns1:UserApprovalData xmlns:tns1="" xmlns:xsi="">
<bpel:to variable="ht_input" part="UserApprovalRequest"></bpel:to>
<bpel:assign validate="no" name="AssignInputs">

<bpel:from part="payload" variable="input">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:organization]]></bpel:query>
<bpel:to part="UserApprovalRequest" variable="ht_input">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:organization]]></bpel:query>

<bpel:from part="payload" variable="input">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:country]]></bpel:query>
<bpel:to part="UserApprovalRequest" variable="ht_input">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:country]]></bpel:query>

Added the following in the UserSignupProcessArtifacts.wsdl

<element name="UserSignupProcessRequest">
<element name="organization" type="string"/>
<element name="country" type="string"/>

With that idea, you can modify the BPEL and HumanTask according to your user claim values.

You can check out my blog [3] which says how to add new fields to the user signup page in wso2 api manager store.

Once you have the steps in [3] configured.

When you sign-up in the API Manager Store

You will be notified with the Approval Process with the following message

When you login to the admin portal (https://<server_ip>:9443/admin), you will see the customized message set at the human task as shown below.

[1] —

[2] —

[3] —

Vishanth Bala

Written by

Enthusiast on Data Science, IoT and Cloud Computing | Football Fanatic | Committer & PMC Member, Apache Stratos |

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade