本文整理汇总了Java中com.sforce.ws.ConnectorConfig.setUsername方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectorConfig.setUsername方法的具体用法?Java ConnectorConfig.setUsername怎么用?Java ConnectorConfig.setUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sforce.ws.ConnectorConfig
的用法示例。
在下文中一共展示了ConnectorConfig.setUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSalesForcePasswordExpired
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
@Test(expected = ConnectionException.class)
public void testSalesForcePasswordExpired() throws ConnectionException {
SalesforceSourceOrSink salesforceSourceOrSink = new SalesforceSourceOrSink();
TSalesforceInputProperties properties = (TSalesforceInputProperties) new TSalesforceInputProperties(null).init();
salesforceSourceOrSink.initialize(null, properties);
ConnectorConfig config = new ConnectorConfig();
config.setUsername(StringUtils.strip(USER_ID_EXPIRED, "\""));
String password = StringUtils.strip(PASSWORD_EXPIRED, "\"");
String securityKey = StringUtils.strip(SECURITY_KEY_EXPIRED, "\"");
if (StringUtils.isNotEmpty(securityKey)) {
password = password + securityKey;
}
config.setPassword(password);
PartnerConnection connection = null;
try {
connection = salesforceSourceOrSink.doConnection(config, true);
} catch (LoginFault ex) {
Assert.fail("Must be an exception related to expired password, not the Login Fault.");
} finally {
if (null != connection) {
connection.logout();
}
}
}
示例2: createPartnerConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private PartnerConnection createPartnerConnection() throws Exception {
ConnectorConfig config = new ConnectorConfig();
LOG.debug("Connecting SF Partner Connection using " + username);
config.setUsername(username);
config.setPassword(password);
String authEndpoint = getAuthEndpoint(loginURL);
LOG.info("loginURL : " + authEndpoint);
config.setAuthEndpoint(authEndpoint);
config.setServiceEndpoint(authEndpoint);
try {
return Connector.newConnection(config);
} catch (ConnectionException ce) {
LOG.error("Exception while creating connection", ce);
throw new Exception(ce);
}
}
示例3: getConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
/**
* Ges the Connection to SalesForce using the WSC wrapper
*
* @param _session
* @param argStruct
* @return
* @throws cfmRunTimeException
* @throws ConnectionException
*/
protected PartnerConnection getConnection(cfSession _session, cfArgStructData argStruct) throws cfmRunTimeException, ConnectionException {
String email = getNamedStringParam(argStruct, "email", null );
if ( email == null )
throwException( _session, "email was not properly defined" );
String passwordtoken = getNamedStringParam(argStruct, "passwordtoken", null );
if ( passwordtoken == null )
throwException( _session, "passwordtoken was not properly defined" );
// Make the connection to SalesForce
ConnectorConfig config = new ConnectorConfig();
config.setUsername(email);
config.setPassword(passwordtoken);
int timeout = getNamedIntParam(argStruct, "timeout", -1 );
if ( timeout > 0 )
config.setReadTimeout(timeout);
return Connector.newConnection(config);
}
示例4: fetchSFDCinfo
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
/**
* Fetching the Salesforce UserInfo along with session id.
* @return
*/
public static SFDCInfo fetchSFDCinfo() {
App.logInfo("Fetching SalesForce Data");
if(App.sfdcInfo.getSessionId() != null) return App.sfdcInfo;
try {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(App.getUserName());
config.setPassword(App.getUserPassword() + App.getSecurityToken());
config.setAuthEndpoint(App.getPartnerUrl());
partnerConnection = Connector.newConnection(config);
GetUserInfoResult userInfo = partnerConnection.getUserInfo();
App.sfdcInfo.setOrg(userInfo.getOrganizationId());
App.sfdcInfo.setUserId(userInfo.getUserId());
App.sfdcInfo.setSessionId(config.getSessionId());
String sept = config.getServiceEndpoint();
sept = sept.substring(0, sept.indexOf(".com") + 4);
App.sfdcInfo.setEndpoint(sept);
App.logInfo("SDCF Info:\n" + App.sfdcInfo.toString());
return App.sfdcInfo;
} catch (ConnectionException ce) {
ce.printStackTrace();
return null;
}
}
示例5: initializeConnectorConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private void initializeConnectorConfig(ConnectorConfig connectorConfig) {
if (forceProject == null) {
throw new IllegalArgumentException("Object containing connection details cannot be null");
}
connectorConfig.setCompression(true);
if (Utils.isEmpty(forceProject.getSessionId())) {
connectorConfig.setManualLogin(true);
connectorConfig.setUsername(forceProject.getUserName());
connectorConfig.setPassword(forceProject.getPassword() + forceProject.getToken());
} else {
connectorConfig.setManualLogin(false);
connectorConfig.setSessionId(forceProject.getSessionId());
}
connectorConfig.setReadTimeout(forceProject.getReadTimeoutMillis());
connectorConfig.setConnectionTimeout(forceProject.getReadTimeoutMillis());
if (Utils.isNotEmpty(forceProject.getEndpointServer())) {
final String endpointUrl =
salesforceEndpoints.getFullEndpointUrl(forceProject.getEndpointServer(),
forceProject.isHttpsProtocol());
connectorConfig.setAuthEndpoint(endpointUrl);
connectorConfig.setServiceEndpoint(connectorConfig.getAuthEndpoint());
}
}
示例6: login
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public boolean login(String username, String password, String endpoint) {
boolean success = false;
String authEndPoint = (endpoint != null) ? endpoint : DEFAULT_ENDPOINT;
try {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(username);
config.setPassword(password);
config.setAuthEndpoint(authEndPoint);
config.setTraceMessage(true);
config.setPrettyPrintXml(true);
conn = new PartnerConnection(config);
success = true;
} catch (ConnectionException ce) {
logger.log(Level.SEVERE, null, ce);
}
return success;
}
示例7: getPartnerConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static PartnerConnection getPartnerConnection(SalesforceConfig config) throws ConnectionException {
ConnectorConfig cc = new ConnectorConfig();
cc.setUsername(config.getUsername());
cc.setPassword(config.getPassword());
cc.setManualLogin(false);
String authEndpoint = String.format(ENDPOINT_SOAP, config.getServerUrl(), config.getApiVersion());
cc.setAuthEndpoint(authEndpoint);
PartnerConnection partnerConnection = com.sforce.soap.partner.Connector.newConnection(cc);
partnerConnection.login(config.getUsername(), config.getPassword());
return partnerConnection;
}
示例8: getMetadataConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static MetadataConnection getMetadataConnection(PartnerConnection pc, SalesforceConfig config) throws ConnectionException {
LoginResult lr = pc.login(config.getUsername(), config.getPassword());
ConnectorConfig cc = new ConnectorConfig();
cc.setUsername(config.getUsername());
cc.setPassword(config.getPassword());
cc.setSessionId(lr.getSessionId());
cc.setServiceEndpoint(lr.getMetadataServerUrl());
cc.setManualLogin(false);
MetadataConnection connection = com.sforce.soap.metadata.Connector.newConnection(cc);
return connection;
}
示例9: getInstance
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static PartnerConnectionExt getInstance() throws ConnectionException {
ConnectorConfig config = new ConnectorConfig();
config.setUsername("dummy_sf_user");
config.setPassword("dummy_sf_password");
config.setManualLogin(true);
// Salesforce SOAP API checks for /services/Soap/c/
config.setServiceEndpoint("http://dummysgendpoint/services/Soap/u/");
return new PartnerConnectionExt(config);
}
示例10: createPartnerConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private PartnerConnection createPartnerConnection(
String endpointUrl,
String userName,
String password)
throws ConnectionException {
ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setUsername(userName);
partnerConfig.setPassword(password);
partnerConfig.setAuthEndpoint(endpointUrl);
return new PartnerConnection(partnerConfig);
}
示例11: getPartnerConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static ConnectorConfig getPartnerConfig(ForceConfigBean conf, SessionRenewer sessionRenewer) throws StageException {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(conf.username.get());
config.setPassword(conf.password.get());
config.setAuthEndpoint("https://"+conf.authEndpoint+"/services/Soap/u/"+conf.apiVersion);
config.setCompression(conf.useCompression);
config.setTraceMessage(conf.showTrace);
config.setSessionRenewer(sessionRenewer);
setProxyConfig(conf, config);
return config;
}
示例12: 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;
}
示例13: login
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private void login(String endpoint) throws ConnectionException {
ConnectorConfig config = new ConnectorConfig();
config.setAuthEndpoint(endpoint);
config.setUsername(username);
config.setPassword(password + securityKey);
config.setConnectionTimeout(60000);
config.setUseChunkedPost(true);
partnerConnection = new PartnerConnection(config);
}
示例14: connectBulk
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
protected BulkConnection connectBulk(ConnectorConfig config) throws ComponentException {
/*
* When PartnerConnection is instantiated, a login is implicitly executed and, if successful, a valid session is
* stored in the ConnectorConfig instance. Use this key to initialize a BulkConnection:
*/
ConnectorConfig bulkConfig = new ConnectorConfig();
bulkConfig.setSessionId(config.getSessionId());
// For session renew
bulkConfig.setSessionRenewer(config.getSessionRenewer());
bulkConfig.setUsername(config.getUsername());
bulkConfig.setPassword(config.getPassword());
/*
* The endpoint for the Bulk API service is the same as for the normal SOAP uri until the /Soap/ part. From here
* it's '/async/versionNumber'
*/
String soapEndpoint = config.getServiceEndpoint();
// set it by a default property file
String api_version = "34.0";
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + api_version;
bulkConfig.setRestEndpoint(restEndpoint);
bulkConfig.setCompression(true);// This should only be false when doing debugging.
bulkConfig.setTraceMessage(false);
bulkConfig.setValidateSchema(false);
try {
return new BulkConnection(bulkConfig);
} catch (AsyncApiException e) {
throw new ComponentException(e);
}
}
示例15: connectBulk
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
protected BulkConnection connectBulk(ConnectorConfig config) throws ComponentException {
final SalesforceConnectionProperties connProps = getConnectionProperties();
/*
* When PartnerConnection is instantiated, a login is implicitly executed and, if successful, a valid session id is
* stored in the ConnectorConfig instance. Use this key to initialize a BulkConnection:
*/
ConnectorConfig bulkConfig = new ConnectorConfig();
setProxy(bulkConfig);
bulkConfig.setSessionId(config.getSessionId());
// For session renew
bulkConfig.setSessionRenewer(config.getSessionRenewer());
bulkConfig.setUsername(config.getUsername());
bulkConfig.setPassword(config.getPassword());
/*
* The endpoint for the Bulk API service is the same as for the normal SOAP uri until the /Soap/ part. From here
* it's '/async/versionNumber'
*/
String soapEndpoint = config.getServiceEndpoint();
// Service endpoint should be like this:
// https://ap1.salesforce.com/services/Soap/u/37.0/00D90000000eSq3
String apiVersion = soapEndpoint.substring(soapEndpoint.lastIndexOf("/services/Soap/u/") + 17);
apiVersion = apiVersion.substring(0, apiVersion.indexOf("/"));
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
bulkConfig.setRestEndpoint(restEndpoint);
// This should only be false when doing debugging.
bulkConfig.setCompression(connProps.needCompression.getValue());
bulkConfig.setTraceMessage(connProps.httpTraceMessage.getValue());
bulkConfig.setValidateSchema(false);
try {
return new BulkConnection(bulkConfig);
} catch (AsyncApiException e) {
throw new ComponentException(e);
}
}