Create Custom Attribute Flow Handlers -- Archived
- Phillip Hanegan
By default, EmpowerID retrieves attribute values for each user account in a connected account store and maps them value for value to the corresponding Person attributes stored in the EmpowerID Identity Warehouse. However, EmpowerID allows you to create your own Attribute Flow Handlers to translate these values differently as needed for your scenarios. You do this by creating a class library in Workflow Studio that inherits from the DefaultAttributeflowHandler class and overriding the method specific to the account store (external or EmpowerID) you wish to effect.
In addition to creating the custom Attribute Flow Handler, you also redefine the Attribute Flow Assembly and Attribute Flow Type for the specific Security Boundary Attributes you are customizing, setting the values to that of the assembly that gets created when you publish the class library and that of the full name of your custom class. Once you have accomplished this, the next time attribute flow occurs, the affected values will be updated in the appropriate system.
In this article, we demonstrate how to create a custom Attribute Flow Handler that transforms the State attribute value contained in an external account store to the abbreviation for those states so that the abbreviated value appears as the State attribute value for the corresponding Person records in the EmpowerID Identity Warehouse. We demonstrate this by doing the following:
- Creating a Attribute Flow Handler class library in Workflow Studio and adding code to the class library to:
- Inherit from the DefaultAttributeflowHandler class
- Override the SetPersonAttribute() method of the DefaultAttributeflowHandler class to abbreviate the State attribute for user accounts in the external system so that those attributes appear in the abbreviated form for each corresponding Person record in EmpowerID
- Editing the State Security Boundary Attribute for EmpowerID in the EmpowerID Web interface
As a best practice, class libraries are created in Workflow Studio and edited in Visual Studio. We follow this practice in this article.
To create a Custom Attribute Flow Handler
In Workflow Studio, right-click on the folder in which you want to create the attribute flow handler and select New Extension or Library > Class Library (.NET Framework).
This opens the C# Editor for the class library.- Click the Save button above the C# Editor and name the file appropriately.
- Close the class library project and then locate it in your source control tree.
- Double-click the project to open it Visual Studio.
- In Visual Studio, open the class library in the editor and add code to do the following:
- Inherit from TheDotNetFactory.People.Components.InboxManagers.DefaultAttributeflowHandler base class
- Override the SetPersonAttribute() method, passing in thePersonandAccountObjectAttributeInboxobjects as parameters. TheAccountObjectAttributeInboxobject is the class used for processing attributes that flow from external account stores to EmpowerID.
The code should look similar to the following example. Please note that the name of your class will differ accordingly.When you create a class library, Workflow Studio automatically adds C= TheDotNetFactory.People.Components as a shorthand Using statement for TheDotNetFactory.People.Components namespace. This allows you to quickly reference the assembly in your code as "C."
public class MyCustomAttributeFlowHandler: C.InboxManagers.DefaultAttributeflowHandler { public override bool SetPersonAttribute(Person person, AccountObjectAttributeInbox attributeInbox) { } }
- In the C# Editor for the custom Attribute Flow Handler, add code to the SetPersonAttribute() method do the following:
- Create a new instance of the SecurityBoundaryAttribute class, calling the GetPersonAttribute() method to return the attributes in the AccountObjectAttributeInbox
- Loop through the State attributes for each account, truncating the values for each to the abbreviated form for that state.
Return the abbreviated form.
The code for the above should look similar to the following.public class MyCustomAttributeFlowHandler : C.InboxManagers.DefaultAttributeflowHandler { public override bool SetPersonAttribute(Person person, AccountObjectAttributeInbox attributeInbox) { //Create new instance of SecurityBoundaryAttribute and call GetPersonAttribute() to return the attributes in the Attribute Inbox SecurityBoundaryAttribute personAttribute = SecurityBoundaryAttribute.GetPersonAttribute(attributeInbox.ObjectAttributeID); //Create variable to hold the results var state = attributeInbox.StringValue; //Loop through the State attributes and abbreviate each switch (state) { case "Massachusetts": state = "MA"; break; case "Missouri": state = "MO"; break; case "New York": state = "NY"; break; case "Texas": state = "TX"; break; default: state = null; break; } //Return state return person.SetAttributeValue(personAttribute.Name, state); } }
- Next, build the solution to create .pub file for it on your machine.
You should see Workflow Studio successfully publish the file.
At this point, the class library is simply published to your local file system. In order to make it available to users in the EmpowerID Web application, you need to run the PublishWorkflowStudioItem workflow in the Web application.
Publish the class library to your environment
- Log in to the EmpowerID web application as a user with the appropriate access to run the PublishWorkflowStudioItem workflow.
On the navbar, expand Object Administration > Workflows and click the Publish Workflow Studio Item action link.
Click Choose File, navigate to the _PublishedItems folder and select the pub file for the class library you just published and then click Submit.
Now that custom Attribute Flow Handler has been created and published, the next step is to instruct EmpowerID to use it for processing the State attributes found in the external account store. This is demonstrated below.
To edit the State Security Boundary Attribute for EmpowerID
- On the navbar of the EmpowerID Web interface, expand Admin > Applications and Directories and click Manage Schema.
- On the Schema page, select the Security Boundary Attributes tab and the click the drop-down arrow to the right of the Search button. This allows you to perform advanced searching.
- In the Advanced Search dialog that opens, enter State in the Name field and select EmpowerID from the Security Boundary Type drop-down.
- Click Search to load the grid with the attribute.
- From the grid, click the Edit button to the left of the State attribute.
- In the Edit dialog that appears, do the following:
- In the Custom Flow Handler field, enter the full name of the class library you created. This should be similar to TheDotNetFactory.Framework.ClassLibrary.CustomAttributeFlowHandler where CustomAttributeFlowHandler is the name of your class library.
- In the Attribute Flow Assembly field, enter the name of the Attribute Flow assembly you just created above, followed by the version number, Culture, and PublicKeyToken information as comma separated values. This entry should look similar to CustomAttributeFlowHandler, Version=4.0.180.1, Culture=neutral, PublicKeyToken=2d2253f74d4496ef where CustomAttributeFlowHandler and Version=4.0.180.1 is the respective name and version number of the assembly in your environment.
- Click Save.
Testing the custom attribute handler
To test the custom attribute handler, create a new test user account in the target account store with an EmpowerID Person linked to that account and set the value of the State attribute to Massachusetts. If the handler is working correctly, during the next inventory run the value of the attribute should be transformed to MA on the EmpowerID Person.
- On the sidebar of the EmpowerID Web interface, expand Identity Administration and click People.
- Click the Create Person Advanced action link.
- From the General tab of the Create Person form that appears, enter the following information:
- First Name – First name of the person
- Last Name – Last name of the person
- Login – Login of the person
Select a Role and Location – Click the link and set the primary Business Role and Location for the person to Temporary Role in Temporary Location.
The General tab of the form should similar to the below image.
- Click the Contact Information tab and select Massachusetts from the State drop-down.
- Click Save to create the new person.
After EmpowerID creates the person, you should see the State attribute reflecting the custom value. You can view this in the Contact pane on the Person's ViewOne page.