Java SVN中的身份验证
我试图使用java为svn构建一个自定义UI。它只是一个简单的应用程序,您可以在文本框中提供svn url。浏览器要求用户名和密码进行身份验证。然后您可以浏览SVN的目录结构(仅供阅读) 为此,我选择了svnkit罐。身份验证(业务逻辑)非常简单Java SVN中的身份验证,java,jsp,svn,servlets,Java,Jsp,Svn,Servlets,我试图使用java为svn构建一个自定义UI。它只是一个简单的应用程序,您可以在文本框中提供svn url。浏览器要求用户名和密码进行身份验证。然后您可以浏览SVN的目录结构(仅供阅读) 为此,我选择了svnkit罐。身份验证(业务逻辑)非常简单 public static ISVNAuthenticationManager authManager = null; // currently used a static variable in the class public List<S
public static ISVNAuthenticationManager authManager = null; // currently used a static variable in the class
public List<String> myfunction(String path, String uName, String password){
public static SVNRepository repository =
SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url.toString()));
if(authManager == null){ // initializing if the authentication is not present
if( uName != null
&& password != null
&& !uName.trim().equals("") && !password.trim().equals("") ){
authManager =
SVNWCUtil.createDefaultAuthenticationManager(uName, password);}
}
repository.setAuthenticationManager(authManager);
// logic for fetching files/folders for the specific url
}
公共静态ISVNAuthenticationManager authManager=null;//类中当前使用的静态变量
公共列表myfunction(字符串路径、字符串uName、字符串密码){
公共静态SVN还原存储库=
create(SVNURL.parseURIEncoded(url.toString());
如果(authManager==null){//在不存在身份验证时初始化
如果(uName!=null
&&密码!=null
&&!uName.trim().equals(“”)&!password.trim().equals(“”){
authManager=
SVNWCUtil.createDefaultAuthenticationManager(uName,密码);}
}
setAuthenticationManager(authManager);
//获取特定url的文件/文件夹的逻辑
}
问题是,每当我向存储库提供url时,我都需要设置AuthenticationManager。显然,我不想在会话中存储用户名和密码,而且我不确定在会话中保留authManager对象是否安全
是否有人可以建议一种从安全角度来看是安全的身份验证方法???这取决于环境。在我的用例中,我在tomcat服务器上运行一个应用程序,该服务器使用GenericPrincipal()实现一个getPassword()