Skip to content

Commit 4fbd520

Browse files
authored
Merge branch 'JCL-457/jena-body-handler' into JCL-402/rdf4j-body-handlers
2 parents 452ce77 + 56f11e2 commit 4fbd520

File tree

5 files changed

+151
-186
lines changed

5 files changed

+151
-186
lines changed

api/src/main/java/com/inrupt/client/ProblemDetails.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@
3434
* @see <a href="https://www.rfc-editor.org/rfc/rfc9457">RFC 9457 Problem Details for HTTP APIs</a>
3535
*/
3636
public class ProblemDetails {
37+
/**
38+
* The <a href="https://www.rfc-editor.org/rfc/rfc9457">RFC9457</a> default MIME type.
39+
*/
3740
public static final String MIME_TYPE = "application/problem+json";
41+
/**
42+
* The <a href="https://www.rfc-editor.org/rfc/rfc9457">RFC9457</a> default problem type.
43+
*/
3844
public static final String DEFAULT_TYPE = "about:blank";
3945
private final URI type;
4046
private final String title;
@@ -44,6 +50,15 @@ public class ProblemDetails {
4450
private static JsonService jsonService;
4551
private static boolean isJsonServiceInitialized;
4652

53+
/**
54+
* Build a ProblemDetails instance providing the expected fields as described in
55+
* <a href="https://www.rfc-editor.org/rfc/rfc9457">RFC9457</a>.
56+
* @param type the problem type
57+
* @param title the problem title
58+
* @param details the problem details
59+
* @param status the error response status code
60+
* @param instance the problem instance
61+
*/
4762
public ProblemDetails(
4863
final URI type,
4964
final String title,
@@ -58,22 +73,42 @@ public ProblemDetails(
5873
this.instance = instance;
5974
}
6075

76+
/**
77+
* The problem type.
78+
* @return the type
79+
*/
6180
public URI getType() {
6281
return this.type;
6382
};
6483

84+
/**
85+
* The problem title.
86+
* @return the title
87+
*/
6588
public String getTitle() {
6689
return this.title;
6790
};
6891

92+
/**
93+
* The problem details.
94+
* @return the details
95+
*/
6996
public String getDetails() {
7097
return this.details;
7198
};
7299

100+
/**
101+
* The problem status code.
102+
* @return the status code
103+
*/
73104
public int getStatus() {
74105
return this.status;
75106
};
76107

108+
/**
109+
* The problem instance.
110+
* @return the instance
111+
*/
77112
public URI getInstance() {
78113
return this.instance;
79114
};
@@ -82,10 +117,25 @@ public URI getInstance() {
82117
* This inner class is only ever used for JSON deserialization. Please do not use in any other context.
83118
*/
84119
public static class Data {
120+
/**
121+
* The problem type.
122+
*/
85123
public URI type;
124+
/**
125+
* The problem title.
126+
*/
86127
public String title;
128+
/**
129+
* The problem details.
130+
*/
87131
public String details;
132+
/**
133+
* The problem status code.
134+
*/
88135
public int status;
136+
/**
137+
* The problem instance.
138+
*/
89139
public URI instance;
90140
}
91141

@@ -104,6 +154,13 @@ private static JsonService getJsonService() {
104154
return ProblemDetails.jsonService;
105155
}
106156

157+
/**
158+
* Builds a {@link ProblemDetails} instance from an HTTP error response.
159+
* @param statusCode the HTTP error response status code
160+
* @param headers the HTTP error response headers
161+
* @param body the HTTP error response body
162+
* @return a {@link ProblemDetails} instance
163+
*/
107164
public static ProblemDetails fromErrorResponse(
108165
final int statusCode,
109166
final Headers headers,

api/src/main/java/com/inrupt/client/Response.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ interface ResponseInfo {
9797
ByteBuffer body();
9898
}
9999

100+
/**
101+
* Indicates whether a status code reflects a successful HTTP response.
102+
* @param statusCode the HTTP response status code
103+
* @return true if the status code is in the success range, namely [200, 299].
104+
*/
100105
static boolean isSuccess(final int statusCode) {
101106
return statusCode >= 200 && statusCode < 300;
102107
}

build-tools/owasp/suppressions.xml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,6 @@
1010
</suppress>
1111

1212
<!-- Suppressed vulnerabilities. These need monthly review. -->
13-
<suppress until="2024-03-01Z">
14-
<notes><![CDATA[
15-
This vulnerability appears when both Spring MVC AND Spring Security 6.2.1+ appear on the classpath. The JCL only uses Spring Security.
16-
]]></notes>
17-
<packageUrl regex="true">^pkg:maven/org\.springframework/spring-.*@.*$</packageUrl>
18-
<vulnerabilityName>CVE-2024-22233</vulnerabilityName>
19-
</suppress>
20-
<suppress until="2024-02-01Z">
21-
<notes><![CDATA[
22-
This vulnerability appears via wiremock and is used only during test execution. As such, the
23-
parse vulnerability is not relevant.
24-
]]></notes>
25-
<packageUrl regex="true">^pkg:maven/com\.jayway\.jsonpath/json\-path@.*$</packageUrl>
26-
<vulnerabilityName>CVE-2023-51074</vulnerabilityName>
27-
</suppress>
28-
<suppress until="2023-12-12Z">
29-
<notes><![CDATA[
30-
This vulnerability appears via wiremock and is used only during test execution. As such, the
31-
rapid reset DoS vector is not relevant.
32-
]]></notes>
33-
<packageUrl regex="true">^pkg:maven/org\.eclipse\.jetty\.http2/http2\-.*@.*$</packageUrl>
34-
<vulnerabilityName>CVE-2023-44487</vulnerabilityName>
35-
</suppress>
36-
<suppress until="2023-12-12Z">
37-
<notes><![CDATA[
38-
This vulnerability appears via wiremock and is used only during test execution. As such, the
39-
rapid reset DoS vector is not relevant.
40-
]]></notes>
41-
<packageUrl regex="true">^pkg:maven/org\.eclipse\.jetty/jetty\-.*@.*$</packageUrl>
42-
<vulnerabilityName>CVE-2023-44487</vulnerabilityName>
43-
</suppress>
4413
<suppress until="2024-06-12Z">
4514
<notes><![CDATA[
4615
This vulnerability impacts the `UriComponentsBuilder` class, which we are not using.

solid/src/main/java/com/inrupt/client/solid/SolidClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public <T extends Resource> CompletionStage<T> read(final URI identifier, final
140140
Response.BodyHandlers.throwOnError(
141141
Response.BodyHandlers.ofByteArray(),
142142
(r) -> Response.isSuccess(r.statusCode()),
143-
httpExceptionMapper("Reading resource " + request.uri() + " failed.")
143+
httpExceptionMapper("Reading resource failed.")
144144
)
145145
).thenApply(response -> {
146146
final String contentType = response.headers().firstValue(CONTENT_TYPE)

0 commit comments

Comments
 (0)