* @return PartnerConnection
* @throws com.sforce.ws.ConnectionException
*/
private PartnerConnection newConnection(ConnectorConfig bindingConfig, int retries) {
try {
PartnerConnection newBinding = Connector.newConnection(bindingConfig);
newBinding.setCallOptions(API_CLIENT_NAME, null);
logger.info("Logging in as " + bindingConfig.getUsername() + "/" + bindingConfig.getPassword() + " to URL: " + bindingConfig.getAuthEndpoint());
if (bindingConfig.isManualLogin()) {
LoginResult loginResult = newBinding.login(bindingConfig.getUsername(), bindingConfig.getPassword());
// if password has expired, throw an exception
if (loginResult.getPasswordExpired()) {
throw new PasswordExpiredException(Messages.getString("Client.errorExpiredPassword")); //$NON-NLS-1$
}
// update session id and service endpoint based on response
newBinding.setSessionHeader(loginResult.getSessionId());
bindingConfig.setServiceEndpoint(loginResult.getServerUrl());
}
return newBinding;
} catch (ConnectionException e) {
// in case of exception try to get a connection again