code: public static boolean hasValidAuthentication(String cookie) {
          boolean valid = false;
          if (StringUtils.isNotBlank(cookie)) {
              Config config = Application.getInstance(Config.class);
  
              String value = null;
              String [] contents = cookie.split(";");
              for (String content : contents) {
                  if (StringUtils.isNotBlank(content) && content.startsWith(config.getAuthenticationCookieName())) {
                      value = StringUtils.substringAfter(content, config.getAuthenticationCookieName() + "=");
                      value = PATTERN.matcher(value).replaceAll("");
                  }
              }
              
              if (StringUtils.isNotBlank(value)) {
                  String jwt = Application.getInstance(Crypto.class).decrypt(value, config.getAuthenticationCookieEncryptionKey());
                  
                  JwtConsumer jwtConsumer = new JwtConsumerBuilder()
                          .setRequireExpirationTime()
                          .setRequireSubject()
                          .setVerificationKey(new HmacKey(config.getAuthenticationCookieSignKey().getBytes(StandardCharsets.UTF_8)))
                          .setJwsAlgorithmConstraints(new AlgorithmConstraints(ConstraintType.WHITELIST, AlgorithmIdentifiers.HMAC_SHA512))
                          .build();
                  try {
                      jwtConsumer.processToClaims(jwt);
                      valid = true;
                  } catch (InvalidJwtException e) {
                      LOG.error("Failed to parse authentication cookie", e);
                  }
              }
          }
          
          return valid;
      }
docs: Checks if the given header contains a valid authentication
  
  @param cookie The cookie to parse
  @return True if the cookie contains a valid authentication, false otherwise