Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/gentle-dots-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"java-sdk": patch
---

Use the Apache HTTP client connector by default to enable support for the PATCH HTTP method.
Comment thread
ilfa marked this conversation as resolved.
1 change: 1 addition & 0 deletions .changeset/weak-eagles-deliver.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Migrate to Server API v4
- Changed root package for the SDK from `com.fingerprint` to `com.fingerprint.v4`
- Removed `GetVisits` and `GetRelatedVisitors` operations.
- Improved models used by the `GetEvent` and `SearchEvents` operations to use a more concise shape and clearer names.
- Use the Apache HTTP client connector by default to enable support for the PATCH HTTP method.
Comment thread
ilfa marked this conversation as resolved.

See [this page in the Fingerprint documentation](https://docs.fingerprint.com/reference/java-server-sdk#migration-guide-for-java-sdk-v8-0-0) for a migration guide.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,32 @@ class WebhookController {
}
```

## Configure an outbound HTTP proxy

To add an outbound HTTP proxy for the API client, use `ClientConfig`:
```java

import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import com.fingerprint.v4.sdk.*;
import com.fingerprint.v4.api.FingerprintApi;

// ...

ApiClient defaultClient = Configuration.getDefaultApiClient();
ClientConfig clientConfig = defaultClient.getClientConfig();

// The following properties configure the ApacheConnectorProvider, which is the default.
clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");

defaultClient.setClientConfig(clientConfig);

FingerprintApi apiInstance = new FingerprintApi(defaultClient);

```

## Documentation for API Endpoints

All URIs are relative to *https://api.fpjs.io/v4*
Expand Down
5 changes: 3 additions & 2 deletions sdk/src/main/java/com/fingerprint/v4/sdk/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
Expand Down Expand Up @@ -1210,7 +1210,8 @@ public ClientConfig getDefaultClientConfig() {
clientConfig.register(MultiPartFeature.class);
clientConfig.register(json);
clientConfig.register(JacksonFeature.class);
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// Use the ApacheConnectorProvider to enable PATCH method support
clientConfig.connectorProvider(new ApacheConnectorProvider());
// turn off compliance validation to be able to send payloads with DELETE calls
Comment thread
JuroUhlar marked this conversation as resolved.
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
Expand Down
55 changes: 28 additions & 27 deletions template/README.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,6 @@ Then manually install the following JARs:

- `sdk/build/libs/{{{artifactId}}}-{{{artifactVersion}}}.jar`

{{#jersey2}}
## Usage

To add a HTTP proxy for the API client, use `ClientConfig`:
```java
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import {{{invokerPackage}}}.*;
import {{{package}}}.{{{classname}}};

...

ApiClient defaultClient = Configuration.getDefaultApiClient();
ClientConfig clientConfig = defaultClient.getClientConfig();
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");
defaultClient.setClientConfig(clientConfig);

{{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```

{{/jersey2}}
## Getting Started

Please follow the [installation](#installation) instruction and execute the following Java code:
Expand Down Expand Up @@ -283,7 +256,35 @@ class WebhookController {
}
}
```
{{#jersey3}}

## Configure an outbound HTTP proxy

To add an outbound HTTP proxy for the API client, use `ClientConfig`:
```java
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import {{{invokerPackage}}}.*;
import {{{package}}}.{{{classname}}};

// ...

ApiClient defaultClient = Configuration.getDefaultApiClient();
ClientConfig clientConfig = defaultClient.getClientConfig();

// The following properties configure the ApacheConnectorProvider, which is the default.
clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");

defaultClient.setClientConfig(clientConfig);

{{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```

{{/jersey3}}
## Documentation for API Endpoints

All URIs are relative to *{{basePath}}*
Expand Down
5 changes: 3 additions & 2 deletions template/libraries/jersey3/ApiClient.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {{javaxPackage}}.ws.rs.core.Response.Status;
{{#hasOAuthMethods}}
import com.github.scribejava.core.model.OAuth2AccessToken;
{{/hasOAuthMethods}}
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
Expand Down Expand Up @@ -1410,7 +1410,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
clientConfig.register(MultiPartFeature.class);
clientConfig.register(json);
clientConfig.register(JacksonFeature.class);
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// Use the ApacheConnectorProvider to enable PATCH method support
clientConfig.connectorProvider(new ApacheConnectorProvider());
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
Expand Down
Loading