use of org.apache.xmlrpc.common.XmlRpcNotAuthorizedException in project processdash by dtuma.
the class BoundXmlRpcConnection method openConnectionImpl.
protected XmlRpcClient openConnectionImpl(boolean printException) throws ErrorDataValueException {
String username = null;
String password = null;
try {
// look up the information needed to make the connection
String baseUrl = this.baseUrl.getValue();
String urlSuffix = this.urlSuffix.getValue();
username = getUsername(this.username.getValue());
password = getPassword(this.password.getValue());
URL url = new URL(baseUrl.trim());
if (StringUtils.hasValue(urlSuffix))
url = new URL(url, urlSuffix);
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(url);
config.setEnabledForExtensions(true);
if (username != null && password != null) {
config.setBasicUserName(username);
config.setBasicPassword(password);
}
XmlRpcClient connection = new XmlRpcClient();
connection.setConfig(config);
if (StringUtils.hasValue(testMethodName))
connection.execute(testMethodName, Collections.EMPTY_LIST);
if (!validateCredentials(connection, username, password))
throw new ErrorDataValueException(BAD_USERNAME_PASS, ErrorData.SEVERE);
setError(null, ErrorData.NO_ERROR);
return connection;
} catch (MalformedURLException mue) {
throw new ErrorDataValueException(INVALID_URL, ErrorData.SEVERE);
} catch (XmlRpcNotAuthorizedException nae) {
throw getBadCredentialsException(username, password);
} catch (ErrorDataValueException edve) {
throw edve;
} catch (Exception e) {
// we were unable to open a connection; return null.
if (printException)
e.printStackTrace();
return null;
}
}
Aggregations