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
IOException
public void addParameters(Collection<? extends Map.Entry<String,String>> parameters)
public void addRequiredParameters(OAuthAccessor accessor) throws OAuthException, IOException, URISyntaxException
protected void completeParameters() throws IOException
IOException
protected void dump(Map<String,Object> into) throws IOException
IOException
public String getAuthorizationHeader(String realm) throws IOException
IOException
public InputStream getBodyAsStream() throws IOException
IOException
public String getBodyEncoding()
public String getBodyType()
public String getConsumerKey() throws IOException
IOException
public Map<String,Object> getDump() throws IOException
IOException
public final String getHeader(String name)
public final List<Map.Entry<String,String>> getHeaders()
public String getParameter(String name) throws IOException
IOException
protected Map<String,String> getParameterMap() throws IOException
IOException
public List<Map.Entry<String,String>> getParameters() throws IOException
IOException
public String getSignature() throws IOException
IOException
public String getSignatureMethod() throws IOException
IOException
public String getToken() throws IOException
IOException
public final String readBodyAsString() throws IOException
IOException
public void requireParameters(String... names) throws OAuthProblemException, IOException
OAuthProblemException
- one or more parameters are absent.IOException
public void sign(OAuthAccessor accessor) throws IOException, OAuthException, URISyntaxException
Copyright © 2008–2017 Province of British Columbia. All rights reserved.