How To
ForgeRock Identity Platform
Does not apply to Identity Cloud

How do I customize the default SAML2 IdP attribute mapper in AM (All versions)?

Last updated Apr 13, 2021

The purpose of this article is to provide information on customizing the default SAML2 attribute mapper for the hosted IdP in AM. This is achieved by extending the DefaultLibraryIDPAttributeMapper class that implements the IDPAttributeMapper interface.

1 reader recommends this article


If you want to customize the default attribute mapper, for example to map a LDAP attribute name and value to a custom format for a specific SP, you can do this by implementing a custom IDPAttributeMapper. This is achieved by extending the DefaultLibraryIDPAttributeMapper class. This class is available from the openam-federation-library-<version>.jar file located in the WEB-INF/lib directory of the AM WAR file. You can find this class in the following path within the jar file: 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 the default IdP attribute mapper

You can customize the default IdP attribute mapper as follows:

  1. Unpack the AM WAR file and extract the openam-federation-library-<version>.jar file.
  2. Create a new custom class that extends the DefaultLibraryIDPAttributeMapper class, for example, CustomIDPAttributeMapper. You should refer to Interface IDPAttributeMapper for further information.
  3. Override the getAttributes() method to achieve your desired customization. The resulting class would look similar to this: public class CustomIDPAttributeMapper extends DefaultLibraryIDPAttributeMapper {    /**     * comments to be made here      */     @Override     public List getAttributes (         Object session,          String hostEntityID,          String remoteEntityID,          String realm){              List<Attribute> attributes =          super.getAttributes (session, hostEntityID, remoteEntityID, realm);              if ("".equals(remoteEntityID)) {             //modify attribute list here         }               return attributes;     } }
  4. Repack the openam-federation-library-<version>.jar with your new custom class.
  5. Add your customization to the AM WAR file:
    • Replace the existing jar file in the WEB-INF/lib directory with your customized jar file.
    • Repack the AM WAR file and deploy as normal.
  6. Update the configuration for the Hosted IdP with your new custom class:
    • AM 6 and later console: navigate to Realms > [Realm Name] > Applications > Federation > Entity Providers > [Hosted IdP Name] > Assertion Processing > Attribute Mapper and replace the default class with your custom class.
    • AM 5.x console: navigate to Realms > [Realm Name] > Applications > SAML > Circle of Trust Configuration > Entity Providers > [Hosted IdP Name] > Assertion Processing > Attribute Mapper and replace the default class with your custom class.
  7. Restart the web application container in which AM runs.
  8. Test your changes.

See Also

How do I customize SAML2 plugins in AM (All versions)?

SAML Federation in AM

SAML v2.0 Guide › Assertion Processing

Related Training


Related Issue Tracker IDs

OPENAM-11474 (Custom IDP Attribute mappers may cause failures after upgrade)

OPENAM-4550 (document how to build and use a custom SAML IdP/SP Attribute Mapper)

Copyright and TrademarksCopyright © 2021 ForgeRock, all rights reserved.