From afff284bd8c3e0d201b5f5c1fb7814853fb75090 Mon Sep 17 00:00:00 2001 From: arithmetic1728 Date: Thu, 4 Feb 2021 21:13:51 -0800 Subject: [PATCH] feat: self signed jwt support --- google-cloud-kms/pom.xml | 18 +++++---- .../KeyManagementServiceStubSettings.java | 3 +- .../com/google/cloud/kms/v1/SampleTest.java | 39 +++++++++++++++++++ 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 google-cloud-kms/src/test/java/com/google/cloud/kms/v1/SampleTest.java diff --git a/google-cloud-kms/pom.xml b/google-cloud-kms/pom.xml index 9477d036..4b63830d 100644 --- a/google-cloud-kms/pom.xml +++ b/google-cloud-kms/pom.xml @@ -17,6 +17,16 @@ google-cloud-kms + + com.google.api + gax + 1.60.1 + + + com.google.api + gax-grpc + 1.60.1 + io.grpc grpc-api @@ -50,14 +60,6 @@ com.google.guava guava - - com.google.api - gax - - - com.google.api - gax-grpc - org.threeten threetenbp diff --git a/google-cloud-kms/src/main/java/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java b/google-cloud-kms/src/main/java/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java index a408e089..05ebddd3 100644 --- a/google-cloud-kms/src/main/java/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java +++ b/google-cloud-kms/src/main/java/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java @@ -358,7 +358,7 @@ public static List getDefaultServiceScopes() { /** Returns a builder for the default credentials for this service. */ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + return GoogleCredentialsProvider.newBuilder().setDefaultScopes(DEFAULT_SERVICE_SCOPES).setScopesToApply(ImmutableList.of()); } /** Returns a builder for the default ChannelProvider for this service. */ @@ -854,6 +854,7 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setDefaultEndpoint(getDefaultEndpoint()); return initDefaults(builder); } diff --git a/google-cloud-kms/src/test/java/com/google/cloud/kms/v1/SampleTest.java b/google-cloud-kms/src/test/java/com/google/cloud/kms/v1/SampleTest.java new file mode 100644 index 00000000..38fc2c2b --- /dev/null +++ b/google-cloud-kms/src/test/java/com/google/cloud/kms/v1/SampleTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.kms.v1; + +import static com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse; + +import com.google.common.collect.Lists; + +import java.util.List; +import org.junit.Test; + +public class SampleTest { + + @Test + public void myTest() throws Exception { + KeyManagementServiceSettings settings = KeyManagementServiceSettings.newBuilder().build(); + KeyManagementServiceClient client = KeyManagementServiceClient.create(settings); + String project = "projects/shinfan-mtls-demo/locations/global"; + // project = "projects/study-auth-265119/locations/global"; + + ListKeyRingsPagedResponse resp = client.listKeyRings(project); + List resources = Lists.newArrayList(resp.iterateAll()); + System.out.println(resources); + } +}