SlingAuthenticationHandler如何与CRXLogin模块通信

时间:2014-05-28 09:02:27

标签: cq5 jackrabbit jcr sling aem

我读到了这一点here。但在我无法弄清楚AuthenticationInfo对象如何传递给CRXLoginModule之后。我已经了解SlingAuthenticationHandler的流程如下 -

  1. SlingAuthenticator调用AuthenticationHandler(CQ默认为TokenAuthenticationHandler)

  2. AuthenticationHandler使用用户名和密码返回AuthenticationInfo。在SlingAuthenticationHandler的代码中,它只从TokenUtil.createCredentials(request,response,this.repository,username,true)发送AuthenticationInfo对象; TokenUtil类的代码说 -

    adminSession = repository.loginAdministrative(null);
    
    SimpleCredentials sc = new SimpleCredentials(userId, new char[0]);
    sc.setAttribute(".token", "");
    userSession = adminSession.impersonate(sc);
    
    TokenCredentials tc = new TokenCredentials((String)sc.getAttribute(".token"));
    AuthenticationInfo authInfo = new AuthenticationInfo("TOKEN", userId);
    authInfo.put("user.jcr.credentials", tc);
    
  3. adminSession.impersonate(sc)调用org.apache.jackrabbit.core.SessionImpl.impersonate(Credential crd)再次调用org.apache.jackrabbit.core.RepositoryImpl.login并允许登录并创建令牌在org.apache.jackrabbit.core.security.authentication.DefaultLoginModule的commit()方法中。

  4. 问题:

    Q1)执行adminSession.impersonate(sc)时,如何调用CRXLoginModule?哪个类文件对此负责?

    Q2)我看到了SlingAuthenticator的代码,但它没有调用javax.jcr.RepositoryFactory或com.day.crx.core.CRXRepositoryFactory。 sling如何将AuthenticationInfo对象传递给CRXLoginModule?

    请帮助我理解这个流程。感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

简单的答案是,您列出的任何内容都不会与CRXLoginModule交互。

如果您参考您链接的演示文稿,演示文稿也未提及CRXLoginModule。

原因是com.day.crx.core.CRXLoginModule是Day的自定义javax.security.auth.spi.LoginModule,用于在认证机制在OSGi框架内移动之前与jackrabbit jcr进行交互,这在CQ 5.5中发生

而不是使用该LoginModule,身份验证处理程序使用jackrabbit提供的Default LoginModule,这将是您已经识别的org.apache.jackrabbit.core.security.authentication.DefaultLoginModule