Custom filter assemblies

To create a custom filter you must add an assembly that implements the IPortalFilter interface.

Note: A custom assembly can only be used if Infor Public Sector and Infor Public Sector Rest Services are installed in an on-premises environment.

To create your assembly, create a .NET 4.6.1 project and add references to these assemblies:

  • Core.dll
  • Infor.PublicSector.Rest.Subsystem.Framework.dll
  • Services.Core.CoreModels.dll
  • Services.Core.Framework
  • Services.Core.Interfaces.dll
  • ServiceStack.ServiceInterface.dll

To define your filter you must implement the AddFilter method, as shown in this example:

using Infor.PublicSector.Services.Core.Framework.ServiceExtensions.Interfaces;
using Infor.PublicSector.Services.Core.Framework.Mapping;
using Infor.PublicSector.Services.Core.Framework.Modeling;
using Hansen.Core.Data;
using Infor.PublicSector.Rest.Subsystem.Framework.Host;
using Infor.PublicSector.Services.Core.Framework.Authentication;
using Infor.PublicSector.Services.Core.Framework;
using Infor.PublicSector.Services.Core.CoreModels;
 
namespace InforDev
{
  public class TestPortalFilter : IPortalFilter
  {
    public void AddFilter(IMappingDescriptorContext context, 
        ComponentModelAssociation association)
    {
      var session = SubsystemHost.RequestState.Session as IpsAuthUserSession;
      var portalUser = PortalAuthUtilities.GetPortalUser(session);
 
      var m = context.ModelMapContext.Request.Model;
      if (m is GenericRequest)
      {
        string mName = ((GenericRequest)m).Moniker;
        if (string.Compare(mName, "InforClient.RhythmTest.Ap1Boolean", true) == 0)
        {
          association.WhereOperatives.Add(
            new IDOperativeByCommonID(
              "RhythmTest",
              "Ap1Boolean.ApplicationDetailKey.BuildingApplication.Applicants.Contact.
                  ContactKey",
              ComparisonOperator.Equal,
              portalUser.Contact.ContactKey));
        }
      }
    }
  }
}

In this example, the TestPortalFilter class uses the generic service to access the database. Because the generic service is used, you must also specify the moniker of the agency business object. The IDOperativeByCommonID object is used to compare the contact key in the detail record to the current user.

After you compile your assembly, place the dll in the bin directory in your Rest Services application directory.

The final step is to add a reference to your assembly. To do this add a child Model node to the Security > Filters node in the Portal configuration. For the Model Name attribute, specify Infor.PublicSector.Services.Core.CoreModels.GenericRequest. For the Extension - Moniker / Type attribute, specify the fully qualified name of the class that you created, followed by the name of your assembly.

For example, if the sample code shown above is in an assembly called InforDev.PublicSector.Custom.dll, you would enter InforDev.TestPortalFilter,InforDev.PublicSector.Custom.