Class CookieUtils


  • public final class CookieUtils
    extends java.lang.Object
    The general set of Cookie utility methods.
    Author:
    Grizzly team
    • Constructor Summary

      Constructors 
      Constructor Description
      CookieUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean containsCTL​(java.lang.String value, int version)  
      static boolean equals​(java.lang.String s, byte[] b, int start, int end)  
      static boolean equals​(java.lang.String s1, java.lang.String s2, int start, int end)  
      static boolean equals​(java.lang.String s, Buffer b, int start, int end)  
      static boolean equalsIgnoreCase​(java.lang.String s, byte[] b, int start, int end)  
      static boolean equalsIgnoreCase​(java.lang.String s1, java.lang.String s2, int start, int end)  
      static boolean equalsIgnoreCase​(java.lang.String s, Buffer b, int start, int end)  
      static int getQuotedValueEndPosition​(byte[] bytes, int off, int end)
      Given a starting position after an initial quote character, this gets the position of the end quote.
      static int getQuotedValueEndPosition​(java.lang.String s, int off, int end)
      Given a starting position after an initial quote character, this gets the position of the end quote.
      static int getQuotedValueEndPosition​(Buffer buffer, int off, int end)
      Given a starting position after an initial quote character, this gets the position of the end quote.
      static int getTokenEndPosition​(byte[] bytes, int off, int end)
      Given the starting position of a token, this gets the end of the token, with no separator characters in between.
      static int getTokenEndPosition​(byte[] bytes, int off, int end, boolean parseAsVersion1)  
      static int getTokenEndPosition​(java.lang.String s, int off, int end)
      Given the starting position of a token, this gets the end of the token, with no separator characters in between.
      static int getTokenEndPosition​(java.lang.String s, int off, int end, boolean parseAsVersion1)  
      static int getTokenEndPosition​(Buffer buffer, int off, int end)
      Given the starting position of a token, this gets the end of the token, with no separator characters in between.
      static int getTokenEndPosition​(Buffer buffer, int off, int end, boolean parseAsVersion1)  
      static boolean isSeparator​(int c)
      Returns true if the byte is a separator character as defined in RFC2619.
      static boolean isSeparator​(int c, boolean parseAsVersion1)  
      static boolean isToken​(java.lang.String value)  
      static boolean isToken​(java.lang.String value, java.lang.String literals)  
      static boolean isToken2​(java.lang.String value)  
      static boolean isToken2​(java.lang.String value, java.lang.String literals)  
      static boolean isWhiteSpace​(int c)
      Returns true if the byte is a whitespace character as defined in RFC2619.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COOKIE_VERSION_ONE_STRICT_COMPLIANCE

        public static final boolean COOKIE_VERSION_ONE_STRICT_COMPLIANCE
        If set to true, then it will double quote the value and update cookie version when there is special characters. Tomcat uses STRICT_SERVLET_COMPLIANCE, whereas this code uses COOKIE_VERSION_ONE_STRICT_COMPLIANCE, which unlike the Tomcat variant not only affects cookie generation, but also cookie parsing. By default, cookies are parsed as v0 cookies, in order to maintain backward compatibility with GlassFish v2.x
      • RFC_6265_SUPPORT_ENABLED

        public static final boolean RFC_6265_SUPPORT_ENABLED
      • USE_LEGACY_PARSER

        public static final boolean USE_LEGACY_PARSER
      • ALWAYS_ADD_EXPIRES

        public static final boolean ALWAYS_ADD_EXPIRES
        If set to false, we don't use the IE6/7 Max-Age/Expires work around
      • OLD_COOKIE_FORMAT

        public static final java.lang.ThreadLocal<java.text.SimpleDateFormat> OLD_COOKIE_FORMAT
    • Constructor Detail

      • CookieUtils

        public CookieUtils()
    • Method Detail

      • isToken

        public static boolean isToken​(java.lang.String value)
      • isToken

        public static boolean isToken​(java.lang.String value,
                                      java.lang.String literals)
      • containsCTL

        public static boolean containsCTL​(java.lang.String value,
                                          int version)
      • isToken2

        public static boolean isToken2​(java.lang.String value)
      • isToken2

        public static boolean isToken2​(java.lang.String value,
                                       java.lang.String literals)
      • equals

        public static boolean equals​(java.lang.String s,
                                     byte[] b,
                                     int start,
                                     int end)
      • equals

        public static boolean equals​(java.lang.String s,
                                     Buffer b,
                                     int start,
                                     int end)
      • equals

        public static boolean equals​(java.lang.String s1,
                                     java.lang.String s2,
                                     int start,
                                     int end)
      • equalsIgnoreCase

        public static boolean equalsIgnoreCase​(java.lang.String s,
                                               Buffer b,
                                               int start,
                                               int end)
      • equalsIgnoreCase

        public static boolean equalsIgnoreCase​(java.lang.String s,
                                               byte[] b,
                                               int start,
                                               int end)
      • equalsIgnoreCase

        public static boolean equalsIgnoreCase​(java.lang.String s1,
                                               java.lang.String s2,
                                               int start,
                                               int end)
      • isSeparator

        public static boolean isSeparator​(int c)
        Returns true if the byte is a separator character as defined in RFC2619. Since this is called often, this function should be organized with the most probable outcomes first.
      • isSeparator

        public static boolean isSeparator​(int c,
                                          boolean parseAsVersion1)
      • isWhiteSpace

        public static boolean isWhiteSpace​(int c)
        Returns true if the byte is a whitespace character as defined in RFC2619.
      • getTokenEndPosition

        public static int getTokenEndPosition​(Buffer buffer,
                                              int off,
                                              int end)
        Given the starting position of a token, this gets the end of the token, with no separator characters in between. JVK
      • getTokenEndPosition

        public static int getTokenEndPosition​(Buffer buffer,
                                              int off,
                                              int end,
                                              boolean parseAsVersion1)
      • getTokenEndPosition

        public static int getTokenEndPosition​(byte[] bytes,
                                              int off,
                                              int end)
        Given the starting position of a token, this gets the end of the token, with no separator characters in between. JVK
      • getTokenEndPosition

        public static int getTokenEndPosition​(byte[] bytes,
                                              int off,
                                              int end,
                                              boolean parseAsVersion1)
      • getTokenEndPosition

        public static int getTokenEndPosition​(java.lang.String s,
                                              int off,
                                              int end)
        Given the starting position of a token, this gets the end of the token, with no separator characters in between. JVK
      • getTokenEndPosition

        public static int getTokenEndPosition​(java.lang.String s,
                                              int off,
                                              int end,
                                              boolean parseAsVersion1)
      • getQuotedValueEndPosition

        public static int getQuotedValueEndPosition​(Buffer buffer,
                                                    int off,
                                                    int end)
        Given a starting position after an initial quote character, this gets the position of the end quote. This escapes anything after a '\' char JVK RFC 2616
      • getQuotedValueEndPosition

        public static int getQuotedValueEndPosition​(byte[] bytes,
                                                    int off,
                                                    int end)
        Given a starting position after an initial quote character, this gets the position of the end quote. This escapes anything after a '\' char JVK RFC 2616
      • getQuotedValueEndPosition

        public static int getQuotedValueEndPosition​(java.lang.String s,
                                                    int off,
                                                    int end)
        Given a starting position after an initial quote character, this gets the position of the end quote. This escapes anything after a '\' char JVK RFC 2616