【发布时间】:2016-08-01 08:55:53
【问题描述】:
我在一个JavaEE 项目中工作,我只想看看用户是否使用username 和password 登录在Alfresco 中有一个帐户,我使用getSession 方法但是它如果username 和password 错误(不存在),则不会返回。
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();
}
谢谢
【问题讨论】:
标签: java jakarta-ee alfresco cmis