问题
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