Android Open Source - allblue-all-in-one O Auth Util






From Project

Back to project page allblue-all-in-one.

License

The source code is released under:

MIT License

If you think the Android project allblue-all-in-one listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.allblue.util;
/*from  www. j av  a  2  s .c  o m*/
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.j256.ormlite.dao.Dao;
import oauth.signpost.OAuthConsumer;
import org.allblue.activity.GlobalActivity;
import org.allblue.metadata.Account;

public class OAuthUtil {
  public static OAuthConsumer getConsumer(final String accountName, final String accountType) {
    String key = XMLUtil.getKey(accountType);
    String value = XMLUtil.getValue(accountType);
    
    OAuthConsumer oauthConsumer = Account.getOAuthConsumer(key, value, accountType);
        Dao<Account, Integer> accountDao = GlobalActivity.getAccountDao();
        try {
            Map keyValue = new HashMap() {{
                put("name", accountName);
                put("type", accountType);
            }};
            List<Account> accounts = accountDao.queryForFieldValues(keyValue);
            if (accounts != null) {
                Account account = accounts.get(0); // it should be only one return value
                oauthConsumer.setTokenWithSecret(account.getToken(), account.getSecret());
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    return oauthConsumer;
  }
}




Java Source Code List

org.allblue.DashBoard.java
org.allblue.activity.GlobalActivity.java
org.allblue.activity.HomeActivity.java
org.allblue.activity.OAuthActivity.java
org.allblue.activity.SettingActivity.java
org.allblue.activity.SingleTabActivity.java
org.allblue.adapter.SettingAdapter.java
org.allblue.adapter.SingleTabCursorAdapter.java
org.allblue.database.DatabaseConfig.java
org.allblue.database.DatabaseHelper.java
org.allblue.metadata.AccountTypes.java
org.allblue.metadata.Account.java
org.allblue.metadata.SinaAccount.java
org.allblue.metadata.TweetItem.java
org.allblue.metadata.TwitterAccount.java
org.allblue.util.OAuthUtil.java
org.allblue.util.SharedOAuthToken.java
org.allblue.util.XMLUtil.java