Are multiple implementations of AuthenticationInfoPostProcessor supported? | Community
Skip to main content
Level 2
July 18, 2022
Solved

Are multiple implementations of AuthenticationInfoPostProcessor supported?

  • July 18, 2022
  • 1 reply
  • 565 views

Working in AEM 6.4 and in process of migrating to 6.5, wondering if AEM supports multiple SAML implementations? And if so, can i also have multiple classes that extend AuthenticationInfoPostProcessor?

 

I can't find anything in the docs about this.

 

Any help would be great,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by TabsCru

Yes, multiple implementations are supported. Note that each will be invoked (in no specific order) so you will need to have each implementation only process the applicable logins.

e.g. Suppose you want to have two websites in AEM protected by two distinct postProcess implementations. Consider something like this:

public abstract class AbstractAuthenticationPostProcessor implements AuthenticationInfoPostProcessor {
  protected PostProcessorHandler getHandler(HttpServletRequest request) {
    String path = request.getRequestURI();

    if (path.startsWith("/content/siteA") {
      return PostProcessorHandler.SiteA;
    }
    if (path.startsWith("/content/siteB") {
      return PostProcessorHandler.SiteB;
    }
    return PostProcessorHandler.None
  }

  protected enum PostProcessorHandler {
      SiteA,
      SiteB,
      None
  }
}

Then in each of the implementations of the postprocessors do this:

public class SiteAPostProcessor extends AbstractAuthenticationPostProcessor {
  @Override
  public void postProcess(
    AuthenticationInfo authenticationInfo,
    HttpServletRequest request,
    HttpServletResponse response) {

    if (getHandler(request) != AuthenticationHandler.SiteA) {
        return;
    }

    // do post login tasks
  }
}

1 reply

TabsCruAuthorAccepted solution
Level 2
October 18, 2022

Yes, multiple implementations are supported. Note that each will be invoked (in no specific order) so you will need to have each implementation only process the applicable logins.

e.g. Suppose you want to have two websites in AEM protected by two distinct postProcess implementations. Consider something like this:

public abstract class AbstractAuthenticationPostProcessor implements AuthenticationInfoPostProcessor {
  protected PostProcessorHandler getHandler(HttpServletRequest request) {
    String path = request.getRequestURI();

    if (path.startsWith("/content/siteA") {
      return PostProcessorHandler.SiteA;
    }
    if (path.startsWith("/content/siteB") {
      return PostProcessorHandler.SiteB;
    }
    return PostProcessorHandler.None
  }

  protected enum PostProcessorHandler {
      SiteA,
      SiteB,
      None
  }
}

Then in each of the implementations of the postprocessors do this:

public class SiteAPostProcessor extends AbstractAuthenticationPostProcessor {
  @Override
  public void postProcess(
    AuthenticationInfo authenticationInfo,
    HttpServletRequest request,
    HttpServletResponse response) {

    if (getHandler(request) != AuthenticationHandler.SiteA) {
        return;
    }

    // do post login tasks
  }
}