コード例 #1
0
ファイル: OwnCloudAccount.java プロジェクト: YudBet/owncloud
  /**
   * Method for deferred load of account attributes from AccountManager
   *
   * @param context
   * @throws AccountNotFoundException
   * @throws AuthenticatorException
   * @throws java.io.IOException
   * @throws OperationCanceledException
   */
  public void loadCredentials(Context context)
      throws AccountNotFoundException, AuthenticatorException, IOException,
          OperationCanceledException {

    if (context == null) {
      throw new IllegalArgumentException("Parameter 'context' cannot be null");
    }

    if (mSavedAccount != null) {
      mCredentials = AccountUtils.getCredentialsForAccount(context, mSavedAccount);
    }
  }
コード例 #2
0
ファイル: OwnCloudAccount.java プロジェクト: YudBet/owncloud
  /**
   * Constructor for already saved OC accounts.
   *
   * <p>Do not use for anonymous credentials.
   */
  public OwnCloudAccount(Account savedAccount, Context context) throws AccountNotFoundException {
    if (savedAccount == null) {
      throw new IllegalArgumentException("Parameter 'savedAccount' cannot be null");
    }

    if (context == null) {
      throw new IllegalArgumentException("Parameter 'context' cannot be null");
    }

    mSavedAccount = savedAccount;
    mSavedAccountName = savedAccount.name;
    mBaseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(context, mSavedAccount));
    mCredentials = null;
  }
コード例 #3
0
ファイル: OwnCloudAccount.java プロジェクト: YudBet/owncloud
 /**
  * Constructor for non yet saved OC accounts.
  *
  * @param baseUri URI to the OC server to get access to.
  * @param credentials Credentials to authenticate in the server. NULL is valid for anonymous
  *     credentials.
  */
 public OwnCloudAccount(Uri baseUri, OwnCloudCredentials credentials) {
   if (baseUri == null) {
     throw new IllegalArgumentException("Parameter 'baseUri' cannot be null");
   }
   mSavedAccount = null;
   mSavedAccountName = null;
   mBaseUri = baseUri;
   mCredentials =
       credentials != null ? credentials : OwnCloudCredentialsFactory.getAnonymousCredentials();
   String username = mCredentials.getUsername();
   if (username != null) {
     mSavedAccountName = AccountUtils.buildAccountName(mBaseUri, username);
   }
 }