SVNKit use of auth folder

断了今生、忘了曾经 提交于 2020-01-14 04:20:10

问题


I'm using SVNKit (1.8.4) to retrieve logs (only the logs) from different repositories, on different servers, with different protocols. The whole thing runs on a Tomcat server and is querying each SVN server every 2 minutes for changes.

After a lot of trial and error, I came up with a scheme where I make a folder for each SVN client instance, so that it can store all the credentials etc. in its own isolated place.

Here's the relevant code that creates the SVNRepository object:

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

Is there a better way to do this?


回答1:


I'd suggest to use lightweight BasicAuthenticationManager instance in place of DefaultSVNAuthenticationManager one. BasicAuthenticationManager only users in-memory credentials and doesn't use local settings or configuration files.

The code would look like that:

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


来源:https://stackoverflow.com/questions/24403997/svnkit-use-of-auth-folder

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