Android Open Source - EBrowser Weave Account Info






From Project

Back to project page EBrowser.

License

The source code is released under:

GNU General Public License

If you think the Android project EBrowser 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.emergent.android.weave.client;
//  w w  w. j a v a  2 s. com
import org.json.JSONException;
import org.json.JSONObject;

import java.net.URI;
import java.net.URISyntaxException;

/**
* @author Patrick Woodworth
*/
public class WeaveAccountInfo {

  private final URI m_server;
  private final String m_username;
  private final String m_password;
  private final char[] m_secret;

  private WeaveAccountInfo(URI server, String username, String password, char[] secret) {
    if (server == null)
      throw new NullPointerException("server was null");
    if (username == null)
      throw new NullPointerException("username was null");
    if (password == null)
      throw new NullPointerException("password was null");
    if (secret == null)
      throw new NullPointerException("secret was null");
    m_server = server;
    m_username = username;
    m_password = password;
    m_secret = secret;
  }

  public URI getServer() {
    return m_server;
  }

  public String getServerAsString() {
    return WeaveUtil.toString(getServer());
  }

  public String getUsername() {
    return m_username;
  }

  public String getPassword() {
    return m_password;
  }

  public String getSecretAsString() {
    return m_secret == null ? null : new String(m_secret);
  }

  public char[] getSecret() {
    return m_secret;
  }

  public String toAuthToken() {
    try {
      JSONObject retval = new JSONObject();
      retval.put("server", getServerAsString());
      retval.put("username", getUsername());
      retval.put("password", getPassword());
      retval.put("secret", getSecretAsString());
      return retval.toString();
    } catch (JSONException e) {
      throw new IllegalStateException(e);
    }
  }

  @Override
  public String toString() {
    try {
      return toAuthToken();
    } catch (Exception ignored) { }
    return super.toString();
  }

  public static WeaveAccountInfo createWeaveAccountInfo(String authtoken) {
    try {
      JSONObject retval = new JSONObject(authtoken);
      URI server = URI.create(retval.getString("server"));
      String username = retval.getString("username");
      String password = retval.getString("password");
      char[] secret = retval.getString("secret").toCharArray();
      return createWeaveAccountInfo(server, username, password, secret);
    } catch (JSONException e) {
      throw new IllegalStateException(e);
    }
  }

  public static WeaveAccountInfo createWeaveAccountInfo(String serverUri, String username, String password, char[] encsecret) throws URISyntaxException {
    return createWeaveAccountInfo(new URI(serverUri), username, password, encsecret);
  }

  public static WeaveAccountInfo createWeaveAccountInfo(URI serverUri, String username, String password, char[] encsecret) {
    return new WeaveAccountInfo(serverUri, username, password, encsecret);
  }
}




Java Source Code List

org.emergent.android.weave.client.Base32.java
org.emergent.android.weave.client.Base64Encoder.java
org.emergent.android.weave.client.Base64.java
org.emergent.android.weave.client.BulkKeyCouplet.java
org.emergent.android.weave.client.Dbg.java
org.emergent.android.weave.client.HexEncoder.java
org.emergent.android.weave.client.Hex.java
org.emergent.android.weave.client.QueryParams.java
org.emergent.android.weave.client.QueryResult.java
org.emergent.android.weave.client.UserWeave.java
org.emergent.android.weave.client.WeaveAccountInfo.java
org.emergent.android.weave.client.WeaveBasicObject.java
org.emergent.android.weave.client.WeaveConstants.java
org.emergent.android.weave.client.WeaveCryptoUtil.java
org.emergent.android.weave.client.WeaveException.java
org.emergent.android.weave.client.WeaveFactory.java
org.emergent.android.weave.client.WeaveHeader.java
org.emergent.android.weave.client.WeaveResponse.java
org.emergent.android.weave.client.WeaveSSLSocketFactory.java
org.emergent.android.weave.client.WeaveTransport.java
org.emergent.android.weave.client.WeaveUtil.java
org.greendroid.QuickActionGrid.java
org.greendroid.QuickActionWidget.java
org.greendroid.QuickAction.java
org.zirco.controllers.Controller.java
org.zirco.events.EventConstants.java
org.zirco.events.EventController.java
org.zirco.events.IDownloadEventsListener.java
org.zirco.model.DbAdapter.java
org.zirco.model.UrlSuggestionItemComparator.java
org.zirco.model.adapters.BookmarksCursorAdapter.java
org.zirco.model.adapters.DownloadListAdapter.java
org.zirco.model.adapters.HistoryExpandableListAdapter.java
org.zirco.model.adapters.UrlSuggestionCursorAdapter.java
org.zirco.model.adapters.WeaveBookmarksCursorAdapter.java
org.zirco.model.items.BookmarkItem.java
org.zirco.model.items.DownloadItem.java
org.zirco.model.items.HistoryItem.java
org.zirco.model.items.UrlSuggestionItem.java
org.zirco.model.items.WeaveBookmarkItem.java
org.zirco.providers.BookmarksProviderWrapper.java
org.zirco.providers.WeaveColumns.java
org.zirco.providers.WeaveContentProvider.java
org.zirco.providers.ZircoBookmarksContentProvider.java
org.zirco.sync.ISyncListener.java
org.zirco.sync.WeaveSyncTask.java
org.zirco.ui.activities.AboutActivity.java
org.zirco.ui.activities.AdBlockerWhiteListActivity.java
org.zirco.ui.activities.BookmarksHistoryActivity.java
org.zirco.ui.activities.BookmarksListActivity.java
org.zirco.ui.activities.ChangelogActivity.java
org.zirco.ui.activities.DownloadsListActivity.java
org.zirco.ui.activities.EditBookmarkActivity.java
org.zirco.ui.activities.HistoryListActivity.java
org.zirco.ui.activities.IToolbarsContainer.java
org.zirco.ui.activities.MainActivity.java
org.zirco.ui.activities.MobileViewListActivity.java
org.zirco.ui.activities.WeaveBookmarksListActivity.java
org.zirco.ui.activities.preferences.BaseSpinnerCustomPreferenceActivity.java
org.zirco.ui.activities.preferences.HomepagePreferenceActivity.java
org.zirco.ui.activities.preferences.PreferencesActivity.java
org.zirco.ui.activities.preferences.SearchUrlPreferenceActivity.java
org.zirco.ui.activities.preferences.UserAgentPreferenceActivity.java
org.zirco.ui.activities.preferences.WeavePreferencesActivity.java
org.zirco.ui.activities.preferences.WeaveServerPreferenceActivity.java
org.zirco.ui.components.CustomWebViewClient.java
org.zirco.ui.components.CustomWebView.java
org.zirco.ui.runnables.DownloadRunnable.java
org.zirco.ui.runnables.FaviconUpdaterRunnable.java
org.zirco.ui.runnables.HideToolbarsRunnable.java
org.zirco.ui.runnables.HistoryUpdater.java
org.zirco.ui.runnables.XmlHistoryBookmarksExporter.java
org.zirco.ui.runnables.XmlHistoryBookmarksImporter.java
org.zirco.utils.AnimationManager.java
org.zirco.utils.ApplicationUtils.java
org.zirco.utils.Constants.java
org.zirco.utils.DateUtils.java
org.zirco.utils.IOUtils.java
org.zirco.utils.ProxyChangeReceiver.java
org.zirco.utils.ProxySettings.java
org.zirco.utils.UrlUtils.java