From ad2f4837d6ff7f5dbe21290743c78e03ccbc3a3e Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Mon, 19 Dec 2022 11:39:49 -0500 Subject: [PATCH] Add Locale.ROOT Signed-off-by: Craig Perkins --- .../main/java/org/opensearch/identity/SecurityFilter.java | 5 ++++- .../java/org/opensearch/identity/SecurityRestFilter.java | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityFilter.java b/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityFilter.java index 6486bf4da4b46..1682c978fd9ed 100644 --- a/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityFilter.java +++ b/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityFilter.java @@ -26,6 +26,8 @@ import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; +import java.util.Locale; + public class SecurityFilter implements ActionFilter { protected final Logger log = LogManager.getLogger(this.getClass()); @@ -69,6 +71,7 @@ private void ap // TODO Get jwt here and verify // TODO Move this logic to right after successful login String requestInfo = String.format( + Locale.ROOT, "(nodeName=%s, requestId=%s, action=%s apply0)", cs.localNode().getId(), request.getParentTask().getId(), @@ -77,7 +80,7 @@ private void ap String logMsg = ""; if (threadContext.getHeader(ThreadContextConstants.OPENSEARCH_AUTHENTICATION_TOKEN_HEADER) != null) { String encodedJwt = threadContext.getHeader(ThreadContextConstants.OPENSEARCH_AUTHENTICATION_TOKEN_HEADER); - logMsg = String.format("Access token provided %s", encodedJwt); + logMsg = String.format(Locale.ROOT, "Access token provided %s", encodedJwt); } else { // TODO Figure out where internal actions are invoked and create token on invocation // No token provided, may be an internal request diff --git a/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityRestFilter.java b/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityRestFilter.java index 7f30e9c2e0a52..2044c6897945c 100644 --- a/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityRestFilter.java +++ b/sandbox/modules/identity/src/main/java/org/opensearch/identity/SecurityRestFilter.java @@ -32,6 +32,7 @@ import java.time.Instant; import java.util.Collections; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Optional; @@ -80,6 +81,7 @@ private boolean checkAndAuthenticateRequest(RestRequest request, RestChannel cha jwtClaims.put("iat", Instant.now().toString()); String encodedJwt = JwtVendor.createJwt(jwtClaims); String requestInfo = String.format( + Locale.ROOT, "(nodeName=%s, requestId=%s, path=%s, jwtClaims=%s checkAndAuthenticateRequest)", client.getLocalNodeId(), request.getRequestId(), @@ -88,7 +90,7 @@ private boolean checkAndAuthenticateRequest(RestRequest request, RestChannel cha ); if (log.isDebugEnabled()) { log.debug(requestInfo); - String logMsg = String.format("Created internal access token %s", encodedJwt); + String logMsg = String.format(Locale.ROOT, "Created internal access token %s", encodedJwt); log.debug("{} {}", requestInfo, logMsg); } threadContext.putHeader(ThreadContextConstants.OPENSEARCH_AUTHENTICATION_TOKEN_HEADER, encodedJwt);