2 Copyright (c) 2007-2009, Yusuke Yamamoto
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Yusuke Yamamoto nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY
17 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 package weibo4android
.http
;
29 import weibo4android
.WeiboException
;
32 * @author Yusuke Yamamoto - yusuke at mac.com
33 * representing unauthorized Request Token which is passed to the service provider when acquiring the authorized Access Token
35 public class RequestToken
extends OAuthToken
{
36 private HttpClient httpClient
;
37 private static final long serialVersionUID
= -8214365845469757952L;
39 RequestToken(Response res
, HttpClient httpClient
) throws WeiboException
{
41 this.httpClient
= httpClient
;
44 RequestToken(String token
, String tokenSecret
) {
45 super(token
, tokenSecret
);
48 public String
getAuthorizationURL() {
49 return httpClient
.getAuthorizationURL() + "?oauth_token=" + getToken();
53 * since Weibo4J 2.0.10
55 public String
getAuthenticationURL() {
56 return httpClient
.getAuthenticationRL() + "?oauth_token=" + getToken();
59 public AccessToken
getAccessToken(String pin
) throws WeiboException
{
60 return httpClient
.getOAuthAccessToken(this, pin
);
63 public HttpClient
getHttpClient() {
67 public void setHttpClient(HttpClient httpClient
) {
68 this.httpClient
= httpClient
;
72 public boolean equals(Object o
) {
73 if (this == o
) return true;
74 if (o
== null || getClass() != o
.getClass()) return false;
75 if (!super.equals(o
)) return false;
77 RequestToken that
= (RequestToken
) o
;
79 if (httpClient
!= null ?
!httpClient
.equals(that
.httpClient
) : that
.httpClient
!= null)
86 public int hashCode() {
87 int result
= super.hashCode();
88 result
= 31 * result
+ (httpClient
!= null ? httpClient
.hashCode() : 0);