public class OAuthMessage extends Object
The parameters in this class are not percent-encoded. Methods like OAuthClient.invoke and OAuthResponseMessage.completeParameters are responsible for percent-encoding parameters before transmission and decoding them after reception.
| Modifier and Type | Field and Description |
|---|---|
static String |
AUTH_SCHEME |
static String |
DELETE |
static String |
GET |
String |
method |
static String |
POST |
static String |
PUT |
String |
URL |
| Constructor and Description |
|---|
OAuthMessage(String method,
String URL,
Collection<? extends Map.Entry<String,String>> parameters) |
OAuthMessage(String method,
String URL,
Collection<? extends Map.Entry<String,String>> parameters,
InputStream bodyAsStream) |
| Modifier and Type | Method and Description |
|---|---|
void |
addParameter(Map.Entry<String,String> parameter) |
void |
addParameter(String key,
String value) |
void |
addParameters(Collection<? extends Map.Entry<String,String>> parameters) |
void |
addRequiredParameters(OAuthAccessor accessor)
Add some of the parameters needed to request access to a protected
resource, if they aren't already in the message.
|
protected void |
completeParameters()
Finish adding parameters; for example read an HTTP response body and parse
parameters from it.
|
static List<OAuth.Parameter> |
decodeAuthorization(String authorization)
Parse the parameters from an OAuth Authorization or WWW-Authenticate
header.
|
protected void |
dump(Map<String,Object> into) |
String |
getAuthorizationHeader(String realm)
Construct a WWW-Authenticate or Authentication header value, containing the
given realm plus all the parameters whose names begin with "oauth_".
|
InputStream |
getBodyAsStream()
Get a stream from which to read the body of the HTTP request or response.
|
String |
getBodyEncoding()
The character encoding of the body of this message.
|
String |
getBodyType()
The MIME type of the body of this message.
|
String |
getConsumerKey() |
Map<String,Object> |
getDump()
Construct a verbose description of this message and its origins.
|
String |
getHeader(String name)
The value of the last HTTP header with the given name.
|
List<Map.Entry<String,String>> |
getHeaders()
All HTTP headers.
|
String |
getParameter(String name) |
protected Map<String,String> |
getParameterMap() |
List<Map.Entry<String,String>> |
getParameters() |
String |
getSignature() |
String |
getSignatureMethod() |
String |
getToken() |
static String |
readAll(InputStream from,
String encoding)
Read all the data from the given stream, and close it.
|
String |
readBodyAsString()
Read the body of the HTTP request or response and convert it to a String.
|
void |
requireParameters(String... names)
Verify that the required parameter names are contained in the actual
collection.
|
void |
sign(OAuthAccessor accessor)
Add a signature to the message.
|
String |
toString() |
public static final String AUTH_SCHEME
public static final String DELETE
public static final String GET
public static final String POST
public static final String PUT
public String method
public String URL
public OAuthMessage(String method, String URL, Collection<? extends Map.Entry<String,String>> parameters)
public OAuthMessage(String method, String URL, Collection<? extends Map.Entry<String,String>> parameters, InputStream bodyAsStream)
public static List<OAuth.Parameter> decodeAuthorization(String authorization)
public static String readAll(InputStream from, String encoding) throws IOException
IOExceptionpublic void addParameters(Collection<? extends Map.Entry<String,String>> parameters)
public void addRequiredParameters(OAuthAccessor accessor) throws OAuthException, IOException, URISyntaxException
protected void completeParameters()
throws IOException
IOExceptionprotected void dump(Map<String,Object> into) throws IOException
IOExceptionpublic String getAuthorizationHeader(String realm) throws IOException
IOExceptionpublic InputStream getBodyAsStream() throws IOException
IOExceptionpublic String getBodyEncoding()
public String getBodyType()
public String getConsumerKey() throws IOException
IOExceptionpublic Map<String,Object> getDump() throws IOException
IOExceptionpublic final String getHeader(String name)
public final List<Map.Entry<String,String>> getHeaders()
public String getParameter(String name) throws IOException
IOExceptionprotected Map<String,String> getParameterMap() throws IOException
IOExceptionpublic List<Map.Entry<String,String>> getParameters() throws IOException
IOExceptionpublic String getSignature() throws IOException
IOExceptionpublic String getSignatureMethod() throws IOException
IOExceptionpublic String getToken() throws IOException
IOExceptionpublic final String readBodyAsString() throws IOException
IOExceptionpublic void requireParameters(String... names) throws OAuthProblemException, IOException
OAuthProblemException - one or more parameters are absent.IOExceptionpublic void sign(OAuthAccessor accessor) throws IOException, OAuthException, URISyntaxException
Copyright © 2008–2017 Province of British Columbia. All rights reserved.