oauth.signpost
クラス AbstractOAuthConsumer

java.lang.Object
  上位を拡張 oauth.signpost.AbstractOAuthConsumer
すべての実装されたインタフェース:
Serializable, OAuthConsumer
直系の既知のサブクラス:
DefaultOAuthConsumer

public abstract class AbstractOAuthConsumer
extends Object
implements OAuthConsumer

ABC for consumer implementations. If you're developing a custom consumer you will probably inherit from this class to save you a lot of work.

作成者:
Matthias Kaeppler
関連項目:
直列化された形式

コンストラクタの概要
AbstractOAuthConsumer(String consumerKey, String consumerSecret)
           
 
メソッドの概要
protected  void collectBodyParameters(HttpRequest request, HttpParameters out)
          Collects x-www-form-urlencoded body parameters as per OAuth Core 1.0 spec section 9.1.1
protected  void collectHeaderParameters(HttpRequest request, HttpParameters out)
          Collects OAuth Authorization header parameters as per OAuth Core 1.0 spec section 9.1.1
protected  void collectQueryParameters(HttpRequest request, HttpParameters out)
          Collects HTTP GET query string parameters as per OAuth Core 1.0 spec section 9.1.1
protected  void completeOAuthParameters(HttpParameters out)
           Helper method that adds any OAuth parameters to the given request parameters which are missing from the current request but required for signing.
protected  String generateNonce()
           
protected  String generateTimestamp()
           
 String getConsumerKey()
           
 String getConsumerSecret()
           
 HttpParameters getRequestParameters()
          Returns all parameters collected from the HTTP request during message signing (this means the return value may be NULL before a call to OAuthConsumer.sign(oauth.signpost.http.HttpRequest)), plus all required OAuth parameters that were added because the request didn't contain them beforehand.
 String getToken()
           
 String getTokenSecret()
           
 void setAdditionalParameters(HttpParameters additionalParameters)
          Allows you to add parameters (typically OAuth parameters such as oauth_callback or oauth_verifier) which will go directly into the signer, i.e. you don't have to put them into the request first.
 void setMessageSigner(OAuthMessageSigner messageSigner)
          Sets the message signer that should be used to generate the OAuth signature.
 void setSendEmptyTokens(boolean enable)
           Causes the consumer to always include the oauth_token parameter to be sent, even if blank.
 void setSigningStrategy(SigningStrategy signingStrategy)
          Defines which strategy should be used to write a signature to an HTTP request.
 void setTokenWithSecret(String token, String tokenSecret)
          Sets the OAuth token and token secret used for message signing.
 HttpRequest sign(HttpRequest request)
          Signs the given HTTP request by writing an OAuth signature (and other required OAuth parameters) to it.
 HttpRequest sign(Object request)
           Signs the given HTTP request by writing an OAuth signature (and other required OAuth parameters) to it.
 String sign(String url)
           "Signs" the given URL by appending all OAuth parameters to it which are required for message signing.
protected abstract  HttpRequest wrap(Object request)
          Adapts the given request object to a Signpost HttpRequest.
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

AbstractOAuthConsumer

public AbstractOAuthConsumer(String consumerKey,
                             String consumerSecret)
メソッドの詳細

setMessageSigner

public void setMessageSigner(OAuthMessageSigner messageSigner)
インタフェース OAuthConsumer の記述:
Sets the message signer that should be used to generate the OAuth signature.

定義:
インタフェース OAuthConsumer 内の setMessageSigner
パラメータ:
messageSigner - the signer
関連項目:
HmacSha1MessageSigner, PlainTextMessageSigner

setSigningStrategy

public void setSigningStrategy(SigningStrategy signingStrategy)
インタフェース OAuthConsumer の記述:
Defines which strategy should be used to write a signature to an HTTP request.

定義:
インタフェース OAuthConsumer 内の setSigningStrategy
パラメータ:
signingStrategy - the strategy
関連項目:
AuthorizationHeaderSigningStrategy, QueryStringSigningStrategy

setAdditionalParameters

public void setAdditionalParameters(HttpParameters additionalParameters)
インタフェース OAuthConsumer の記述:
Allows you to add parameters (typically OAuth parameters such as oauth_callback or oauth_verifier) which will go directly into the signer, i.e. you don't have to put them into the request first. The consumer's SigningStrategy will then take care of writing them to the correct part of the request before it is sent. This is useful if you want to pre-set custom OAuth parameters. Note that these parameters are expected to already be percent encoded -- they will be simply merged as-is. BE CAREFUL WITH THIS METHOD! Your service provider may decide to ignore any non-standard OAuth params when computing the signature.

定義:
インタフェース OAuthConsumer 内の setAdditionalParameters
パラメータ:
additionalParameters - the parameters

sign

public HttpRequest sign(HttpRequest request)
                 throws OAuthMessageSignerException,
                        OAuthExpectationFailedException,
                        OAuthCommunicationException
インタフェース OAuthConsumer の記述:
Signs the given HTTP request by writing an OAuth signature (and other required OAuth parameters) to it. Where these parameters are written depends on the current SigningStrategy.

定義:
インタフェース OAuthConsumer 内の sign
パラメータ:
request - the request to sign
戻り値:
the request object passed as an argument
例外:
OAuthMessageSignerException
OAuthExpectationFailedException
OAuthCommunicationException

sign

public HttpRequest sign(Object request)
                 throws OAuthMessageSignerException,
                        OAuthExpectationFailedException,
                        OAuthCommunicationException
インタフェース OAuthConsumer の記述:

Signs the given HTTP request by writing an OAuth signature (and other required OAuth parameters) to it. Where these parameters are written depends on the current SigningStrategy.

This method accepts HTTP library specific request objects; the consumer implementation must ensure that only those request types are passed which it supports.

定義:
インタフェース OAuthConsumer 内の sign
パラメータ:
request - the request to sign
戻り値:
the request object passed as an argument
例外:
OAuthMessageSignerException
OAuthExpectationFailedException
OAuthCommunicationException

sign

public String sign(String url)
            throws OAuthMessageSignerException,
                   OAuthExpectationFailedException,
                   OAuthCommunicationException
インタフェース OAuthConsumer の記述:

"Signs" the given URL by appending all OAuth parameters to it which are required for message signing. The assumed HTTP method is GET. Essentially, this is equivalent to signing an HTTP GET request, but it can be useful if your application requires clickable links to protected resources, i.e. when your application does not have access to the actual request that is being sent.

定義:
インタフェース OAuthConsumer 内の sign
パラメータ:
url - the input URL. May have query parameters.
戻り値:
the input URL, with all necessary OAuth parameters attached as a query string. Existing query parameters are preserved.
例外:
OAuthMessageSignerException
OAuthExpectationFailedException
OAuthCommunicationException

wrap

protected abstract HttpRequest wrap(Object request)
Adapts the given request object to a Signpost HttpRequest. How this is done depends on the consumer implementation.

パラメータ:
request - the native HTTP request instance
戻り値:
the adapted request

setTokenWithSecret

public void setTokenWithSecret(String token,
                               String tokenSecret)
インタフェース OAuthConsumer の記述:
Sets the OAuth token and token secret used for message signing.

定義:
インタフェース OAuthConsumer 内の setTokenWithSecret
パラメータ:
token - the token
tokenSecret - the token secret

getToken

public String getToken()
定義:
インタフェース OAuthConsumer 内の getToken

getTokenSecret

public String getTokenSecret()
定義:
インタフェース OAuthConsumer 内の getTokenSecret

getConsumerKey

public String getConsumerKey()
定義:
インタフェース OAuthConsumer 内の getConsumerKey

getConsumerSecret

public String getConsumerSecret()
定義:
インタフェース OAuthConsumer 内の getConsumerSecret

completeOAuthParameters

protected void completeOAuthParameters(HttpParameters out)

Helper method that adds any OAuth parameters to the given request parameters which are missing from the current request but required for signing. A good example is the oauth_nonce parameter, which is typically not provided by the client in advance.

It's probably not a very good idea to override this method. If you want to generate different nonces or timestamps, override generateNonce() or generateTimestamp() instead.

パラメータ:
out - the request parameter which should be completed

getRequestParameters

public HttpParameters getRequestParameters()
インタフェース OAuthConsumer の記述:
Returns all parameters collected from the HTTP request during message signing (this means the return value may be NULL before a call to OAuthConsumer.sign(oauth.signpost.http.HttpRequest)), plus all required OAuth parameters that were added because the request didn't contain them beforehand. In other words, this is the exact set of parameters that were used for creating the message signature.

定義:
インタフェース OAuthConsumer 内の getRequestParameters
戻り値:
the request parameters used for message signing

setSendEmptyTokens

public void setSendEmptyTokens(boolean enable)
インタフェース OAuthConsumer の記述:

Causes the consumer to always include the oauth_token parameter to be sent, even if blank. If you're seeing 401s during calls to OAuthProvider.retrieveRequestToken(oauth.signpost.OAuthConsumer, java.lang.String, java.lang.String...), try setting this to true.

定義:
インタフェース OAuthConsumer 内の setSendEmptyTokens
パラメータ:
enable - true or false

collectHeaderParameters

protected void collectHeaderParameters(HttpRequest request,
                                       HttpParameters out)
Collects OAuth Authorization header parameters as per OAuth Core 1.0 spec section 9.1.1


collectBodyParameters

protected void collectBodyParameters(HttpRequest request,
                                     HttpParameters out)
                              throws IOException
Collects x-www-form-urlencoded body parameters as per OAuth Core 1.0 spec section 9.1.1

例外:
IOException

collectQueryParameters

protected void collectQueryParameters(HttpRequest request,
                                      HttpParameters out)
Collects HTTP GET query string parameters as per OAuth Core 1.0 spec section 9.1.1


generateTimestamp

protected String generateTimestamp()

generateNonce

protected String generateNonce()


Copyright © 2012. All Rights Reserved.