risdenk commented on a change in pull request #274: KNOX-2212 - Token 
permissiveness
URL: https://github.com/apache/knox/pull/274#discussion_r385316073
 
 

 ##########
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenStateService.java
 ##########
 @@ -310,4 +325,30 @@ protected boolean needsEviction(final String token) 
throws UnknownTokenException
     return tokenExpirations.keySet().stream().collect(Collectors.toList());
   }
 
+  /**
+   * A function that returns the JWT token expiration. This is only called when
+   * gateway.knox.token.permissive.failure.enabled property is set to true.
+   *
+   * @param token token to be verified and saved
+   */
+  protected long getJWTTokenExpiration(final String token) {
+    if (!isValidIdentifier(token)) {
+      throw new IllegalArgumentException("Token data cannot be null.");
+    }
+    JWT jwt;
+    try {
+      jwt = new JWTToken(token);
+    } catch (final ParseException e) {
+      log.errorParsingToken(e.toString());
+      throw new IllegalArgumentException(e);
 
 Review comment:
   Right but the method signature where all this is called is:
   
   `public long getTokenExpiration(final String token) throws 
UnknownTokenException {`
   
   So why would we throw an `IllegalArgumentException`? Its an unchecked 
runtimeexception so do we know how that bubbles back up to the caller? Is every 
user of `DefaultTokenStateService#getTokenExpiration` going to know to check 
for `IllegalArgumentException`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to