【问题标题】:Are multiple implementations of AuthenticationInfoPostProcessor supported?是否支持 AuthenticationInfoPostProcessor 的多种实现?
【发布时间】:2022-08-17 02:32:07
【问题描述】:

在 AEM 6.4 中工作并在迁移到 6.5 的过程中,我可以拥有多个扩展 AuthenticationInfoPostProcessor 的类吗?

我在文档中找不到任何关于此的内容。

任何帮助都会很棒,

  • 您当前的代码是否适用于 AEM 6.5?根据 AEM 论坛的工作人员,6.4 和 6.5 之间的差异并没有那么大。
  • 是的,我的代码在 6.4 和 6.5 中都存在问题,除了一些小例外。

标签: aem aem-6


【解决方案1】:

是的,支持多种实现。 请注意,每个都将被调用(没有特定的顺序),因此您需要让每个实现只处理适用的登录。

例如假设您希望 AEM 中的两个网站受两个不同的 postProcess 实施保护。考虑这样的事情:

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
  }
}

然后在后处理器的每个实现中执行以下操作:

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
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-30
    • 2020-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多