使用 C# 从 SharpSvn 获取凭据
我正在编写一些 C# 代码来一次性执行对 SVN 的多次提交,就像工具 svnmucc 一样。到目前为止,我一直在使用 SharpSvn 与 SVN 进行其余必要的通信,因此我想我可以利用它来完成以下任务:
如何获取使用的凭据(用户名、密码)夏普Svn?
我想做这样的事情:
using (SvnClient svnClient = new SvnClient())
{
SomeFictitiousCredentialsClass credentials = svnClient.Authentication.FictitiousGetCachedCredentialsMethod();
// Call my code that performs svnmucc-like work here, passing username and password
// obtained from 'credentials' variable.
}
I am writing some C# code to perform multiple commits to SVN in one pass, much like the tool svnmucc. So far I've been using SharpSvn to do the rest of the necessary communication with SVN, so I'm thinking I can take advantage of it to accomplish the following:
How can I get the credentials (username, password) that are used by SharpSvn?
I'd like to do something like this:
using (SvnClient svnClient = new SvnClient())
{
SomeFictitiousCredentialsClass credentials = svnClient.Authentication.FictitiousGetCachedCredentialsMethod();
// Call my code that performs svnmucc-like work here, passing username and password
// obtained from 'credentials' variable.
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Sharpsvn 没有为您提供 Subversion 凭据的 API。它主要实现 libsvn_client api,在此级别无法访问此数据。
当需要凭据时,SharpSvn 从颠覆库获取回调;在大多数情况下,内置密码存储无法进行身份验证后。
如果您的 svnmucc 代码也使用 Subversion api,您只需插入 subversion 预定义的身份验证处理程序即可。
SharpSvn 本身尚不支持 svnmucc。 (有一些关于有人喜欢将其添加到 SharpSvn 的讨论,但我最近没有收到任何关于此的消息)
Sharpsvn doesn't have an api that provides you the credentials from Subversion. It mostly implements the libsvn_client api, and at this level there is no access to this data.
SharpSvn gets a callback from the subversion libraries when these need credentials; in most cases after the builtin password store fails to authenticate.
If your svnmucc code also uses the Subversion apis, you can just plugin the subversion predefined authentication handlers..
SharpSvn itself doesn't have svnmucc support yet. (There was some talk about somebody who liked to add this to SharpSvn, but I haven't got any news about this lately)
虽然另一个答案对于 SharpSvn 的所有当前版本仍然有效,但 SvnMucc 支持刚刚登陆 SharpSvn 的开发代码。因此很快就可以从 .Net 执行类似 SvnMucc 的操作。
如果您想从现有的 SvnClient 执行操作,可以使用稍微不同的语法,但这是总体思路。
While the other answer is still valid for all current versions of SharpSvn, SvnMucc support has just landed in the development code for SharpSvn. So soon it will be possible to perform SvnMucc like operations from .Net.
There is a slightly different syntax available if you would like to perform the operation from an existing SvnClient, but this is the general idea.