Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,38 @@ Authentication becomes invalid when a Salesforce session is invalidated or an ac
// Set the bearer token function
connector.setBearerTokenProvider(bearerTokenProvider);

For a full example, see [LoginExample.java](src/main/java/com/salesforce/emp/connector/example/LoginExample.java).
## Proxy
To connect to Salesforce through a proxy, you can use the ProxyBayeuxParameters class, adding it the proxy configuration, and eventually, also the authentication

BayeuxParameters params = LoginHelper.login(new URL(loginUrl), argv[0], argv[1]);


Consumer<Map<String, Object>> consumer = event -> System.out
.println(String.format("Received:\n%s", JSON.toString(event)));

CustomBayeuxParameter dbp = new CustomBayeuxParameter(params);
Address a = new Address(proxyHost, proxyPort);
HttpProxy p = new HttpProxy(a, proxyProtocol.equals("https"));
dbp.addProxy(p);
if (!proxyUsername.isEmpty()) {
BasicAuthentication auth = new BasicAuthentication(
new URI(String.format("%s://%s:%s", proxyProtocol, proxyHost, proxyPort)), "*", proxyUsername,
proxyPassword) {
@Override
public boolean matches(String type, URI uri, String realm) {
realm = "*";
return super.matches(type, uri, realm);
}

};
dbp.addAuthentication(auth);
}

EmpConnector connector = new EmpConnector(dbp);

connector.start().get(5, TimeUnit.SECONDS);

For a full example, see [LoginProxyExample.java](src/main/java/com/salesforce/emp/connector/example/LoginProxyExample.java).

## Documentation
For more information about the components of the EMP Connector and a walkthrough, see the [Java Client Example](https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/code_sample_java_client_intro.htm)
Expand Down
17 changes: 15 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<organization>Salesforce.com, Inc.</organization>
<organizationUrl>http://www.salesforce.com</organizationUrl>
</developer>
<developer>
<name>Alessandro Casolla</name>
<email>[email protected]</email>
<organization>Softphone srl</organization>
<organizationUrl>http://www.softphone.it</organizationUrl>
</developer>
</developers>

<scm>
Expand Down Expand Up @@ -68,20 +74,27 @@
<dependency>
<groupId>org.cometd.java</groupId>
<artifactId>cometd-java-client</artifactId>
<version>3.1.4</version>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.6</version>
<scope>test</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ default int maxNetworkDelay() {
/**
* @return a list of proxies to use for outbound connections
*/
default Collection<? extends org.eclipse.jetty.client.ProxyConfiguration.Proxy> proxies() {
default Collection<org.eclipse.jetty.client.ProxyConfiguration.Proxy> proxies() {
return Collections.emptyList();
}

/**
* @return a list of authentications to use for proxies
*/
default Collection<org.eclipse.jetty.client.api.Authentication> authentications() {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public int maxNetworkDelay() {
}

@Override
public Collection<? extends Proxy> proxies() {
public Collection<Proxy> proxies() {
return parameters.proxies();
}

Expand Down
Loading