diff --git a/README.md b/README.md index d9a0d01..15f0b5e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This is a zero-dependency Java library to sign Jersey requests with a AWS4 signa com.axonivy.connector.aws amazon-aws4-authenticator - 0.0.5 + 0.0.6 ``` diff --git a/pom.xml b/pom.xml index a288d41..187caa6 100644 --- a/pom.xml +++ b/pom.xml @@ -41,13 +41,13 @@ org.glassfish.jersey.core jersey-client - 2.34 + 2.45 test org.glassfish.jersey.inject jersey-hk2 - 2.34 + 2.45 test diff --git a/src/main/java/com/axonivy/connector/aws/authentication/Aws4AuthenticationRequestFilter.java b/src/main/java/com/axonivy/connector/aws/authentication/Aws4AuthenticationRequestFilter.java index a592113..7e9203a 100644 --- a/src/main/java/com/axonivy/connector/aws/authentication/Aws4AuthenticationRequestFilter.java +++ b/src/main/java/com/axonivy/connector/aws/authentication/Aws4AuthenticationRequestFilter.java @@ -33,7 +33,7 @@ public void filter(ClientRequestContext context) throws IOException { headers.add(X_AMZ_DATE, signer.getTimeStamp()); headers.add(AUTHORIZATION, signer.sign()); } catch (NoSuchAlgorithmException | InvalidKeyException ex) { - throw new IOException("Could not sign Amazon AWS request", ex); + throw new IOException("Could not sign request", ex); } } } diff --git a/src/main/java/com/axonivy/connector/aws/authentication/CanonicalRequest.java b/src/main/java/com/axonivy/connector/aws/authentication/CanonicalRequest.java index 80e35e8..c8c5c67 100644 --- a/src/main/java/com/axonivy/connector/aws/authentication/CanonicalRequest.java +++ b/src/main/java/com/axonivy/connector/aws/authentication/CanonicalRequest.java @@ -3,6 +3,9 @@ import static com.axonivy.connector.aws.authentication.Constants.SIGNED_HEADERS; import static com.axonivy.connector.aws.authentication.Constants.X_AMZ_DATE; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + import javax.ws.rs.client.ClientRequestContext; class CanonicalRequest { @@ -38,8 +41,18 @@ private void appendPath() { if (path == null || path.isEmpty()) { path = "/"; } - builder.append(path); - builder.append('\n'); + try { + System.out.println(path); + var encodedPath = URLEncoder.encode(path, StandardCharsets.UTF_8.toString()) + .replace("%2F", "/") + .replace("%7E", "~") + .replace("*", "%2A") + .replace("+", "%20"); + builder.append(encodedPath); + builder.append('\n'); + } catch (Exception ex) { + throw new RuntimeException("Could not encode path " + path, ex); + } } private void appendQuery() {