From eb5747fdbf22b0cf12bce02ed3f74557fcae3e57 Mon Sep 17 00:00:00 2001 From: Yi Shi Date: Tue, 31 Oct 2023 15:48:07 +0800 Subject: [PATCH] update ref binary --- pom.xml | 22 ++++++--- .../operator/GcpOperatorKeyRetriever.java | 46 ------------------- src/main/java/com/uid2/operator/Main.java | 3 +- 3 files changed, 17 insertions(+), 54 deletions(-) delete mode 100644 src/main/java/com/uid2/operator/GcpOperatorKeyRetriever.java diff --git a/pom.xml b/pom.xml index 973942ad3..ab2361bbe 100644 --- a/pom.xml +++ b/pom.xml @@ -21,17 +21,25 @@ 1.5.0-676519b018 1.1.0 1.4.0-2195ee834a - 1.3.4-649b0b4f7f - 5.14.0-f627d5e88c + 1.3.8-SNAPSHOT + 5.15.3-SNAPSHOT ${project.version} + + + snapshots-repo + https://s01.oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + - - com.google.cloud - google-cloud-secretmanager - 2.29.0 - com.google.guava guava diff --git a/src/main/java/com/uid2/operator/GcpOperatorKeyRetriever.java b/src/main/java/com/uid2/operator/GcpOperatorKeyRetriever.java deleted file mode 100644 index 397b76b1b..000000000 --- a/src/main/java/com/uid2/operator/GcpOperatorKeyRetriever.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.uid2.operator; - -import com.google.api.gax.retrying.RetrySettings; -import com.google.cloud.secretmanager.v1.*; -import com.uid2.enclave.IOperatorKeyRetriever; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.threeten.bp.Duration; - -import java.io.IOException; - -public class GcpOperatorKeyRetriever implements IOperatorKeyRetriever { - private static final Logger LOGGER = LoggerFactory.getLogger(GcpOperatorKeyRetriever.class); - - private final SecretVersionName secretVersionName; - /** - * Retrieve secret value from GCP SecretManager - * @param secretVersionName in "projects/{project}/secrets/{secret}/versions/{secret_version}" format - */ - public GcpOperatorKeyRetriever(String secretVersionName){ - // Will throw IllegalArgument Exception for invalid format - this.secretVersionName = SecretVersionName.parse(secretVersionName); - } - - @Override - public String retrieve() { - var retrySetting = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofSeconds(3)) - .setMaxRetryDelay(Duration.ofSeconds(3)) - .setMaxAttempts(3) - .build(); - var settingsBuilder =SecretManagerServiceSettings.newBuilder(); - settingsBuilder.accessSecretVersionSettings().setRetrySettings(retrySetting); - - try(var client = SecretManagerServiceClient.create(settingsBuilder.build())) { - var response = client.accessSecretVersion(this.secretVersionName); - String payload = response.getPayload().getData().toStringUtf8(); - LOGGER.info("Plaintext: " + payload); - - return payload; - } catch (IOException e) { - LOGGER.error("Error: " + e.getMessage()); - throw new RuntimeException(e); - } - } -} diff --git a/src/main/java/com/uid2/operator/Main.java b/src/main/java/com/uid2/operator/Main.java index 4459d84de..777b9cb32 100644 --- a/src/main/java/com/uid2/operator/Main.java +++ b/src/main/java/com/uid2/operator/Main.java @@ -1,6 +1,7 @@ package com.uid2.operator; import ch.qos.logback.classic.LoggerContext; +import com.google.common.base.Strings; import com.uid2.enclave.IOperatorKeyRetriever; import com.uid2.operator.model.KeyManager; import com.uid2.operator.monitoring.IStatsCollectorQueue; @@ -501,7 +502,7 @@ private IOperatorKeyRetriever createOperatorKeyRetriever() throws Exception { } case "gcp-oidc": { var secretVersionName = this.config.getString(Const.Config.GcpSecretVersionNameProp); - return new GcpOperatorKeyRetriever(secretVersionName); + return OperatorKeyRetrieverFactory.getGcpOperatorKeyRetriever(secretVersionName); } default: { // default to load from config