Commit 6ac762b7 authored by Sheng Wang's avatar Sheng Wang
Browse files

capture error when get keyvault secret

parent dccae799
Pipeline #24658 failed with stages
in 8 minutes and 21 seconds
......@@ -16,6 +16,8 @@ package org.opengroup.osdu.wd.azure.keyvault;
import com.azure.identity.DefaultAzureCredential;
import com.azure.security.keyvault.secrets.SecretClient;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.client.model.http.AppException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......@@ -31,10 +33,14 @@ public class KeyvaultClient {
private String keyVaultURL;
public String getSecretValue(String key) {
SecretClient secretClient = buildSecretsClient();
String value = KeyVaultFacade.getSecretWithValidation(secretClient, key);
LOGGER.log(Level.INFO, String.format("Secret %s: %s***", key, value.substring(0, 3)));
return value;
try {
SecretClient secretClient = buildSecretsClient();
String value = KeyVaultFacade.getSecretWithValidation(secretClient, key);
LOGGER.log(Level.INFO, String.format("Secret %s: %s***", key, value.substring(0, 3)));
return value;
}catch (Exception e){
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Internal Server Error", String.format("Error getting Secret for key: %s", key), e);
}
}
private SecretClient buildSecretsClient() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment