本文整理汇总了Java中com.sforce.ws.ConnectorConfig类的典型用法代码示例。如果您正苦于以下问题:Java ConnectorConfig类的具体用法?Java ConnectorConfig怎么用?Java ConnectorConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectorConfig类属于com.sforce.ws包,在下文中一共展示了ConnectorConfig类的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: createBulkConnection
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
private BulkConnection createBulkConnection(ConnectorConfig partnerConfig)
throws AsyncApiException {
ConnectorConfig config = new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
String soapEndpoint = partnerConfig.getServiceEndpoint();
String restEndpoint = soapEndpoint.substring(
0, soapEndpoint.indexOf("Soap/")) + "async/" + API_VERSION;
config.setRestEndpoint(restEndpoint);
config.setCompression(isCompression);
config.setTraceMessage(false);
return new BulkConnection(config);
}
示例4: createConnection
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
private PartnerConnection createConnection() {
if (connection == null) {
PartnerConnectionConnectorConfig pcConnectorConfig = new PartnerConnectionConnectorConfig();
ConnectorConfig config = pcConnectorConfig.createConfig();
LOG.debug("creating connection for : " + CommandLineArguments.getUsername() + " "
+ CommandLineArguments.getOrgUrl() + " "
+ config.getUsername() + " " + config.getAuthEndpoint());
try {
connection = Connector.newConnection(config);
setSessionIdFromConnectorConfig(config);
LOG.debug("Partner Connection established with the org!! \n SESSION ID IN createPartnerConn: "
+ sessionIdFromConnectorConfig);
} catch (ConnectionException connEx) {
ApexUnitUtils.shutDownWithDebugLog(connEx, ConnectionHandler
.logConnectionException(connEx, connection));
}
}
return connection;
}
示例5: 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());
}
}
}
}
示例6: login
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
public void login(ConnectorConfig connect) {
switch (connection.oauth2FlowType.getValue()) {
case JWT_Flow:
JsonNode accessToken = new SalesforceJwtConnection(connection.oauth2JwtFlow, url).getAccessToken();
connect.setServiceEndpoint(getSOAPEndpoint(accessToken.get(Oauth2JwtClient.KEY_ID).asText(), //
accessToken.get(Oauth2JwtClient.KEY_TOKEN_TYPE).asText(), //
accessToken.get(Oauth2JwtClient.KEY_ACCESS_TOKEN).asText(), //
apiVersion));
connect.setSessionId(accessToken.get(Oauth2JwtClient.KEY_ACCESS_TOKEN).asText());
break;
case Implicit_Flow:
SalesforceOAuthAccessTokenResponse token = new SalesforceImplicitConnection(connection.oauth, url).getToken();
connect.setServiceEndpoint(getSOAPEndpoint(token.getID(), token.getTokenType(), token.getAccessToken(), apiVersion));
connect.setSessionId(token.getAccessToken());
break;
default:
break;
}
}
示例7: 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);
}
示例8: 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;
}
}
示例9: errorExecuteAnonymousResult
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
private static ExecuteAnonymousResult errorExecuteAnonymousResult(ConnectorConfig apexCfg, Exception exception) {
ExecuteAnonymousResult er = new ExecuteAnonymousResult();
er.setCompiled(true);
er.setSuccess(false);
String msg = ForceExceptionUtils.getConnectionCauseExceptionMessage(apexCfg, exception);
er.setExceptionMessage(msg);
if (Utils.isNotEmpty(exception.getStackTrace())) {
StackTraceElement[] stackTraces = exception.getStackTrace();
StringBuffer trace = new StringBuffer();
for (StackTraceElement element : stackTraces) {
trace.append(element.getClassName()).append(".").append(element.getMethodName()).append(" line ")
.append(element.getLineNumber()).append("\n");
}
er.setExceptionStackTrace(trace.toString());
}
return er;
}
示例10: getConnectionCauseExceptionMessage
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
public static String getConnectionCauseExceptionMessage(ConnectorConfig connectorConfig, Throwable th) {
StringBuffer strBuff = null;
if (connectorConfig != null && Utils.isNotEmpty(connectorConfig.getServiceEndpoint())) {
strBuff =
new StringBuffer(Messages.getString("General.ConnectionError.Server.message", new String[] { Utils
.getServerNameFromUrl(connectorConfig.getServiceEndpoint()) }));
} else {
strBuff = new StringBuffer(Messages.getString("General.ConnectionError.message"));
}
strBuff.append(":");
if (th.getCause() instanceof UnknownHostException && connectorConfig != null) {
return getUnknownHostExceptionMessage(strBuff, connectorConfig, th);
}
if(th.getCause() != null) {
strBuff.append("\n\n").append(th.getCause().getClass().getSimpleName()).append(": ").append(
getStrippedRootCauseMessage(th.getCause()));
}
return strBuff.toString();
}
示例11: 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());
}
}
示例12: login
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
public void login(@NotNull InstanceCredentials instanceCredentials, boolean traceMessages) {
clearAllConnections();
ConnectorConfig loginConfig = createConnectorConfig(instanceCredentials, traceMessages);
try {
// Create the Enterprise Connection which will log into Salesforce
enterpriseConnection = Connector.newConnection(loginConfig);
// Setup the Metadata Connection which will use the session Id from the Enterprise Connection
ConnectorConfig metadataConfig = createConnectorConfig(instanceCredentials, traceMessages);
metadataConfig.setSessionId(enterpriseConnection.getConfig().getSessionId());
metadataConfig.setServiceEndpoint(enterpriseConnection.getConfig().getServiceEndpoint().replace("services/Soap/c", "services/Soap/m"));
metadataConnection = com.sforce.soap.metadata.Connector.newConnection(metadataConfig);
// Setup the Apex Connection which will use the session Id from the Enterprise Connection
ConnectorConfig apexConfig = createConnectorConfig(instanceCredentials, traceMessages);
apexConfig.setSessionId(enterpriseConnection.getConfig().getSessionId());
apexConfig.setServiceEndpoint(enterpriseConnection.getConfig().getServiceEndpoint().replace("services/Soap/c", "services/Soap/s"));
apexConnection = com.sforce.soap.apex.Connector.newConnection(apexConfig);
} catch (ConnectionException e) {
logger.error("Unable to login to Salesforce", e);
}
}
示例13: 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;
}
示例14: testConnect
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
private void testConnect( String password ) throws Exception {
LogChannelInterface logInterface = mock( LogChannelInterface.class );
String url = "http://localhost/services/Soap/u/37.0";
String username = "MySampleUsername";
SalesforceConnection connection;
connection = spy( new SalesforceConnection( logInterface, url, username, password ) );
ArgumentCaptor<ConnectorConfig> captorConfig = ArgumentCaptor.forClass( ConnectorConfig.class );
ConnectorConfig mockConfig = mock( ConnectorConfig.class );
doReturn( UUID.randomUUID().toString() ).when( mockConfig ).getUsername();
doReturn( UUID.randomUUID().toString() ).when( mockConfig ).getPassword();
doReturn( mockConfig ).when( bindingStub ).getConfig();
doReturn( mock( LoginResult.class ) ).when( bindingStub ).login( anyString(), anyString() );
try {
connection.connect();
} catch ( KettleException e ) {
// The connection should fail
// We just want to see the generated ConnectorConfig
}
verify( connection ).createBinding( captorConfig.capture() );
assertEquals( username, captorConfig.getValue().getUsername() );
// Password is unchanged (not decrypted) when setting in ConnectorConfig
assertEquals( password, captorConfig.getValue().getPassword() );
}
示例15: getConnectorConfig
import com.sforce.ws.ConnectorConfig; //导入依赖的package包/类
private static ConnectorConfig getConnectorConfig(String serverUrl, String sessionId)
{
ConnectorConfig config = new ConnectorConfig();
config.setServiceEndpoint(serverUrl);
config.setSessionId(sessionId);
config.setCompression(true);
return config;
}