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"); } }
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"); } }
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); }
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); }
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 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); }
@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); } } }