【发布时间】:2014-03-24 19:49:59
【问题描述】:
如何在不签出项目的情况下使用用户名和密码对 svn url 进行身份验证
现在我正在调用 doCheckout() 方法进行身份验证。我不想下载到本地starge。我只想做身份验证。
我当前的代码
public class SvnAuth {
private static SVNClientManager ourClientManager;
public boolean svnAuthentication(String svnLocation, String svnUserName,
String svnPassword, File file) throws SVNException {
DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
ourClientManager = SVNClientManager.newInstance(options, svnUserName,
svnPassword);
SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
updateClient.setIgnoreExternals(false);
SVNRevision rev = SVNRevision.HEAD;
try {
long revision1 = updateClient.doCheckout(
SVNURL.parseURIEncoded(svnLocation), file, rev, rev, true);
} catch (SVNException e) {
SVNErrorMessage svnErrorMessage = e.getErrorMessage();
throw new SVNException(svnErrorMessage);
}
return true;
}
}
我使用的SVNKit版本是1.7.4-v1
【问题讨论】:
-
你可以使用 SVNLogClient 代替 SVNUpdateClient
-
你能详细说明@FredericClose
-
使用 SVNLogClient 您将使用相同的身份验证机制,但不会强制签出文件以验证登录名/密码。
-
也可以使用SVNRepository#testConnection方法。
-
该类中的#testConnection 方法在哪里? @DmitryPavlenko
标签: java svn authentication svnkit