net.adamcin.httpsig.api
Class RequestContent

java.lang.Object
  extended by net.adamcin.httpsig.api.RequestContent
All Implemented Interfaces:
Serializable

public final class RequestContent
extends Object
implements Serializable

Object used to pass per-request context, such as Request Line and HTTP Headers in client/server implementation-independent way.

See Also:
Serialized Form

Nested Class Summary
static class RequestContent.Builder
           
 
Field Summary
static String DATE_FORMAT
          Deprecated. 
static String DATE_FORMAT_RFC1123
           
 
Method Summary
 byte[] getContent(List<String> headers, Charset charset)
          Returns the signature content as a byte array
 String getContentString(List<String> headers)
          Returns the signature content as a String
 String getDate()
           
 Date getDateGMT()
          Returns the currently set date header value converted to a Date object in the GMT time zone
 Calendar getDateTZ(TimeZone timeZone)
          Returns the currently set date header value converted to a Calendar in the specified timeZone, or in the default timeZone if the parameter is null
 List<String> getHeaderNames()
           
 List<String> getHeaderValues(String name)
           
 String getRequestLine()
          Deprecated. 
 String getRequestTarget()
           
 String toString()
           
protected static Date tryParseDate(String date)
          Sets the literal date header value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATE_FORMAT

@Deprecated
public static final String DATE_FORMAT
Deprecated. 
The official format of the Date header value (and other date-type headers) is defined by RFC 1123 (DATE_FORMAT_RFC1123)

See Also:
Constant Field Values

DATE_FORMAT_RFC1123

public static final String DATE_FORMAT_RFC1123
See Also:
Constant Field Values
Method Detail

getContent

public byte[] getContent(List<String> headers,
                         Charset charset)
Returns the signature content as a byte array

Parameters:
headers - the list of headers to be included in the signed content
Returns:
the result of getContentString(java.util.List) encoded using the provided Charset

getContentString

public String getContentString(List<String> headers)
Returns the signature content as a String

Parameters:
headers - the list of headers to be included in the signed content
Returns:

toString

public String toString()
Overrides:
toString in class Object

getHeaderNames

public List<String> getHeaderNames()
Returns:
the list of header names contained in this RequestContent, in the order in which they were added, except for request-target, which is listed first if present

getRequestLine

@Deprecated
public String getRequestLine()
Deprecated. 

Returns:
the request-line if set

getRequestTarget

public String getRequestTarget()
Returns:
the request-target if set

getDate

public String getDate()
Returns:
the first date header value if set, null if not

getHeaderValues

public List<String> getHeaderValues(String name)
Parameters:
name - the name of the header
Returns:
the list of values for the given header name, or an empty list if no values have been added.

tryParseDate

protected static Date tryParseDate(String date)
Sets the literal date header value.

Parameters:
date - a date string conforming to DATE_FORMAT_RFC1123 or to the deprecated DATE_FORMAT
Returns:
true if the date header was set successfully. false if the header is already set or the provided string does not conform to DATE_FORMAT_RFC1123 or to DATE_FORMAT

getDateGMT

public Date getDateGMT()
Returns the currently set date header value converted to a Date object in the GMT time zone

Returns:
a Date object in GMT or null if header is not set or not valid

getDateTZ

public Calendar getDateTZ(TimeZone timeZone)
Returns the currently set date header value converted to a Calendar in the specified timeZone, or in the default timeZone if the parameter is null

Parameters:
timeZone - some time zone or null to convert to the default time zone
Returns:
a Calendar in the specified time zone or in the default time zone if the timeZone parameter is null


Copyright © 2013-2014. All Rights Reserved.