gnodet-bot commented on code in PR #31274:
URL: https://github.com/apache/camel/pull/31274#discussion_r4770702141


##########
components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java:
##########
@@ -166,6 +166,22 @@ private void getSessionToken(StsClient stsClient, Exchange 
exchange) throws Inva
             }
         } else {
             GetSessionTokenRequest.Builder builder = 
GetSessionTokenRequest.builder();
+            Integer durationSeconds = 
exchange.getIn().getHeader(STS2Constants.DURATION_SECONDS, Integer.class);
+            if (ObjectHelper.isNotEmpty(durationSeconds)) {
+                builder.durationSeconds(durationSeconds);
+            }
+            String serialNumber = 
exchange.getIn().getHeader(STS2Constants.SERIAL_NUMBER, String.class);
+            String tokenCode = 
exchange.getIn().getHeader(STS2Constants.TOKEN_CODE, String.class);
+            if (ObjectHelper.isNotEmpty(serialNumber) != 
ObjectHelper.isNotEmpty(tokenCode)) {
+                throw new IllegalArgumentException(
+                        "The " + STS2Constants.SERIAL_NUMBER + " and " + 
STS2Constants.TOKEN_CODE
+                                                   + " headers of 
getSessionToken are set together, as MFA needs both the"
+                                                   + " device and its one-time 
code");
+            }

Review Comment:
   💡 **Nit:** The error message reads as if the two headers *are* set together, 
but this exception fires precisely when they are *not*. `"must be set 
together"` makes the constraint clear.
   
   ```suggestion
                   throw new IllegalArgumentException(
                           "The " + STS2Constants.SERIAL_NUMBER + " and " + 
STS2Constants.TOKEN_CODE
                                                      + " headers of 
getSessionToken must be set together, as MFA needs both the"
                                                      + " device and its 
one-time code");
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to