我在一个 JavaEE 项目中工作,我只想看看使用 username 和 password 登录的用户是否有一个Alfresco 中的帐户,我使用了 getSession 方法,但如果 username 和 password 错误,它不会返回(不存在).
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(); }谢谢
推荐答案经过多次研究,我发现了 Alfresco 的 Rest Api
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
您可以在此链接中找到更多信息wiki.alfresco/wiki/Repository_RESTful_API_Reference(如何添加一个人,如何检查某人是否是私人站点的成员......).
you can find more in this link wiki.alfresco/wiki/Repository_RESTful_API_Reference (how to add a person, how to check if someone is a member of a private site ... ).
更多推荐
测试用户帐户露天 CMIS(如果存在)
发布评论