From b3d42f9d18f9b1688bf6f9f4d213cf3638974ae4 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 4 Oct 2023 16:43:12 +0800 Subject: [PATCH] fix awsauth in okhttp gson java client --- .../Java/libraries/okhttp-gson/auth/AWS4Auth.mustache | 6 +++++- .../Java/libraries/okhttp-gson/build.gradle.mustache | 3 +++ .../resources/Java/libraries/okhttp-gson/build.sbt.mustache | 3 +++ .../main/resources/Java/libraries/okhttp-gson/pom.mustache | 3 +-- samples/client/echo_api/java/okhttp-gson/pom.xml | 1 - samples/client/others/java/okhttp-gson-streaming/pom.xml | 1 - samples/client/petstore/java/okhttp-gson-3.1/pom.xml | 1 - .../petstore/java/okhttp-gson-awsv4signature/build.gradle | 1 + .../petstore/java/okhttp-gson-awsv4signature/build.sbt | 1 + .../client/petstore/java/okhttp-gson-awsv4signature/pom.xml | 1 - .../petstore/java/okhttp-gson-dynamicOperations/pom.xml | 1 - .../petstore/java/okhttp-gson-group-parameter/pom.xml | 1 - .../petstore/java/okhttp-gson-nullable-required/pom.xml | 1 - .../petstore/java/okhttp-gson-parcelableModel/pom.xml | 1 - samples/client/petstore/java/okhttp-gson-swagger1/pom.xml | 1 - samples/client/petstore/java/okhttp-gson-swagger2/pom.xml | 1 - samples/client/petstore/java/okhttp-gson/pom.xml | 1 - 17 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/AWS4Auth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/AWS4Auth.mustache index 5e11820e9a11..a9ee5ff646c8 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/AWS4Auth.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/AWS4Auth.mustache @@ -6,16 +6,20 @@ import {{invokerPackage}}.Pair; import {{invokerPackage}}.ApiException; import java.io.ByteArrayInputStream; +import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.List; +import java.util.stream.Collectors; import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.AwsCredentials; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.auth.signer.params.Aws4SignerParams; +import software.amazon.awssdk.http.ContentStreamProvider; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.regions.Region; @@ -25,7 +29,7 @@ import okio.Buffer; {{>generatedAnnotation}} public class AWS4Auth implements Authentication { - private AWSCredentials credentials; + private AwsCredentials credentials; private String region; private String service; diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache index f4032d8f7d53..0d0e4cc9481f 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache @@ -121,6 +121,9 @@ dependencies { {{#openApiNullable}} implementation 'org.openapitools:jackson-databind-nullable:0.2.6' {{/openApiNullable}} + {{#withAWSV4Signature}} + implementation 'software.amazon.awssdk:auth:2.20.157' + {{/withAWSV4Signature}} {{#hasOAuthMethods}} implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.2' {{/hasOAuthMethods}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache index cf50c15c4e84..8d7bd5a68fe8 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache @@ -19,6 +19,9 @@ lazy val root = (project in file(".")). {{#openApiNullable}} "org.openapitools" % "jackson-databind-nullable" % "0.2.6", {{/openApiNullable}} + {{#withAWSV4Signature}} + "software.amazon.awssdk" % "auth" % "2.20.157", + {{/withAWSV4Signature}} {{#hasOAuthMethods}} "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.2", {{/hasOAuthMethods}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache index 3c1b453e3161..2261a4025ea1 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache @@ -375,12 +375,11 @@ ${jackson-databind-nullable-version} {{/openApiNullable}} - {{#withAWSV4Signature}} software.amazon.awssdk auth - 2.20.120 + 2.20.157 {{/withAWSV4Signature}} diff --git a/samples/client/echo_api/java/okhttp-gson/pom.xml b/samples/client/echo_api/java/okhttp-gson/pom.xml index 66a91a826524..47865e769e85 100644 --- a/samples/client/echo_api/java/okhttp-gson/pom.xml +++ b/samples/client/echo_api/java/okhttp-gson/pom.xml @@ -300,7 +300,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/others/java/okhttp-gson-streaming/pom.xml b/samples/client/others/java/okhttp-gson-streaming/pom.xml index a3e4248648cd..f6bdcbd7b95f 100644 --- a/samples/client/others/java/okhttp-gson-streaming/pom.xml +++ b/samples/client/others/java/okhttp-gson-streaming/pom.xml @@ -300,7 +300,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson-3.1/pom.xml b/samples/client/petstore/java/okhttp-gson-3.1/pom.xml index ddf50ad183e6..a6037898ab5a 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-3.1/pom.xml @@ -305,7 +305,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/build.gradle b/samples/client/petstore/java/okhttp-gson-awsv4signature/build.gradle index 50af067a5ab8..504ebafa3665 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/build.gradle +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/build.gradle @@ -115,6 +115,7 @@ dependencies { implementation 'javax.ws.rs:jsr311-api:1.1.1' implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' implementation 'org.openapitools:jackson-databind-nullable:0.2.6' + implementation 'software.amazon.awssdk:auth:2.20.157' implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.2' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/build.sbt b/samples/client/petstore/java/okhttp-gson-awsv4signature/build.sbt index 30f3633352c6..b86eb7e785c4 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/build.sbt +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/build.sbt @@ -17,6 +17,7 @@ lazy val root = (project in file(".")). "javax.ws.rs" % "jsr311-api" % "1.1.1", "javax.ws.rs" % "javax.ws.rs-api" % "2.1.1", "org.openapitools" % "jackson-databind-nullable" % "0.2.6", + "software.amazon.awssdk" % "auth" % "2.20.157", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.2", "io.gsonfire" % "gson-fire" % "1.8.5" % "compile", "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/pom.xml b/samples/client/petstore/java/okhttp-gson-awsv4signature/pom.xml index acdc6f48ff2b..2816a3509d8b 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/pom.xml @@ -305,7 +305,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - software.amazon.awssdk auth diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml b/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml index 5e90d1fb12e7..7c1dde4a9db6 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml @@ -310,7 +310,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/pom.xml b/samples/client/petstore/java/okhttp-gson-group-parameter/pom.xml index 570257c5f84a..39726ef1a5ac 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/pom.xml @@ -305,7 +305,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/pom.xml b/samples/client/petstore/java/okhttp-gson-nullable-required/pom.xml index 7550ed608dd7..5e1c8d866547 100644 --- a/samples/client/petstore/java/okhttp-gson-nullable-required/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-nullable-required/pom.xml @@ -305,7 +305,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/pom.xml b/samples/client/petstore/java/okhttp-gson-parcelableModel/pom.xml index c3f34dcbd183..7d329eddb5c7 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/pom.xml @@ -312,7 +312,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/pom.xml b/samples/client/petstore/java/okhttp-gson-swagger1/pom.xml index 1a1e48ea451c..ca06f5bb59f0 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-swagger1/pom.xml @@ -310,7 +310,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson-swagger2/pom.xml b/samples/client/petstore/java/okhttp-gson-swagger2/pom.xml index b2db3f3da484..3ef2bee4970b 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger2/pom.xml +++ b/samples/client/petstore/java/okhttp-gson-swagger2/pom.xml @@ -310,7 +310,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api diff --git a/samples/client/petstore/java/okhttp-gson/pom.xml b/samples/client/petstore/java/okhttp-gson/pom.xml index a50f71b24085..7831b90f739e 100644 --- a/samples/client/petstore/java/okhttp-gson/pom.xml +++ b/samples/client/petstore/java/okhttp-gson/pom.xml @@ -305,7 +305,6 @@ jackson-databind-nullable ${jackson-databind-nullable-version} - javax.ws.rs jsr311-api