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 / abstract classes have an implementation that we recommend to extend 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 / abstract classes:
|Plugin to customize||Implementation class to extend||Corresponding Interface/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)|
These classes are available from the openam-federation-library-<version>.jar file located in the WEB-INF/lib directory of the AM/OpenAM WAR file. You can find the classes in the following path within the jar file: com/sun/identity/saml2/plugins.
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 Professional 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 customize the default SAML2 IdP account mapper in AM/OpenAM (All versions)?
- How do I customize the default SAML2 SP account mapper in AM/OpenAM (All versions)?
- How do I customize the default SAML2 IdP attribute mapper in AM/OpenAM (All versions)?
- How do I customize the default SAML2 SP attribute mapper in AM/OpenAM (All versions)?
The basic process is:
- Unpack the AM/OpenAM WAR file and extract the openam-federation-library-<version>.jar file.
- Create a new custom class that extends the default implementation class.
- Override the method you want to modify and insert your business logic.
- Repack the openam-federation-library-<version>.jar with your new custom class.
- Add your customization to the AM/OpenAM WAR file:
- Replace the existing jar file in the WEB-INF/lib directory with your customized jar file.
- Repack the AM/OpenAM WAR file and deploy as normal.
- 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/OpenAM runs.
- Test your changes.