Class Cookies


  • public class Cookies
    extends java.lang.Object
    Class that contains utility methods for dealing with cookies.
    Author:
    Stuart Douglas, Andre Dietisheim, Richard Opalka
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DOMAIN  
      static java.lang.String PATH  
      static java.lang.String VERSION  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void assembleCrumbs​(HeaderMap headerMap)
      Cookie headers form: https://www.rfc-editor.org/rfc/rfc6265#section-4.2.1 If more than one header entry exist for "Cookie", it will be assembled into one that conforms to rfc.
      static void disperseCrumbs​(HeaderMap headerMap)
      IF there is single entry that follows RFC separation rules, it will be turned into singular fields.
      static java.util.List<java.lang.String> getCrumbs​(HeaderMap headerMap)
      Fetch list containing crumbs( singular entries of Cookie header )
      static boolean isCrumbsAssemplyDisabled()  
      static java.util.Map<java.lang.String,​Cookie> parseRequestCookies​(int maxCookies, boolean allowEqualInValue, java.util.List<java.lang.String> cookies)
      Deprecated, for removal: This API element is subject to removal in a future version.
      static void parseRequestCookies​(int maxCookies, boolean allowEqualInValue, java.util.List<java.lang.String> cookies, java.util.Set<Cookie> parsedCookies)  
      static Cookie parseSetCookieHeader​(java.lang.String headerValue)
      Parses a "Set-Cookie:" response header value into its cookie representation.
      • Methods inherited from class java.lang.Object

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

      • parseSetCookieHeader

        public static Cookie parseSetCookieHeader​(java.lang.String headerValue)
        Parses a "Set-Cookie:" response header value into its cookie representation. The header value is parsed according to the syntax that's defined in RFC2109:
         
          set-cookie      =       "Set-Cookie:" cookies
           cookies         =       1#cookie
           cookie          =       NAME "=" VALUE *(";" cookie-av)
           NAME            =       attr
           VALUE           =       value
           cookie-av       =       "Comment" "=" value
                           |       "Domain" "=" value
                           |       "Max-Age" "=" value
                           |       "Path" "=" value
                           |       "Secure"
                           |       "Version" "=" 1*DIGIT
        
         
         
        Parameters:
        headerValue - The header value
        Returns:
        The cookie
        See Also:
        Cookie, rfc2109
      • parseRequestCookies

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        public static java.util.Map<java.lang.String,​Cookie> parseRequestCookies​(int maxCookies,
                                                                                       boolean allowEqualInValue,
                                                                                       java.util.List<java.lang.String> cookies)
        Deprecated, for removal: This API element is subject to removal in a future version.
        /** Parses the cookies from a list of "Cookie:" header values. The cookie header values are parsed according to RFC2109 that defines the following syntax:
         
         cookie          =  "Cookie:" cookie-version
                            1*((";" | ",") cookie-value)
         cookie-value    =  NAME "=" VALUE [";" path] [";" domain]
         cookie-version  =  "$Version" "=" value
         NAME            =  attr
         VALUE           =  value
         path            =  "$Path" "=" value
         domain          =  "$Domain" "=" value
         
         
        Parameters:
        maxCookies - The maximum number of cookies. Used to prevent hash collision attacks
        allowEqualInValue - if true equal characters are allowed in cookie values
        cookies - The cookie values to parse
        Returns:
        A pared cookie map
        See Also:
        Cookie, rfc2109
      • parseRequestCookies

        public static void parseRequestCookies​(int maxCookies,
                                               boolean allowEqualInValue,
                                               java.util.List<java.lang.String> cookies,
                                               java.util.Set<Cookie> parsedCookies)
      • assembleCrumbs

        public static void assembleCrumbs​(HeaderMap headerMap)
        Cookie headers form: https://www.rfc-editor.org/rfc/rfc6265#section-4.2.1 If more than one header entry exist for "Cookie", it will be assembled into one that conforms to rfc.
        Parameters:
        headerMap -
      • disperseCrumbs

        public static void disperseCrumbs​(HeaderMap headerMap)
        IF there is single entry that follows RFC separation rules, it will be turned into singular fields. This should be only used PRIOR to compression.
        Parameters:
        headerMap -
      • getCrumbs

        public static java.util.List<java.lang.String> getCrumbs​(HeaderMap headerMap)
        Fetch list containing crumbs( singular entries of Cookie header )
        Parameters:
        headerMap -
        Returns:
      • isCrumbsAssemplyDisabled

        public static boolean isCrumbsAssemplyDisabled()