quantranhong1999 commented on code in PR #2450:
URL: https://github.com/apache/james-project/pull/2450#discussion_r1800338631


##########
server/protocols/jmap/src/main/java/org/apache/james/jmap/http/XUserAuthenticationStrategy.java:
##########
@@ -69,4 +100,18 @@ private Mono<MailboxSession> createMailboxSession(Username 
username) {
     public AuthenticationChallenge correspondingChallenge() {
         return X_USER_CHALLENGE;
     }
+
+    private Function<HttpServerRequest, Optional<Username>> 
createUsernameExtractorWithoutSecretValidation() {
+        return httpRequest -> 
Optional.ofNullable(httpRequest.requestHeaders().get(X_USER_HEADER_NAME))
+            .map(String::trim)
+            .filter(s -> !s.isEmpty())
+            .map(Username::of);
+    }
+
+    private Function<HttpServerRequest, Optional<Username>> 
createUsernameExtractorWithSecretValidation(String secret) {
+        return httpRequest -> 
createUsernameExtractorWithoutSecretValidation().apply(httpRequest)
+            .filter(username -> 
Optional.ofNullable(httpRequest.requestHeaders().get(X_USER_SECRET_HEADER_NAME))
+                .map(secret::equals)
+                .orElse(false));
+    }

Review Comment:
   +1



##########
server/apps/.DS_Store:
##########


Review Comment:
   What is this file?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to