From e9a5430c2557778bc6c43986527d57023090e781 Mon Sep 17 00:00:00 2001 From: "eric.steele" Date: Tue, 31 May 2022 18:03:17 -0700 Subject: AmazonS3: Add support for AWS API signature version 4 Updating the AmazonS3 class to support AWS Signature version 4 because version 2 is no longer supported in all AWS regions. The version can be selected with the new 'aws.api.signature.version' property (defaults to 2 for backwards compatibility). When set to '4', the user must also specify the AWS region via the 'region' property. The 'region' property must match the region that the 'domain' property resolves to. Bug: 579907 Change-Id: If289dbc6d0f57323cfeaac2624c4eb5028f78d13 --- .../src/org/eclipse/jgit/util/HttpSupport.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java index 23a73faf8c..663a3449e1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java @@ -185,6 +185,33 @@ public class HttpSupport { } } + /** + * Translates the provided URL into application/x-www-form-urlencoded + * format. + * + * @param url + * The URL to translate. + * @param keepPathSlash + * Whether or not to keep "/" in the URL (i.e. don't translate + * them to "%2F"). + * + * @return The translated URL. + * @since 5.13 + */ + public static String urlEncode(String url, boolean keepPathSlash) { + String encoded; + try { + encoded = URLEncoder.encode(url, UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, + e); + } + if (keepPathSlash) { + encoded = encoded.replace("%2F", "/"); //$NON-NLS-1$ //$NON-NLS-2$ + } + return encoded; + } + /** * Get the HTTP response code from the request. *

-- cgit v1.2.3