From 549281126db020e90c959f67f89eee623aa47625 Mon Sep 17 00:00:00 2001 From: Ryan Doherty Date: Mon, 12 Aug 2024 09:01:43 -0400 Subject: [PATCH] Allow setting of WDK secret key directly (rather than from interpreting a file) --- Model/lib/rng/wdkModel-config.rng | 3 +++ .../java/org/gusdb/wdk/model/config/ModelConfig.java | 5 ++++- .../org/gusdb/wdk/model/config/ModelConfigBuilder.java | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Model/lib/rng/wdkModel-config.rng b/Model/lib/rng/wdkModel-config.rng index e9d5e48b5..b5ffc0544 100644 --- a/Model/lib/rng/wdkModel-config.rng +++ b/Model/lib/rng/wdkModel-config.rng @@ -16,6 +16,9 @@ + + + diff --git a/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfig.java b/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfig.java index 5b9663bf8..5431946e1 100644 --- a/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfig.java +++ b/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfig.java @@ -142,7 +142,7 @@ public String getName() { private final Path _wdkTempDir; public ModelConfig(String modelName, String projectId, Path gusHome, boolean caching, boolean useWeights, - String paramRegex, Optional secretKeyFile, Path wdkTempDir, String webServiceUrl, String assetsUrl, + String paramRegex, Optional secretKeyFile, String secretKey, Path wdkTempDir, String webServiceUrl, String assetsUrl, String smtpServer, String supportEmail, List adminEmails, String emailSubject, String emailContent, ModelConfigUserDB userDB, ModelConfigAppDB appDB, ModelConfigUserDatasetStore userDatasetStoreConfig, QueryMonitor queryMonitor, @@ -163,6 +163,7 @@ public ModelConfig(String modelName, String projectId, Path gusHome, boolean cac // file locations _wdkTempDir = wdkTempDir; _secretKeyFile = secretKeyFile; + _secretKey = secretKey; // network locations _webServiceUrl = webServiceUrl; @@ -295,6 +296,8 @@ public ModelConfigAppDB getAppDB() { * configured secret key file. If the configured filename is null or the contents * of the file cannot be read for any reason, null is returned. * + * Note: as of 8/12/24, you can alternatively directly set the secretKey in model-config.xml + * * @return secret key */ public String getSecretKey() { diff --git a/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfigBuilder.java b/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfigBuilder.java index ae414d590..39bdab57b 100644 --- a/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfigBuilder.java +++ b/Model/src/main/java/org/gusdb/wdk/model/config/ModelConfigBuilder.java @@ -29,6 +29,7 @@ public class ModelConfigBuilder { // file locations private String _secretKeyFile; + private String _secretKey; private String _wdkTempDir = "/tmp"; // network locations @@ -107,6 +108,7 @@ public ModelConfig build() throws WdkModelException { // file locations secretKeyFile, + _secretKey, wdkTempDir, // network locations @@ -253,6 +255,14 @@ public void setSecretKeyFile(String secretKeyFile) { _secretKeyFile = secretKeyFile; } + /** + * @param secretKeyFile + * the secretKeyFile to set + */ + public void setSecretKey(String secretKey) { + _secretKey = secretKey; + } + /** * @param authenticationMethod configured authentication method */