本文整理汇总了Java中com.sforce.ws.ConnectorConfig.setProxy方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectorConfig.setProxy方法的具体用法?Java ConnectorConfig.setProxy怎么用?Java ConnectorConfig.setProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sforce.ws.ConnectorConfig
的用法示例。
在下文中一共展示了ConnectorConfig.setProxy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setProxy
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private synchronized void setProxy(ConnectorConfig config) {
final ProxyPropertiesRuntimeHelper proxyHelper = new ProxyPropertiesRuntimeHelper(
properties.getConnectionProperties().proxy);
resetAuthenticator();
if (proxyHelper.getProxyHost() != null) {
if (proxyHelper.getSocketProxy() != null) {
config.setProxy(proxyHelper.getSocketProxy());
} else {
config.setProxy(proxyHelper.getProxyHost(), Integer.parseInt(proxyHelper.getProxyPort()));
}
if (proxyHelper.getProxyUser() != null && proxyHelper.getProxyUser().length() > 0) {
config.setProxyUsername(proxyHelper.getProxyUser());
if (proxyHelper.getProxyPwd() != null && proxyHelper.getProxyPwd().length() > 0) {
config.setProxyPassword(proxyHelper.getProxyPwd());
setAuthenticator(proxyHelper.getProxyUser(), proxyHelper.getProxyPwd());
}
}
}
}
示例2: setProxyConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private static void setProxyConfig(ForceConfigBean conf, ConnectorConfig config) throws StageException {
if (conf.useProxy) {
config.setProxy(conf.proxyHostname, conf.proxyPort);
if (conf.useProxyCredentials) {
config.setProxyUsername(conf.proxyUsername.get());
config.setProxyPassword(conf.proxyPassword.get());
}
}
}
示例3: createConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public ConnectorConfig createConfig() {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(CommandLineArguments.getUsername());
config.setPassword(CommandLineArguments.getPassword());
config.setCompression(true);
if (CommandLineArguments.getProxyHost() != null && CommandLineArguments.getProxyPort() != null) {
LOG.debug("Setting proxy configuraiton to " + CommandLineArguments.getProxyHost() + " on port "
+ CommandLineArguments.getProxyPort());
config.setProxy(CommandLineArguments.getProxyHost(), CommandLineArguments.getProxyPort());
}
return config;
}
示例4: setProxyOnConnectorConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private static void setProxyOnConnectorConfig(IProxy proxy, ConnectorConfig connectorConfig) {
final String proxyHost = proxy.getProxyHost();
final String proxyPort = proxy.getProxyPort();
int portNumber = Utils.isNotEmpty(proxyPort) ? Integer.parseInt(proxyPort) : -1;
if (portNumber >= 0 && portNumber <= 65535) {
connectorConfig.setProxy(proxyHost, Integer.parseInt(proxyPort));
if (logger.isDebugEnabled()) {
logger.debug("Set proxy '" + connectorConfig.getProxy().address().toString());
}
}
connectorConfig.setProxyUsername(proxy.getProxyUser());
connectorConfig.setProxyPassword(proxy.getProxyPassword());
}
示例5: bulkApiLogin
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
/**
* Login to salesforce
* @return login status
*/
public boolean bulkApiLogin() throws Exception {
this.log.info("Authenticating salesforce bulk api");
boolean success = false;
String hostName = this.workUnit.getProp(ConfigurationKeys.SOURCE_CONN_HOST_NAME);
String apiVersion = this.workUnit.getProp(ConfigurationKeys.SOURCE_CONN_VERSION);
if (Strings.isNullOrEmpty(apiVersion)) {
apiVersion = "29.0";
}
String soapAuthEndPoint = hostName + SALESFORCE_SOAP_AUTH_SERVICE + "/" + apiVersion;
try {
ConnectorConfig partnerConfig = new ConnectorConfig();
if (super.workUnitState.contains(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL)
&& !super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL).isEmpty()) {
partnerConfig.setProxy(super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL),
super.workUnitState.getPropAsInt(ConfigurationKeys.SOURCE_CONN_USE_PROXY_PORT));
}
partnerConfig.setUsername(this.workUnit.getProp(ConfigurationKeys.SOURCE_CONN_USERNAME));
partnerConfig.setPassword(PasswordManager.getInstance(this.workUnit)
.readPassword(this.workUnit.getProp(ConfigurationKeys.SOURCE_CONN_PASSWORD)));
partnerConfig.setAuthEndpoint(soapAuthEndPoint);
PartnerConnection connection = new PartnerConnection(partnerConfig);
String soapEndpoint = partnerConfig.getServiceEndpoint();
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
ConnectorConfig config = new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
config.setRestEndpoint(restEndpoint);
config.setCompression(true);
config.setTraceFile("traceLogs.txt");
config.setTraceMessage(false);
config.setPrettyPrintXml(true);
if (super.workUnitState.contains(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL)
&& !super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL).isEmpty()) {
config.setProxy(super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL),
super.workUnitState.getPropAsInt(ConfigurationKeys.SOURCE_CONN_USE_PROXY_PORT));
}
this.bulkConnection = new BulkConnection(config);
success = true;
} catch (Exception e) {
throw new Exception("Failed to connect to salesforce bulk api; error - " + e.getMessage(), e);
}
return success;
}
示例6: bulkApiLogin
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
/**
* Login to salesforce
* @return login status
*/
public boolean bulkApiLogin() throws Exception {
log.info("Authenticating salesforce bulk api");
boolean success = false;
String hostName = this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_HOST_NAME);
String apiVersion = this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_VERSION);
if (Strings.isNullOrEmpty(apiVersion)) {
apiVersion = "29.0";
}
String soapAuthEndPoint = hostName + SALESFORCE_SOAP_AUTH_SERVICE + "/" + apiVersion;
try {
ConnectorConfig partnerConfig = new ConnectorConfig();
if (super.workUnitState.contains(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL)
&& !super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL).isEmpty()) {
partnerConfig.setProxy(super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL),
super.workUnitState.getPropAsInt(ConfigurationKeys.SOURCE_CONN_USE_PROXY_PORT));
}
String securityToken = this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_SECURITY_TOKEN);
String password = PasswordManager.getInstance(this.workUnitState)
.readPassword(this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_PASSWORD));
partnerConfig.setUsername(this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USERNAME));
partnerConfig.setPassword(password + securityToken);
partnerConfig.setAuthEndpoint(soapAuthEndPoint);
new PartnerConnection(partnerConfig);
String soapEndpoint = partnerConfig.getServiceEndpoint();
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
ConnectorConfig config = new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
config.setRestEndpoint(restEndpoint);
config.setCompression(true);
config.setTraceFile("traceLogs.txt");
config.setTraceMessage(false);
config.setPrettyPrintXml(true);
if (super.workUnitState.contains(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL)
&& !super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL).isEmpty()) {
config.setProxy(super.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USE_PROXY_URL),
super.workUnitState.getPropAsInt(ConfigurationKeys.SOURCE_CONN_USE_PROXY_PORT));
}
this.bulkConnection = new BulkConnection(config);
success = true;
} catch (RuntimeException e) {
throw new RuntimeException("Failed to connect to salesforce bulk api; error - " + e, e);
}
return success;
}