public SalesforceDataContext(String username, String password, String securityToken) {
   try {
     _connection = Connector.newConnection(username, password + securityToken);
   } catch (ConnectionException e) {
     throw SalesforceUtils.wrapException(e, "Failed to log in to Salesforce service");
   }
 }
 public SalesforceDataContext(
     String endpoint, String username, String password, String securityToken) {
   try {
     ConnectorConfig config = new ConnectorConfig();
     config.setUsername(username);
     config.setPassword(password + securityToken);
     config.setAuthEndpoint(endpoint);
     config.setServiceEndpoint(endpoint);
     _connection = Connector.newConnection(config);
   } catch (ConnectionException e) {
     throw SalesforceUtils.wrapException(e, "Failed to log in to Salesforce service");
   }
 }
  @OAuthPostAuthorization
  public void postAuthorize() throws ConnectionException, MalformedURLException, AsyncApiException {
    ConnectorConfig config = new ConnectorConfig();
    if (LOGGER.isDebugEnabled()) {
      config.addMessageHandler(
          new MessageHandler() {
            @Override
            public void handleRequest(URL endpoint, byte[] request) {
              LOGGER.debug("Sending request to " + endpoint.toString());
              LOGGER.debug(new String(request));
            }

            @Override
            public void handleResponse(URL endpoint, byte[] response) {
              LOGGER.debug("Receiving response from " + endpoint.toString());
              LOGGER.debug(new String(response));
            }
          });
    }

    config.setSessionId(accessToken);
    config.setManualLogin(true);

    config.setCompression(false);

    String serviceEndpoint = "https://" + (new URL(instanceId)).getHost() + "/services/Soap/u/26.0";
    config.setServiceEndpoint(serviceEndpoint);

    this.partnerConnection = Connector.newConnection(config);
    setConnectionOptions(this.partnerConnection);

    String restEndpoint = "https://" + (new URL(instanceId)).getHost() + "/services/async/26.0";
    config.setRestEndpoint(restEndpoint);

    this.bulkConnection = new BulkConnection(config);
  }