Testing user account alfresco CMIS if exist

℡╲_俬逩灬. 提交于 2019-12-04 05:54:48

问题


I am working in a JavaEE project and i want simply see if the user ho logged in with a username and a password have an account in Alfresco, I user the getSession method but it doesn't return if the username and password are wrong (doesn't exist).

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();
}                     

Thank you


回答1:


After many research i discover the Rest Api for Alfresco

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

for my case I used it and worked for me

you can find more in this link https://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference (how to add a person, how to check if someone is a member of a private site ... ).



来源:https://stackoverflow.com/questions/38694684/testing-user-account-alfresco-cmis-if-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!