/** * Closes all API connections (SOAP Web services API, Metadata API, and Bulk API) and resets configs. */ @Override public void close() { this.connector.close(); }
private ForceConnectorConfig checkConfigCache(ForceConnectorConfig configToCheck) throws ConnectionException { return checkConfigCache(configToCheck, null); }
/** * Get the BulkConnection object, connection will be lazily instantiated. * * @return BulkConnection to the Force.com Bulk API * @throws ConnectionException thrown if an error occurs during initialization of the connection * @throws AsyncApiException thrown if an error occurs during initialization of the connection */ public BulkConnection getBulkConnection() throws ConnectionException, AsyncApiException { return connector.getBulkConnection(); }
config.setSessionId(sc.getSessionId()); config.setSessionRenewer(this); ForceServiceConnector connector = new ForceServiceConnector(); connector.setConnectorConfig(config); connector.getConnection().logout(); } catch (ConnectionException e) { LOGGER.warn("Error logging out through API: ", e.getMessage());
/** * Instantiates the connections to the Force.com service. It either reads the configs * from thread local (which would have been set from OAuth) or it gets the config from * the store manager. * {@inheritDoc} */ @Override public ManagedConnection createManagedConnection(Object poolKey, Map transactionOptions) { ForceStoreManager storeManager = (ForceStoreManager) omfContext.getStoreManager(); ForceServiceConnector connector = new ForceServiceConnector(); // A ConnectorConfig might have been set via OAuth in which case we should be // using that. ForceConnectorConfig tlConfig; if ((tlConfig = ForceServiceConnector.getThreadLocalConnectorConfig()) != null) { connector.setConnectorConfig(tlConfig); } else { connector.setConnectorConfig(storeManager.getConfig()); } connector.setConnectionName(omfContext.getPersistenceConfiguration().getStringProperty("force.ConnectionName")); connector.setClientId(ForceServiceConnector.API_USER_AGENT); connector.setTimeout(omfContext.getPersistenceConfiguration().getIntProperty("datanucleus.datastoreReadTimeout")); connector.setSkipCache(omfContext.getPersistenceConfiguration() .getBooleanProperty("force.skipConfigCache", false /* resultIfNotSet */)); return new ForceManagedConnection(connector); } }
connectorConfig.setSessionId(null); close(); setConnectorConfig((ForceConnectorConfig) connectorConfig); getConnection();
/** * Gets the PartnerConnection object, connection will be lazily instantiated. * * @return a PartnerConnection to the Force.com SOAP API */ @Override public Object getConnection() { try { return connector.getConnection(); } catch (ConnectionException ce) { throw new NucleusException(ce.getMessage(), ce); } }
return checkConfigCache((ForceConnectorConfig) externalConfig.clone()); final ForceConnectorConfig cachedConfig = getCachedConfig(getCacheIdForConnectionName(connectionName)); if (cachedConfig != null) { return cachedConfig; return checkConfigCache(loadedConfig, connectionName);
ForceServiceConnector.setThreadLocalConnectorConfig(cc); try { chain.doFilter(request, response); SecurityContextHolder.clearContext(); ForceServiceConnector.setThreadLocalConnectorConfig(null); ForceSecurityContextHolder.release();
config.setSessionId(sc.getSessionId()); config.setSessionRenewer(this); ForceServiceConnector connector = new ForceServiceConnector(); connector.setConnectorConfig(config); connector.getConnection().logout(); } catch (ConnectionException e) { LOGGER.warn("Error logging out through API: ", e.getMessage());
/** * Instantiates the connections to the Force.com service. It either reads the configs * from thread local (which would have been set from OAuth) or it gets the config from * the store manager. * {@inheritDoc} */ @Override public ManagedConnection createManagedConnection(Object poolKey, Map transactionOptions) { ForceStoreManager storeManager = (ForceStoreManager) omfContext.getStoreManager(); ForceServiceConnector connector = new ForceServiceConnector(); // A ConnectorConfig might have been set via OAuth in which case we should be // using that. ForceConnectorConfig tlConfig; if ((tlConfig = ForceServiceConnector.getThreadLocalConnectorConfig()) != null) { connector.setConnectorConfig(tlConfig); } else { connector.setConnectorConfig(storeManager.getConfig()); } connector.setConnectionName(omfContext.getPersistenceConfiguration().getStringProperty("force.ConnectionName")); connector.setClientId(ForceServiceConnector.API_USER_AGENT); connector.setTimeout(omfContext.getPersistenceConfiguration().getIntProperty("datanucleus.datastoreReadTimeout")); connector.setSkipCache(omfContext.getPersistenceConfiguration() .getBooleanProperty("force.skipConfigCache", false /* resultIfNotSet */)); return new ForceManagedConnection(connector); } }
connectorConfig.setSessionId(null); close(); setConnectorConfig((ForceConnectorConfig) connectorConfig); getConnection();
/** * Gets the PartnerConnection object, connection will be lazily instantiated. * * @return a PartnerConnection to the Force.com SOAP API */ @Override public Object getConnection() { try { return connector.getConnection(); } catch (ConnectionException ce) { throw new NucleusException(ce.getMessage(), ce); } }
return checkConfigCache((ForceConnectorConfig) externalConfig.clone()); final ForceConnectorConfig cachedConfig = getCachedConfig(getCacheIdForConnectionName(connectionName)); if (cachedConfig != null) { return cachedConfig; return checkConfigCache(loadedConfig, connectionName);
ForceServiceConnector.setThreadLocalConnectorConfig(cc); request.setAttribute(FILTER_ALREADY_VISITED, Boolean.TRUE); chain.doFilter(new AuthenticatedRequestWrapper(request, sc), response); } finally { ForceSecurityContextHolder.release(); ForceServiceConnector.setThreadLocalConnectorConfig(null);
@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); } } }
ForceServiceConnector.setThreadLocalConnectorConfig(cc); request.setAttribute(FILTER_ALREADY_VISITED, Boolean.TRUE); chain.doFilter(new AuthenticatedRequestWrapper(request, sc), response); } finally { ForceSecurityContextHolder.release(); ForceServiceConnector.setThreadLocalConnectorConfig(null);
/** * Closes all API connections (SOAP Web services API, Metadata API, and Bulk API) and resets configs. */ @Override public void close() { this.connector.close(); }
/** * Get the BulkConnection object, connection will be lazily instantiated. * * @return BulkConnection to the Force.com Bulk API * @throws ConnectionException thrown if an error occurs during initialization of the connection * @throws AsyncApiException thrown if an error occurs during initialization of the connection */ public BulkConnection getBulkConnection() throws ConnectionException, AsyncApiException { return connector.getBulkConnection(); }
private ForceConnectorConfig checkConfigCache(ForceConnectorConfig configToCheck) throws ConnectionException { return checkConfigCache(configToCheck, null); }