Created
February 16, 2011 13:21
-
-
Save vs/829353 to your computer and use it in GitHub Desktop.
Reading SVN password authentication cache.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.tmatesoft.svn.util; | |
import java.io.File; | |
import org.tmatesoft.svn.core.SVNException; | |
import org.tmatesoft.svn.core.SVNProperties; | |
import org.tmatesoft.svn.core.SVNPropertyValue; | |
import org.tmatesoft.svn.core.internal.wc.SVNFileListUtil; | |
import org.tmatesoft.svn.core.internal.wc.SVNWCProperties; | |
import org.tmatesoft.svn.core.wc.SVNWCUtil; | |
/** | |
* @author <a href="[email protected]">Semen Vadishev</a> | |
*/ | |
public class Test2 { | |
public static void main(String[] args) throws SVNException { | |
File configDirectory = SVNWCUtil.getDefaultConfigurationDirectory(); | |
File authCacheArea = new File(configDirectory, "auth"); | |
File passwordCacheArea = new File(authCacheArea, "svn.simple"); | |
if (!passwordCacheArea.isDirectory()) { | |
System.out.println("Password cache doesn't exist"); | |
return; | |
} | |
File[] realmCacheFiles = SVNFileListUtil.listFiles(passwordCacheArea); | |
for (int i = 0; i < realmCacheFiles.length; i++) { | |
File realmCacheFile = realmCacheFiles[i]; | |
SVNWCProperties properties = new SVNWCProperties(realmCacheFile, null); | |
SVNProperties realmCache = properties.asMap(); | |
String realm = SVNPropertyValue.getPropertyAsString(realmCache.getSVNPropertyValue("svn:realmstring")); | |
String passwordStorageType = SVNPropertyValue.getPropertyAsString(realmCache.getSVNPropertyValue("passtype")); | |
System.out.println("Realm cache: " + realmCacheFile.getAbsolutePath()); | |
System.out.println("Realm: " + realm); | |
System.out.println("Passtype: " + passwordStorageType); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment