If you want to customize the default account mappers, attribute mappers or adapters, you need to implement corresponding interfaces or extend an abstract class. Most of those interfaces or abstract classes have an implementation that we recommend extending when you need a custom plugin. Extending an implementation allows you to delegate the bulk of the work to the default method implementation and only perform small changes according to business requirements.
The following table shows the classes to extend and the corresponding interfaces and abstract classes:
|Plugin to customize||Implementation class to extend||Corresponding Interface or abstract class|
|IDP Account Mapper||DefaultIDPAccountMapper||IDPAccountMapper|
|SP Account Mapper||DefaultLibrarySPAccountMapper||SPAccountMapper|
|IDP Attribute Mapper||DefaultLibraryIDPAttributeMapper||IDPAttributeMapper|
|SP Attribute Mapper||DefaultSPAttributeMapper||SPAttributeMapper|
|SP Adapter||N/A||SAML2ServiceProviderAdapter (Abstract class)|
The interfaces are part of the Public API: API Javadoc › Package com.sun.identity.saml2.plugins.
Disclaimer for the following code, please review before implementing these changes. This code is just a sample; it does not include best practice for Java® code (such as error handling) and will need customizing to fit your use case. Customizing SAML2 plugins is outside the scope of ForgeRock support; if you want more tailored advice, consider engaging Deployment Support Services.
Customizing a default plugin
See the following articles for specific details on customizing the different SAML2 plugins for different use cases:
- How do I create a custom SAML2 IdP account mapper in AM (All versions)?
- How do I create a custom SAML2 SP account mapper in AM (All versions)?
- How do I create a custom SAML2 IdP attribute mapper in AM (All versions)?
- How do I create a custom SAML2 SP attribute mapper in AM (All versions)?
The basic process is:
- Git clone the AM external repository.
- Check out the relevant branch.
- Create a new Java project in your IDE.
- Add a Maven dependency to your project for the openam-federation-library.
- Create a new custom class that extends the default implementation class.
- Override the method you want to modify and insert your business logic.
- Build a .jar file containing the custom class.
- Copy the .jar file to the WEB-INF/lib/ folder where AM is deployed.
- Update the configuration for the relevant hosted entity provider by replacing the default class with your new custom class.
- Restart the web application container in which AM runs.
- Test your changes.