We have a SVN repository, and I am able to connect to it through Tortoise. But when I try to connect to it through SvnKit, specifically svnRepository.testConnection() method, it says
svn: E170001: Authentication required for .... The credentials passed in are the same ones I am using with Tortoise as well.
This particular component works fine with other repositories. Further, this repository is secured. But I am able to connect to other secure repositories as well.
Here's the error log.
org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001: Authentication required for 'server name:443'
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.java:47)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.java:41)
at org.tmatesoft.svn.core.auth.BasicAuthenticationManager.getNextAuthentication(BasicAuthenticationManager.java:223)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:657)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:362)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:350)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAVConnection.java:708)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:628)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:103)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1016)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.testConnection(DAVRepository.java:99)
Looking forward to a solution.
The solution is simple: call
with a proper ISVNAuthenticationManager implementation.
SVNKit has already several ready-to-use implementations of this class. The simplest one is
BasicAuthenticationManagerwhich can be constructed by one or severalSVNAuthentication. EachSVNAuthenticationinstance represents some kind of credentials (see its subclasses). So if, for example, your repository is secured by only username and password, you can constructSVNPasswordAuthenticationwith your password and then constructBasicAuthenticationManagerusing it and pass toSVNRepository.Another useful implementation is
DefaultSVNAuthenticationManagerwhich describes "authentication data stored in~/.subversiondirectory". To construct it you can useSVNWCUtil.createDefaultAuthenticationManager(). You can also customize this class, for example, to allow or disallow to enter a password from a keyboard in interactive mode, or to store or not to store entered password in in~/.subversiondirectory (or also you can use another directory for that). To understand how to do that, I recommend you to look atSVNCommandEnvironment.createClientAuthenticationManager()which constructsISVNAuthenticationManagerimplementation for command line utility.