String getJWTFromCookie(HttpServletRequest req) {
    String serializedJWT = null;
    Cookie[] cookies = req.getCookies();
    if (cookies != null) {
      JwtAuthenticationProperties jwtProperties = propertiesProvider.get();
      String jwtCookieName = (jwtProperties == null) ? null : jwtProperties.getCookieName();
      if (StringUtils.isEmpty(jwtCookieName)) {
        jwtCookieName = AmbariServerConfigurationKey.SSO_JWT_COOKIE_NAME.getDefaultValue();
      }

      for (Cookie cookie : cookies) {
        if (jwtCookieName.equals(cookie.getName())) {
          LOG.info("{} cookie has been found and is being processed", jwtCookieName);
          serializedJWT = cookie.getValue();
          break;
        }
      }
    }
    return serializedJWT;
  }
Encapsulate the acquisition of the JWT token from HTTP cookies within the
request.

@param req servlet request to get the JWT token from
@return serialized JWT token
ambari-server/src/main/java/org/apache/ambari/server/security/authentication/jwt/AmbariJwtAuthenticationFilter.java