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?
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: