将 LoginContext 作为凭证​​传递给 JCR 中的存储库登录(java 内容存储库)

Passing LoginContext as Credentials for Repository Login in JCR (java content Repository)

我一直在传递 logincontext 对象作为凭据来获取存储库登录会话

Repository repo = new Jcr(new Oak()).createRepository();
    final LoginContext lc= JaasAuthenticationTest.getlogincontext(); 
    Credentials credentials = new Credentials() {
        public LoginContext getLoginContext() { return lc; }
        };
Session session = repo.login(credentials);

JaasAuthenticationTest 看起来像

    lc = new LoginContext("nikhil", new TestCallbackHandler(name, password));
    return lc;

但显示错误:

javax.jcr.LoginException: Login Failure: all modules ignored
at org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:262)
at org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:220)

你试过了吗:

session = repository.login(new SimpleCredentials("username", "password".toCharArray()));