Skip to content

Commit 0534011

Browse files
authored
Merge pull request #420 from PerimeterX/release/v6.16.0
Release/v6.16.0
2 parents 720ef56 + 9815ba4 commit 0534011

8 files changed

Lines changed: 98 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
2-
## [x.x.x] - YYYY-MM-DD
2+
## [v6.16.0](https://github.com/PerimeterX/perimeterx-java-sdk/compare/6.16.0...HEAD) (2025-11-12)
33
- Added support for data enrichment header feature (`px_data_enrichment_header_name` configuration)
4+
- Added support for AD user identifiers feature
45
- Added `px_secured_pxhd_enabled` configuration option to enable secure flag on `pxhd` cookie
56
- Added `is_sensitive_route` to risk api and async activities
67
- Added `additional_token_info` to risk api and async activities
@@ -10,6 +11,7 @@
1011
- Updated dependencies minor and patch versions (major versions unchanged)
1112
- Changed custom parameters to be of type `Object` instead of `String` to allow more flexibility
1213
- Changed first party block script in captcha template to end with expected `/captcha.js`
14+
- Changed `RequestWrapper` to include custom headers in methods that retrieve request headers
1315
- Fixed possible connection leak issue due to unclosed responses in first party and telemetry requests
1416
- Fixed first party fuzzing errors by returning 400 on first party requests with URL length > 1000 characters
1517

CONFIGURATIONS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ Directives
5353
|loginResponseValidationStatusCode|Array of status codes that is used to validate if the login was successful.|{200}|int[]
5454
|customLoginResponseValidator|Custom class that validates if the login was successful. LoginResponseValidator must be implemented to be able to use this class.|DefaultCustomLoginResponseValidator|LoginResponseValidator
5555
|credentialsCustomExtractor|Custom class that extracts the login credentials. CredentialsExtractor must be implemented to be able to use this class.|DefaultCredentialsCustomExtractor|CredentialsExtractor
56+
||pxDataEnrichmentHeaderName|Header name for forwarding data enrichment payload to origin server. When set, the SDK will add the PXDE payload as a header that can be forwarded to backend services.|"" (empty string)|String|Used with data enrichment feature
57+
||securedPxhdEnabled|Enable secure flag on pxhd cookie for enhanced security in HTTPS-only environments.|false|boolean|
58+
||pxJwtCookieName|Name of the cookie containing JWT token for user identifier extraction.|null|String|Part of Account Defender JWT user identifiers feature
59+
||pxJwtCookieUserIdFieldName|Field name in JWT payload to extract as user ID from cookie.|null|String|Supports dot notation for nested fields (e.g., "user.id")
60+
||pxJwtCookieAdditionalFieldNames|List of additional field names to extract from JWT cookie payload.|Empty List|List<String>|Supports dot notation for nested fields
61+
||pxJwtHeaderName|Name of the header containing JWT token for user identifier extraction.|null|String|Part of Account Defender JWT user identifiers feature
62+
||pxJwtHeaderUserIdFieldName|Field name in JWT payload to extract as user ID from header.|null|String|Supports dot notation for nested fields (e.g., "sub")
63+
||pxJwtHeaderAdditionalFieldNames|List of additional field names to extract from JWT header payload.|Empty List|List<String>|Supports dot notation for nested fields
5664

5765
## <a name="interfaces"></a> Interfaces
5866
`perimeterx-java-sdk` can be tuned and set a different type of interface in order to make the module more flexible

README.md

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# [PerimeterX](http://www.perimeterx.com) Java SDK
66

7-
> Latest stable version: [v6.15.0](https://search.maven.org/#artifactdetails%7Ccom.perimeterx%7Cperimeterx-sdk%7C6.15.0%7Cjar)
7+
> Latest stable version: [v6.16.0](https://search.maven.org/#artifactdetails%7Ccom.perimeterx%7Cperimeterx-sdk%7C6.16.0%7Cjar)
88
99
## Table of Contents
1010

@@ -152,8 +152,12 @@ Please continue reading about the various configurations available on the sdk in
152152

153153
#### <a name="data-enrichment"></a> Data Enrichment - pxde(PerimeterX Data Enrichment)
154154

155-
Users can use the additional activity handler to retrieve information for the request using the pxde object.
156-
First, check that the data enrichment object is verified, then you can access it's properties.
155+
Users can access data enrichment information in two ways:
156+
157+
1. **Using context.getPxde()** - Access the data enrichment payload directly in your Java code
158+
2. **Using a custom header** - Forward the data enrichment payload as a header to another server (e.g., your origin server)
159+
160+
##### Accessing Data Enrichment in Java Code
157161

158162
MyVerificationHandler.java:
159163
```java
@@ -191,6 +195,26 @@ enforcer.setVerificationHandler(new MyVerificationHandler(config));
191195
...
192196
```
193197

198+
##### Forwarding Data Enrichment as a Header
199+
200+
To forward the data enrichment payload to your backend/origin server, configure the header name. After `pxVerify` completes, the PXDE payload will be automatically added as a header to the request, which can then be forwarded:
201+
202+
```java
203+
PXConfiguration config = new PXConfiguration.Builder()
204+
...
205+
.pxDataEnrichmentHeaderName("X-PX-Data-Enrichment")
206+
.build();
207+
PerimeterX enforcer = new PerimeterX(config);
208+
209+
// In your filter:
210+
PXContext ctx = enforcer.pxVerify(request, response);
211+
212+
// After pxVerify, the request now contains the data enrichment header
213+
// and can be forwarded to your backend/origin server
214+
// The header will be available as "X-PX-Data-Enrichment" in the request
215+
filterChain.doFilter(request, response);
216+
```
217+
194218
#### <a name="custom-sensitive-request"></a> Custom Sensitive Request
195219
With the `customIsSensitive` predicate you can force the request to be sensitive.
196220
The input of the function is the same request that sent to the method `pxVerify`.
@@ -220,6 +244,8 @@ The input of the function is the same request that sent to the method `pxVerify`
220244
If the function throws exception, it is equivalent to returning empty custom params.
221245
Implementing this configuration overrides the deprecated configuration `customParameterProvider`.
222246

247+
Custom parameters support various types including strings, numbers, and booleans, allowing flexibility in the data sent to PerimeterX.
248+
223249
> **Note**
224250
> The request body can only be read once by default. If your function requires reading the body
225251
> consider using RequestWrapper which caches the body. Send the wrapped request to
@@ -234,12 +260,58 @@ PXConfiguration pxConfiguration = new PXConfiguration.Builder()
234260
CustomParameters customParameters = new CustomParameters();
235261
customParameters.setCustomParam1("example-value");
236262
customParameters.setCustomParam2(req.getHeader("example-header"));
263+
customParameters.setCustomParam3(123); // Numbers are supported
264+
customParameters.setCustomParam4(true); // Booleans are supported
237265
return customParameters;
238266
})
239267
.build();
240268
...
241269
```
242270

271+
#### <a name="jwt-user-identifiers"></a> JWT User Identifiers (Account Defender)
272+
273+
The SDK can extract user identifiers from JWT tokens in cookies or headers to enhance Account Defender capabilities. This allows PerimeterX to correlate user activity across sessions and improve detection accuracy.
274+
275+
Configure JWT extraction from cookies:
276+
```java
277+
PXConfiguration pxConfiguration = new PXConfiguration.Builder()
278+
...
279+
.pxJwtCookieName("authCookie")
280+
.pxJwtCookieUserIdFieldName("userId")
281+
.pxJwtCookieAdditionalFieldNames(Arrays.asList("email", "role"))
282+
.build();
283+
```
284+
285+
Configure JWT extraction from headers:
286+
```java
287+
PXConfiguration pxConfiguration = new PXConfiguration.Builder()
288+
...
289+
.pxJwtHeaderName("Authorization")
290+
.pxJwtHeaderUserIdFieldName("sub")
291+
.pxJwtHeaderAdditionalFieldNames(Arrays.asList("exp", "iss"))
292+
.build();
293+
```
294+
295+
The SDK will:
296+
1. First attempt to extract user identifiers from the configured cookie
297+
2. If not found, attempt to extract from the configured header
298+
3. Support dot notation for nested fields (e.g., "user.id")
299+
4. Automatically handle Bearer token prefixes in headers
300+
301+
#### <a name="secured-pxhd"></a> Secured PXHD Cookie
302+
303+
For enhanced security in HTTPS-only environments, you can enable the secure flag on the `pxhd` cookie. This ensures the cookie is only transmitted over secure connections:
304+
305+
```java
306+
PXConfiguration pxConfiguration = new PXConfiguration.Builder()
307+
...
308+
.securedPxhdEnabled(true)
309+
.build();
310+
```
311+
312+
> **Note**
313+
> Only enable this in environments where all traffic is served over HTTPS, as the cookie will not be sent over HTTP connections when this flag is enabled.
314+
243315
#### <a name="multi-app-support"></a> Multiple Application Support
244316
Simply create multiple instances of the PerimeterX class:
245317
```java

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<name>PerimeterX JAVA SDK</name>
88
<groupId>com.perimeterx</groupId>
99
<artifactId>perimeterx-sdk</artifactId>
10-
<version>6.15.1</version>
10+
<version>6.16.0</version>
1111

1212
<packaging>jar</packaging>
1313
<description>PerimeterX Java SDK</description>

px_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "6.15.1",
2+
"version": "6.16.0",
33
"supported_features": [
44
"advanced_blocking_response",
55
"batched_activities",

src/main/java/com/perimeterx/http/RequestWrapper.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public Enumeration<String> getHeaders(String name) {
7676
}
7777

7878
@Override
79-
public int getIntHeader(String name) {
79+
public int getIntHeader(String name) throws NumberFormatException {
8080
final String headerValue = getHeader(name);
8181
if (headerValue != null) {
8282
return Integer.parseInt(headerValue);
@@ -85,10 +85,14 @@ public int getIntHeader(String name) {
8585
}
8686

8787
@Override
88-
public long getDateHeader(String name) {
88+
public long getDateHeader(String name) throws IllegalArgumentException {
8989
final String headerValue = getHeader(name);
9090
if (headerValue != null) {
91-
return Long.parseLong(headerValue);
91+
try {
92+
return Long.parseLong(headerValue);
93+
} catch (NumberFormatException e) {
94+
throw new IllegalArgumentException("Header " + name + " is not a valid date");
95+
}
9296
}
9397
return -1L;
9498
}

src/test/java/com/perimeterx/api/RequestWrapperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ public void testGetDateHeader() {
152152
assertEquals(requestWrapper.getDateHeader("nonExistentHeader"), -1);
153153
try {
154154
requestWrapper.getDateHeader("stringHeader");
155-
fail("Expected NumberFormatException");
156-
} catch (NumberFormatException e) {
155+
fail("Expected IllegalArgumentException");
156+
} catch (IllegalArgumentException e) {
157157
// Expected exception
158158
}
159159
}

web/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<properties>
6666
<maven.compiler.source>8</maven.compiler.source>
6767
<maven.compiler.target>8</maven.compiler.target>
68-
<com.perimeterx.version>6.15.1</com.perimeterx.version>
68+
<com.perimeterx.version>6.16.0</com.perimeterx.version>
6969
</properties>
7070

7171
</project>

0 commit comments

Comments
 (0)