|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.oauth.OAuthMessage
public class OAuthMessage
A request or response message used in the OAuth protocol.
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.
Field Summary | |
---|---|
static java.lang.String |
AUTH_SCHEME
|
static java.lang.String |
DELETE
|
static java.lang.String |
GET
|
java.lang.String |
method
|
static java.lang.String |
POST
|
static java.lang.String |
PUT
|
java.lang.String |
URL
|
Constructor Summary | |
---|---|
OAuthMessage(java.lang.String method,
java.lang.String URL,
java.util.Collection<? extends java.util.Map.Entry> parameters)
|
|
OAuthMessage(java.lang.String method,
java.lang.String URL,
java.util.Collection<? extends java.util.Map.Entry> parameters,
java.io.InputStream bodyAsStream)
|
Method Summary | |
---|---|
void |
addParameter(java.util.Map.Entry<java.lang.String,java.lang.String> parameter)
|
void |
addParameter(java.lang.String key,
java.lang.String value)
|
void |
addParameters(java.util.Collection<? extends java.util.Map.Entry<java.lang.String,java.lang.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 java.util.List<OAuth.Parameter> |
decodeAuthorization(java.lang.String authorization)
Parse the parameters from an OAuth Authorization or WWW-Authenticate header. |
protected void |
dump(java.util.Map<java.lang.String,java.lang.Object> into)
|
java.lang.String |
getAuthorizationHeader(java.lang.String realm)
Construct a WWW-Authenticate or Authentication header value, containing the given realm plus all the parameters whose names begin with "oauth_". |
java.io.InputStream |
getBodyAsStream()
Get a stream from which to read the body of the HTTP request or response. |
java.lang.String |
getBodyEncoding()
The character encoding of the body of this message. |
java.lang.String |
getBodyType()
The MIME type of the body of this message. |
java.lang.String |
getConsumerKey()
|
java.util.Map<java.lang.String,java.lang.Object> |
getDump()
Construct a verbose description of this message and its origins. |
java.lang.String |
getHeader(java.lang.String name)
The value of the last HTTP header with the given name. |
java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getHeaders()
All HTTP headers. |
java.lang.String |
getParameter(java.lang.String name)
|
protected java.util.Map<java.lang.String,java.lang.String> |
getParameterMap()
|
java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getParameters()
|
java.lang.String |
getSignature()
|
java.lang.String |
getSignatureMethod()
|
java.lang.String |
getToken()
|
static java.lang.String |
readAll(java.io.InputStream from,
java.lang.String encoding)
Read all the data from the given stream, and close it. |
java.lang.String |
readBodyAsString()
Read the body of the HTTP request or response and convert it to a String. |
void |
requireParameters(java.lang.String... names)
Verify that the required parameter names are contained in the actual collection. |
void |
sign(OAuthAccessor accessor)
Add a signature to the message. |
HttpMessage |
toHttpRequest(OAuthClient.ParameterStyle style)
Deprecated. use HttpMessage.newRequest |
java.lang.String |
toString()
|
void |
validateMessage(OAuthAccessor accessor,
OAuthValidator validator)
Deprecated. use validator.validateMessage(this, accessor) instead. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.lang.String method
public java.lang.String URL
public static final java.lang.String AUTH_SCHEME
public static final java.lang.String GET
public static final java.lang.String POST
public static final java.lang.String PUT
public static final java.lang.String DELETE
Constructor Detail |
---|
public OAuthMessage(java.lang.String method, java.lang.String URL, java.util.Collection<? extends java.util.Map.Entry> parameters)
public OAuthMessage(java.lang.String method, java.lang.String URL, java.util.Collection<? extends java.util.Map.Entry> parameters, java.io.InputStream bodyAsStream)
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
protected void completeParameters() throws java.io.IOException
java.io.IOException
public java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> getParameters() throws java.io.IOException
java.io.IOException
public void addParameter(java.lang.String key, java.lang.String value)
public void addParameter(java.util.Map.Entry<java.lang.String,java.lang.String> parameter)
public void addParameters(java.util.Collection<? extends java.util.Map.Entry<java.lang.String,java.lang.String>> parameters)
public java.lang.String getParameter(java.lang.String name) throws java.io.IOException
java.io.IOException
public java.lang.String getConsumerKey() throws java.io.IOException
java.io.IOException
public java.lang.String getToken() throws java.io.IOException
java.io.IOException
public java.lang.String getSignatureMethod() throws java.io.IOException
java.io.IOException
public java.lang.String getSignature() throws java.io.IOException
java.io.IOException
protected java.util.Map<java.lang.String,java.lang.String> getParameterMap() throws java.io.IOException
java.io.IOException
public java.lang.String getBodyType()
public java.lang.String getBodyEncoding()
public final java.lang.String getHeader(java.lang.String name)
public final java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> getHeaders()
public final java.lang.String readBodyAsString() throws java.io.IOException
java.io.IOException
public java.io.InputStream getBodyAsStream() throws java.io.IOException
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getDump() throws java.io.IOException
java.io.IOException
protected void dump(java.util.Map<java.lang.String,java.lang.Object> into) throws java.io.IOException
java.io.IOException
public void requireParameters(java.lang.String... names) throws OAuthProblemException, java.io.IOException
OAuthProblemException
- one or more parameters are absent.
java.io.IOException
public void addRequiredParameters(OAuthAccessor accessor) throws OAuthException, java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
OAuthException
public void sign(OAuthAccessor accessor) throws java.io.IOException, OAuthException, java.net.URISyntaxException
java.net.URISyntaxException
java.io.IOException
OAuthException
public HttpMessage toHttpRequest(OAuthClient.ParameterStyle style) throws java.io.IOException
style
- where to put the OAuth parameters, within the HTTP request
java.io.IOException
public void validateMessage(OAuthAccessor accessor, OAuthValidator validator) throws OAuthException, java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
OAuthProblemException
- the message is invalid
OAuthException
public java.lang.String getAuthorizationHeader(java.lang.String realm) throws java.io.IOException
java.io.IOException
public static java.lang.String readAll(java.io.InputStream from, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.util.List<OAuth.Parameter> decodeAuthorization(java.lang.String authorization)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |