com.databasesandlife.util.SvnUrlWithUsernamePassword Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common Show documentation
Show all versions of java-common Show documentation
Utility classes developed at Adrian Smith Software (A.S.S.)
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 {
var m = Pattern.compile("^([^|]+?)(\\|([^|]+)\\|([^|]+))?$").matcher(pipeSeparated);
if (! m.matches()) throw new ConfigurationException("SVN '" + pipeSeparated + "' should have 'url|user|pw' form");
try {
var 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 - 2024 Weber Informatics LLC | Privacy Policy