Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit442d7e0

Browse files
Luis Garzarueiyhuang
Luis Garza
authored andcommitted
Removed Jackson dependency for non-IAM authentication mechanisms
1 parentb6cbc42 commit442d7e0

File tree

6 files changed

+37
-38
lines changed

6 files changed

+37
-38
lines changed

‎src/main/java/com/amazon/redshift/core/IdpAuthHelper.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
importcom.amazon.redshift.util.RedshiftException;
1616
importcom.amazon.redshift.util.RedshiftProperties;
1717
importcom.amazon.redshift.util.RedshiftState;
18+
importcom.amazon.redshift.util.JsonUtils;
1819
importcom.fasterxml.jackson.core.JsonProcessingException;
1920
importcom.fasterxml.jackson.databind.JsonNode;
2021
importsoftware.amazon.awssdk.auth.credentials.AwsBasicCredentials;
@@ -187,7 +188,7 @@ private static RedshiftProperties readAuthProfile(String authProfile, String iam
187188

188189

189190
try {
190-
JsonNodeprofileJson =Utils.parseJson(profileContent);
191+
JsonNodeprofileJson =JsonUtils.parseJson(profileContent);
191192
Iterator<Entry<String,JsonNode>>elements =profileJson.fields();
192193

193194
while (elements.hasNext()) {

‎src/main/java/com/amazon/redshift/core/Utils.java‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
importcom.amazon.redshift.util.GT;
1010
importcom.amazon.redshift.util.RedshiftException;
1111
importcom.amazon.redshift.util.RedshiftState;
12-
importcom.fasterxml.jackson.core.JsonProcessingException;
13-
importcom.fasterxml.jackson.databind.JsonNode;
14-
importcom.fasterxml.jackson.databind.ObjectMapper;
1512

1613
importjava.io.IOException;
1714
importjava.nio.charset.Charset;
@@ -22,8 +19,6 @@
2219
*/
2320
publicclassUtils {
2421

25-
privatestaticfinalObjectMapperOBJECT_MAPPER =newObjectMapper();
26-
2722
/**
2823
* Turn a bytearray into a printable form, representing each byte in hex.
2924
*
@@ -218,30 +213,4 @@ public static int parseServerVersionStr(String serverVersion) throws NumberForma
218213
publicstaticbooleanisNullOrEmpty(Stringvalue) {
219214
returnvalue ==null ||value.isEmpty();
220215
}
221-
222-
/**
223-
* Parses a JSON string into a JsonNode object.
224-
*
225-
* @param json The JSON string to be parsed. Must be a valid JSON format.
226-
* Can represent an object, array, or primitive JSON value.
227-
* @return A JsonNode representing the parsed JSON structure.
228-
* The specific type of JsonNode (ObjectNode, ArrayNode, etc.)
229-
* will depend on the input JSON structure.
230-
* @throws JsonProcessingException if the input string is not valid JSON,
231-
* or if there are any other problems parsing the JSON content.
232-
* @throws IllegalArgumentException if the input string is null.
233-
*
234-
* @see com.fasterxml.jackson.databind.JsonNode
235-
* @see com.fasterxml.jackson.databind.ObjectMapper#readTree(String)
236-
*
237-
* Example usage:
238-
* <pre>
239-
* String jsonString = "{\"name\":\"John\",\"age\":30}";
240-
* JsonNode node = JsonUtil.parseJson(jsonString);
241-
* String name = node.get("name").asText();
242-
* </pre>
243-
*/
244-
publicstaticJsonNodeparseJson(Stringjson)throwsJsonProcessingException {
245-
returnOBJECT_MAPPER.readTree(json);
246-
}
247216
}

‎src/main/java/com/amazon/redshift/plugin/AzureCredentialsProvider.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packagecom.amazon.redshift.plugin;
22

3-
importcom.amazon.redshift.core.Utils;
3+
importcom.amazon.redshift.core.Utils;
4+
importcom.amazon.redshift.util.JsonUtils;
45
importcom.fasterxml.jackson.core.JsonProcessingException;
56
importcom.fasterxml.jackson.databind.JsonNode;
67
importcom.amazon.redshift.RedshiftProperty;
@@ -204,7 +205,7 @@ private String azureOauthBasedAuthentication() throws IOException, SdkClientExce
204205
Stringcontent =EntityUtils.toString(resp.getEntity());
205206
JsonNodeentityJson;
206207
try {
207-
entityJson =Utils.parseJson(content);
208+
entityJson =JsonUtils.parseJson(content);
208209
}catch (JsonProcessingExceptione) {
209210
throwSdkClientException.create("Failed to parse Azure response.",e);
210211
}

‎src/main/java/com/amazon/redshift/plugin/BrowserAzureCredentialsProvider.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packagecom.amazon.redshift.plugin;
22

3-
importcom.amazon.redshift.core.Utils;
3+
importcom.amazon.redshift.core.Utils;
4+
importcom.amazon.redshift.util.JsonUtils;
45
importcom.amazon.redshift.logger.LogLevel;
56
importcom.amazon.redshift.logger.RedshiftLogger;
67
importcom.amazon.redshift.plugin.httpserver.RequestHandler;
@@ -402,7 +403,7 @@ private String extractSamlAssertion(String content)
402403
{
403404
JsonNodeaccessTokenField;
404405
try {
405-
accessTokenField =Utils.parseJson(content).findValue("access_token");
406+
accessTokenField =JsonUtils.parseJson(content).findValue("access_token");
406407
}catch (JsonProcessingExceptione) {
407408
thrownewInternalPluginException("Failed to parse access_token");
408409
}

‎src/main/java/com/amazon/redshift/plugin/BrowserAzureOAuth2CredentialsProvider.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packagecom.amazon.redshift.plugin;
22

3-
importcom.amazon.redshift.core.Utils;
3+
importcom.amazon.redshift.core.Utils;
4+
importcom.amazon.redshift.util.JsonUtils;
45
importcom.amazon.redshift.logger.LogLevel;
56
importcom.amazon.redshift.logger.RedshiftLogger;
67
importcom.amazon.redshift.plugin.httpserver.RequestHandler;
@@ -408,7 +409,7 @@ private String extractJwtAssertion(String content)
408409
{
409410
JsonNodeaccessTokenField;
410411
try {
411-
accessTokenField =Utils.parseJson(content).findValue("access_token");
412+
accessTokenField =JsonUtils.parseJson(content).findValue("access_token");
412413
}catch (JsonProcessingExceptione) {
413414
thrownewInternalPluginException("Failed to parse access_token from response.");
414415
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
packagecom.amazon.redshift.util;
2+
3+
importcom.fasterxml.jackson.core.JsonProcessingException;
4+
importcom.fasterxml.jackson.databind.JsonNode;
5+
importcom.fasterxml.jackson.databind.ObjectMapper;
6+
7+
/**
8+
* JSON parsing utilities for authentication providers.
9+
*/
10+
publicclassJsonUtils {
11+
12+
privatestaticfinalObjectMapperOBJECT_MAPPER =newObjectMapper();
13+
14+
/**
15+
* Parses a JSON string into a JsonNode object.
16+
*
17+
* @param json The JSON string to parse. Must not be null.
18+
* @return A JsonNode representing the parsed JSON structure.
19+
* @throws JsonProcessingException if the input is not valid JSON content
20+
* or if there are any other problems parsing the JSON content.
21+
* @throws IllegalArgumentException if the input string is null.
22+
*/
23+
publicstaticJsonNodeparseJson(Stringjson)throwsJsonProcessingException {
24+
returnOBJECT_MAPPER.readTree(json);
25+
}
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp