Top Description Constructors Methods
org.apache.http.impl.cookie

public Class RFC2965PortAttributeHandler

extends Object
implements CommonCookieAttributeHandler
Class Inheritance
All Implemented Interfaces
org.apache.http.cookie.CommonCookieAttributeHandler, org.apache.http.cookie.CookieAttributeHandler
Annotations
@Contract
threading:IMMUTABLE
Imports
java.util.StringTokenizer, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.cookie.ClientCookie, .CommonCookieAttributeHandler, .Cookie, .CookieOrigin, .CookieRestrictionViolationException, .MalformedCookieException, .SetCookie, .SetCookie2, org.apache.http.util.Args

"Port" cookie attribute handler for RFC 2965 cookie spec.
Since
4.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public boolean
match(final Cookie cookie, final CookieOrigin
the cookie source to match against
origin
)

Implements org.apache.http.cookie.CookieAttributeHandler.match.

Match cookie port attribute.
public void
parse(final SetCookie cookie, final String
cookie attribute value from the cookie response header
portValue
)

Implements org.apache.http.cookie.CookieAttributeHandler.parse.

Parse cookie port attribute.
private static int[]

Returns:

parsed array of ports
parsePortAttribute
(final String
port attribute value
portValue
)

Parses the given Port attribute value (e.g. "8000,8001,8002") into an array of ports.

private static boolean

Returns:

true returns true if the given port exists in the given ports list; false otherwise.
portMatch
(final int
port of host where cookie was received from or being sent to.
port
,
final int[]
port list
ports
)

Returns true if the given port exists in the given ports list.

public void
validate(final Cookie cookie, final CookieOrigin
the cookie source to validate against
origin
)

Implements org.apache.http.cookie.CookieAttributeHandler.validate.

Validate cookie port attribute.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RFC2965PortAttributeHandlerback to summary
public RFC2965PortAttributeHandler()

Method Detail

getAttributeNameback to summary
public String getAttributeName()

Implements org.apache.http.cookie.CommonCookieAttributeHandler.getAttributeName.

Annotations
@Override
matchback to summary
public boolean match(final Cookie cookie, final CookieOrigin origin)

Implements org.apache.http.cookie.CookieAttributeHandler.match.

Match cookie port attribute. If the Port attribute is not specified in header, the cookie can be sent to any port. Otherwise, the request port must be in the cookie's port list.

Parameters
cookie:Cookie

Doc from org.apache.http.cookie.CookieAttributeHandler.match.

org.apache.http.cookie.Cookie to match

origin:CookieOrigin

Doc from org.apache.http.cookie.CookieAttributeHandler.match.

the cookie source to match against

Returns:boolean

Doc from org.apache.http.cookie.CookieAttributeHandler.match.

true if the match is successful; false otherwise

Annotations
@Override
parseback to summary
public void parse(final SetCookie cookie, final String portValue) throws MalformedCookieException

Implements org.apache.http.cookie.CookieAttributeHandler.parse.

Parse cookie port attribute.

Parameters
cookie:SetCookie

Doc from org.apache.http.cookie.CookieAttributeHandler.parse.

org.apache.http.cookie.Cookie to be updated

portValue:String

Doc from org.apache.http.cookie.CookieAttributeHandler.parse.

cookie attribute value from the cookie response header

Annotations
@Override
parsePortAttributeback to summary
private static int[] parsePortAttribute(final String portValue) throws MalformedCookieException

Parses the given Port attribute value (e.g. "8000,8001,8002") into an array of ports.

Parameters
portValue:String

port attribute value

Returns:int[]

parsed array of ports

Exceptions
MalformedCookieException:
if there is a problem in parsing due to invalid portValue.
portMatchback to summary
private static boolean portMatch(final int port, final int[] ports)

Returns true if the given port exists in the given ports list.

Parameters
port:int

port of host where cookie was received from or being sent to.

ports:int[]

port list

Returns:boolean

true returns true if the given port exists in the given ports list; false otherwise.

validateback to summary
public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException

Implements org.apache.http.cookie.CookieAttributeHandler.validate.

Validate cookie port attribute. If the Port attribute was specified in header, the request port must be in cookie's port list.

Parameters
cookie:Cookie

Doc from org.apache.http.cookie.CookieAttributeHandler.validate.

org.apache.http.cookie.Cookie to validate

origin:CookieOrigin

Doc from org.apache.http.cookie.CookieAttributeHandler.validate.

the cookie source to validate against

Annotations
@Override
Exceptions
MalformedCookieException:

Doc from org.apache.http.cookie.CookieAttributeHandler.validate.

if cookie validation fails for this attribute