Skip to content

Commit

Permalink
Add Locale.ROOT
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Dec 19, 2022
1 parent b39cd11 commit ad2f483
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -69,6 +71,7 @@ private <Request extends ActionRequest, Response extends ActionResponse> 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(),
Expand All @@ -77,7 +80,7 @@ private <Request extends ActionRequest, Response extends ActionResponse> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
Expand All @@ -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);
Expand Down

0 comments on commit ad2f483

Please sign in to comment.