SVNKit使用auth文件夹

我正在使用SVNKit (1.8.4)从不同的存储库,不同的服务器,使用不同的协议检索日志(只有日志)。 整个事情在Tomcat服务器上运行,并且每2分钟查询一次SVN服务器以进行更改。

经过大量的反复试验,我想出了一个方案,为每个SVN客户端实例创建一个文件夹,以便它可以将所有凭据等存储在自己隔离的地方。

这是创建SVNRepository对象的相关代码:

 SVNRepository getRepository(String url, String authFolder, String username, String password) throws SVNException { SVNRepository repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded(url) ); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( authFolder, username, password, true); repository.setAuthenticationManager(authManager); return repository; } 

有一个更好的方法吗?

我建议使用轻量级的BasicAuthenticationManager实例代替DefaultSVNAuthenticationManager。 BasicAuthenticationManager仅用户内存凭据,不使用本地设置或配置文件。

代码看起来像这样:

 ISVNAuthenticationManager authManager = new BasicAuthenticationManager(new SVNAuthentication[] { new SVNPasswordAuthentication(userName, password, false, url, false), }); repository.setAuthenticationManager(authManager);