Dirty stub.
[wl-mobile.git] / src / pl / org / nowoczesnapolska / AuthHelper.java
1 package pl.org.nowoczesnapolska;
2
3 import java.io.UnsupportedEncodingException;
4
5 import oauth.signpost.OAuth;
6 import oauth.signpost.OAuthConsumer;
7 import oauth.signpost.OAuthProvider;
8 import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
9 import oauth.signpost.commonshttp.CommonsHttpOAuthProvider;
10 import oauth.signpost.exception.OAuthCommunicationException;
11 import oauth.signpost.exception.OAuthExpectationFailedException;
12 import oauth.signpost.exception.OAuthMessageSignerException;
13 import oauth.signpost.exception.OAuthNotAuthorizedException;
14 import android.util.Log;
15
16 public class AuthHelper {
17
18         
19         /* OAuth */
20         private static OAuthConsumer mConsumer;
21         private static OAuthProvider mProvider;
22         private static String mCallbackUrl;
23         private static String apiURL = "http://epsilon.nowoczesnapolska.org.pl/api/";
24
25         public static void OAuthHelper(String consumerKey, String consumerSecret, String callbackUrl)
26         throws UnsupportedEncodingException {
27                 mConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
28                 mProvider = new CommonsHttpOAuthProvider(
29                                 apiURL+"oauth/request_token/",
30                                 apiURL+"oauth/access_token/",
31                                 apiURL+"oauth/authorize/");
32                 mProvider.setOAuth10a(true);
33                 mCallbackUrl = "wl://";
34         }    
35
36
37         public static String getRequestToken()
38         throws OAuthMessageSignerException, OAuthNotAuthorizedException,
39         OAuthExpectationFailedException, OAuthCommunicationException {
40                 String authUrl = mProvider.retrieveRequestToken(mConsumer, mCallbackUrl);
41                 return authUrl;
42         }
43
44         public static String[] getAccessToken(String verifier)
45         throws OAuthMessageSignerException, OAuthNotAuthorizedException,
46         OAuthExpectationFailedException, OAuthCommunicationException {
47                 Log.d("resume", "beforetoken");
48                 mProvider.retrieveAccessToken(mConsumer, verifier);
49                 return new String[] {
50                                 mConsumer.getToken(), mConsumer.getTokenSecret()
51                 };
52         }
53         
54         
55 }