Skip to content

Instantly share code, notes, and snippets.

@vs
Created February 16, 2011 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vs/829353 to your computer and use it in GitHub Desktop.
Save vs/829353 to your computer and use it in GitHub Desktop.
Reading SVN password authentication cache.
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="semen.vadishev@svnkit.com">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