测试用户帐户 alfresco CMIS(如果存在)

Testing user account alfresco CMIS if exist

我在一个 JavaEE 项目中工作,我只想看看使用 usernamepassword 登录的用户是否在 Alfresco 中有一个帐户,我使用 getSession 方法,但如果 usernamepassword 错误(不存在),它不会 return。

private static Session getSession(String serverUrl, String username, String password) {
    SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
    Map<String, String> params = new HashMap<>();
    params.put(SessionParameter.USER, username);
    params.put(SessionParameter.PASSWORD, password);
    params.put(SessionParameter.ATOMPUB_URL, serverUrl);
    params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
    List<Repository> repos = sessionFactory.getRepositories(params);
    if (repos.isEmpty()) {
        System.out.println(" repository doesn't exist ");
        throw new RuntimeException("Server has no repositories!");
    }
    return repos.get(0).createSession();
}                     

谢谢

经过多次研究,我发现 Rest Api Alfresco

GET /alfresco/service/api/people/{userName} 

对于我的情况,我使用它并为我工作

您可以在此 link https://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference 中找到更多信息(如何添加人员,如何检查某人是否是私人网站的成员...)。