
com.databasesandlife.util.SvnUrlWithUsernamePassword Maven / Gradle / Ivy
package com.databasesandlife.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import com.databasesandlife.util.gwtsafe.ConfigurationException;
/**
* Represents a SVN URL, username, password.
*
* @author This source is copyright Adrian Smith and licensed under the LGPL 3.
* @see Project on GitHub
*/
public class SvnUrlWithUsernamePassword {
public SVNURL url;
public String username, password;
/** @param pipeSeparated "url" or "url|username|password" */
public static SvnUrlWithUsernamePassword parse(String pipeSeparated) throws ConfigurationException {
Matcher m = Pattern.compile("^([^|]+?)(\\|([^|]+)\\|([^|]+))?$").matcher(pipeSeparated);
if (! m.matches()) throw new ConfigurationException("SVN '" + pipeSeparated + "' should have 'url|user|pw' form");
try {
SvnUrlWithUsernamePassword result = new SvnUrlWithUsernamePassword();
result.url = SVNURL.parseURIEncoded(m.group(1));
result.username = m.group(3);
result.password = m.group(4);
return result;
}
catch (SVNException e) { throw new ConfigurationException("SVN URL '" + m.group(1) + "' malformed: " + e.getMessage(), e); }
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy