Skip to content

Commit

Permalink
CDAP-20867 switch to cheaper secure store call in oauth handler
Browse files Browse the repository at this point in the history
Switch to use cheaper SecureStore.getData() call instead of
SecureStore.get() when the secure key metadata is not needed
  • Loading branch information
albertshau committed Nov 1, 2023
1 parent 7e9946b commit 44609a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String evaluate(String macroFunction, String... arguments) throws Invalid
throw new InvalidMacroException("Secure store macro function only supports 1 argument.");
}
try {
return Bytes.toString(secureStore.get(namespace, arguments[0]).get());
return Bytes.toString(secureStore.getData(namespace, arguments[0]));
} catch (Exception e) {
throw new InvalidMacroException(
"Failed to resolve macro '" + macroFunction + "(" + arguments[0] + ")'", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Optional<OAuthProvider> getProvider(String name) throws OAuthStoreExcepti
OAuthClientCredentials clientCreds;
try {
String clientCredsJson = new String(
secureStore.get(NamespaceId.SYSTEM.getNamespace(), getClientCredsKey(name)).get(),
secureStore.getData(NamespaceId.SYSTEM.getNamespace(), getClientCredsKey(name)),
StandardCharsets.UTF_8);
clientCreds = GSON.fromJson(clientCredsJson, OAuthClientCredentials.class);
} catch (IOException e) {
Expand Down Expand Up @@ -171,7 +171,7 @@ public Optional<OAuthRefreshToken> getRefreshToken(String oauthProvider, String
throws OAuthStoreException {
try {
String tokenJson = new String(
secureStore.get(NamespaceId.SYSTEM.getNamespace(), getRefreshTokenKey(oauthProvider, credentialId)).get(),
secureStore.getData(NamespaceId.SYSTEM.getNamespace(), getRefreshTokenKey(oauthProvider, credentialId)),
StandardCharsets.UTF_8);
return Optional.of(GSON.fromJson(tokenJson, OAuthRefreshToken.class));
} catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion cdap-ui
Submodule cdap-ui updated 138 files

0 comments on commit 44609a5

Please sign in to comment.