static ForceConnectorConfig loadFromName(String connectionName) throws IOException { Map<ForceConnectionProperty, String> propMap = ForceConnectorUtils.loadConnectorPropsFromName(connectionName); if (propMap == null) return null; ForceConnectorConfig config = new ForceConnectorConfig(); config.setPropsFromMap(propMap, connectionName); return config; }
private void initConfig() { if (config.getSessionRenewer() == null) { config.setSessionRenewer(this); } // Add proxy information to config if (DEFAULT_PROXY != null && (config.getProxy() != Proxy.NO_PROXY || config.getProxy().type() == Type.DIRECT)) { config.setProxy(DEFAULT_PROXY); } // Transfer any extra state we have to config if (this.timeout > 0) config.setReadTimeout(this.timeout); }
private void validateConnectorConfig(ForceConnectorConfig configToValidate) throws ConnectionException { if (configToValidate.getSessionId() == null && configToValidate.getAuthEndpoint() == null) { throw new ConnectionException("ForceConnectorConfig must have an AuthEndpoint"); } if (configToValidate.getSessionId() == null && configToValidate.getUsername() == null) { throw new ConnectionException("ForceConnectorConfig must have a Username"); } }
ForceConnectorConfig cc = new ForceConnectorConfig(); cc.setSessionId(user.getSessionId()); SecurityContext sc = (SecurityContext) auth.getDetails(); cc.setServiceEndpoint(sc.getEndPoint()); cc.setSessionRenewer(this);
config = new ForceConnectorConfig(); config.setConnectionUrl(endpoint); config.setAuthEndpoint(endpoint); config.setUsername(getConnectionUserName()); config.setPassword(getConnectionPassword());
private void setPropsFromMap(Map<ForceConnectionProperty, String> propMap, String propSource) { String errorMessage = "Could not load valid ForceConnectorConfig properties from " + propSource + "."; String endpointValue = propMap.get(ForceConnectionProperty.ENDPOINT); ForceConnectionProperty.ENDPOINT.validateValue(endpointValue, errorMessage); setAuthEndpoint(endpointValue); String userValue = propMap.get(ForceConnectionProperty.USER); ForceConnectionProperty.USER.validateValue(userValue, errorMessage); setUsername(userValue); String passwordValue = propMap.get(ForceConnectionProperty.PASSWORD); ForceConnectionProperty.PASSWORD.validateValue(passwordValue, errorMessage); setPassword(passwordValue); String clientIdValue; if ((clientIdValue = propMap.get(ForceConnectionProperty.CLIENTID)) != null) { ForceConnectionProperty.CLIENTID.validateValue(clientIdValue, errorMessage); setClientId(clientIdValue); } String timeoutValue; if ((timeoutValue = propMap.get(ForceConnectionProperty.TIMEOUT)) != null) { ForceConnectionProperty.TIMEOUT.validateValue(timeoutValue, errorMessage); int timeout = Integer.valueOf(timeoutValue); if (timeout > 0) setReadTimeout(timeout); } }
private void initBulkConnection() throws ConnectionException, AsyncApiException { if (this.connection == null) { initConnection(); } ConnectorConfig configNew = new ConnectorConfig(); configNew.setSessionId(config.getSessionId()); configNew.setServiceEndpoint(config.getServiceEndpoint()); configNew.setRestEndpoint(RESTAPI_URI_PATTERN.matcher(config.getServiceEndpoint()).replaceFirst("$1/async/$2/")); this.bulkConnection = new BulkConnection(configNew); }
@Override public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { if (authentication == null || authentication.getDetails() == null || !(authentication.getDetails() instanceof SecurityContext)) return; ForceConnectorConfig config = new ForceConnectorConfig(); try { SecurityContext sc = ((SecurityContext) authentication.getDetails()); // Use the value from session and not the login endpoint request.setAttribute(LogoutSuccessHandler.FORCE_ENDPOINT_ATTRIBUTE, sc.getEndPoint()); config.setServiceEndpoint(sc.getEndPoint()); config.setSessionId(sc.getSessionId()); config.setSessionRenewer(this); ForceServiceConnector connector = new ForceServiceConnector(); connector.setConnectorConfig(config); //logout from the partner API connector.getConnection().logout(); } catch (ConnectionException e) { if (config.getSessionId() != null) { // If the session id is null that means we visited the renewer method below and the session is dead anyways throw new AuthenticationServiceException("Unable to logout from Salesforce", e); } } }
config = new ForceConnectorConfig(); config.setConnectionUrl(endpoint); config.setAuthEndpoint(endpoint); config.setUsername(getConnectionUserName()); config.setPassword(getConnectionPassword());
private void setPropsFromMap(Map<ForceConnectionProperty, String> propMap, String propSource) { String errorMessage = "Could not load valid ForceConnectorConfig properties from " + propSource + "."; String endpointValue = propMap.get(ForceConnectionProperty.ENDPOINT); ForceConnectionProperty.ENDPOINT.validateValue(endpointValue, errorMessage); setAuthEndpoint(endpointValue); String userValue = propMap.get(ForceConnectionProperty.USER); ForceConnectionProperty.USER.validateValue(userValue, errorMessage); setUsername(userValue); String passwordValue = propMap.get(ForceConnectionProperty.PASSWORD); ForceConnectionProperty.PASSWORD.validateValue(passwordValue, errorMessage); setPassword(passwordValue); String clientIdValue; if ((clientIdValue = propMap.get(ForceConnectionProperty.CLIENTID)) != null) { ForceConnectionProperty.CLIENTID.validateValue(clientIdValue, errorMessage); setClientId(clientIdValue); } String timeoutValue; if ((timeoutValue = propMap.get(ForceConnectionProperty.TIMEOUT)) != null) { ForceConnectionProperty.TIMEOUT.validateValue(timeoutValue, errorMessage); int timeout = Integer.valueOf(timeoutValue); if (timeout > 0) setReadTimeout(timeout); } }
private void initBulkConnection() throws ConnectionException, AsyncApiException { if (this.connection == null) { initConnection(); } ConnectorConfig configNew = new ConnectorConfig(); configNew.setSessionId(config.getSessionId()); configNew.setServiceEndpoint(config.getServiceEndpoint()); configNew.setRestEndpoint(RESTAPI_URI_PATTERN.matcher(config.getServiceEndpoint()).replaceFirst("$1/async/$2/")); this.bulkConnection = new BulkConnection(configNew); }
HttpServletResponse res = (HttpServletResponse) response; ForceConnectorConfig config = new ForceConnectorConfig(); try { config.setServiceEndpoint(sc.getEndPoint()); config.setSessionId(sc.getSessionId()); config.setSessionRenewer(this); ForceServiceConnector connector = new ForceServiceConnector(); connector.setConnectorConfig(config);
private void initConfig() { if (config.getSessionRenewer() == null) { config.setSessionRenewer(this); } // Add proxy information to config if (DEFAULT_PROXY != null && (config.getProxy() != Proxy.NO_PROXY || config.getProxy().type() == Type.DIRECT)) { config.setProxy(DEFAULT_PROXY); } // Transfer any extra state we have to config if (this.timeout > 0) config.setReadTimeout(this.timeout); }
static ForceConnectorConfig loadFromName(String connectionName) throws IOException { Map<ForceConnectionProperty, String> propMap = ForceConnectorUtils.loadConnectorPropsFromName(connectionName); if (propMap == null) return null; ForceConnectorConfig config = new ForceConnectorConfig(); config.setPropsFromMap(propMap, connectionName); return config; }
private void initMetadataConnection() throws ConnectionException { if (this.connection == null) { initConnection(); } ConnectorConfig configNew = new ConnectorConfig(); configNew.setSessionId(config.getSessionId()); configNew.setServiceEndpoint(METADATA_URI_PATTERN.matcher(config.getServiceEndpoint()).replaceFirst("$1/m/$2")); this.metadataConnection = new MetadataConnection(configNew); // Give the metadata connection a client id if we have one if (this.clientId != null) { this.metadataConnection.setCallOptions(this.clientId); } else if (this.externalClientId != null) { // If we've constructed config from ForceServiceConnectionInfo state // then we've saved any client id for use here (see getConfig) this.metadataConnection.setCallOptions(this.externalClientId); } else { this.metadataConnection.setCallOptions(API_USER_AGENT); //just default to sdk version } this.metadataConnection.getConfig().setRequestHeader("User-Agent", API_USER_AGENT); }
private void validateConnectorConfig(ForceConnectorConfig configToValidate) throws ConnectionException { if (configToValidate.getSessionId() == null && configToValidate.getAuthEndpoint() == null) { throw new ConnectionException("ForceConnectorConfig must have an AuthEndpoint"); } if (configToValidate.getSessionId() == null && configToValidate.getUsername() == null) { throw new ConnectionException("ForceConnectorConfig must have a Username"); } }
HttpServletResponse res = (HttpServletResponse) response; ForceConnectorConfig config = new ForceConnectorConfig(); try { config.setServiceEndpoint(sc.getEndPoint()); config.setSessionId(sc.getSessionId()); config.setSessionRenewer(this); ForceServiceConnector connector = new ForceServiceConnector(); connector.setConnectorConfig(config);
private void initMetadataConnection() throws ConnectionException { if (this.connection == null) { initConnection(); } ConnectorConfig configNew = new ConnectorConfig(); configNew.setSessionId(config.getSessionId()); configNew.setServiceEndpoint(METADATA_URI_PATTERN.matcher(config.getServiceEndpoint()).replaceFirst("$1/m/$2")); this.metadataConnection = new MetadataConnection(configNew); // Give the metadata connection a client id if we have one if (this.clientId != null) { this.metadataConnection.setCallOptions(this.clientId); } else if (this.externalClientId != null) { // If we've constructed config from ForceServiceConnectionInfo state // then we've saved any client id for use here (see getConfig) this.metadataConnection.setCallOptions(this.externalClientId); } else { this.metadataConnection.setCallOptions(API_USER_AGENT); //just default to sdk version } this.metadataConnection.getConfig().setRequestHeader("User-Agent", API_USER_AGENT); }
ForceConnectorConfig cc = new ForceConnectorConfig(); cc.setSessionId(sc.getSessionId()); cc.setServiceEndpoint(sc.getEndPoint()); cc.setSessionRenewer(this);
ForceConnectorConfig cc = new ForceConnectorConfig(); cc.setSessionId(sc.getSessionId()); cc.setServiceEndpoint(sc.getEndPoint()); cc.setSessionRenewer(this);