예제 #1
0
  /**
   * 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
  /**
   * 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
 /**
  * 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);
   }
 }