ServerAddress address = credentials.getServerAddress();
String userName = credentials.getUser();
String password = credentials.getPasswordHash();
String version = Versions.CURRENT.toString();
// Configure the web service.
AuthenticateServiceLocator locator = new AuthenticateServiceLocator();
// We cannot call getConfiguration().configureWebservice() here,
// because that would lead to infinite recursion since in order to configure
// a web service, you need to login. So we simply build the url ourselves:
StringBuilder url = credentials.isUsingHttps() ? new StringBuilder("https://") : new StringBuilder("http://");
url.append(address.toString()).append(getConfiguration().getWsPath()).append(SERVICE_NAME);
locator.setkonga_authenticateEndpointAddress(url.toString());
try {
WsKeyValuePairs keyValues = createKeyValuePairsToSendToServer();
AuthenticateResult ws_res = locator.getkonga_authenticate().loginWithVersionAndKeyValues(
userName, password, version, keyValues);
AuthenticateResultImpl result = new AuthenticateResultImpl(ws_res);
keyValuesHandler.handle(new ServerInfo(result.serverGuid(), credentials.getServer()), result.keyValues());
return result;
} catch (RemoteException e) {