Beispiel #1
0
 // Getting an authentication token is not supported //throws NetworkErrorException
 public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     var result = new Bundle();
     var am = AccountManager.Get(mContext.ApplicationContext);
     var authToken = am.PeekAuthToken(account, authTokenType);
     if (string.IsNullOrEmpty(authToken))
     {
         var password = am.GetPassword(account);
         if (!string.IsNullOrEmpty(password))
         {
             authToken = AuthTokenLoader.SignIn(mContext, account.Name, password);
         }
     }
     if (!string.IsNullOrEmpty(authToken))
     {
         result.PutString(AccountManager.KeyAccountName, account.Name);
         result.PutString(AccountManager.KeyAccountType, account.Type);
         result.PutString(AccountManager.KeyAuthtoken, authToken);
     }
     else
     {
         var intent = new Intent(mContext, typeof(LoginActivity));
         intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
         intent.PutExtra(LoginActivity.EXTRA_TOKEN_TYPE, authTokenType);
         var bundle = new Bundle();
         bundle.PutParcelable(AccountManager.KeyIntent, intent);
     }
     return result;
 }
Beispiel #2
0
        public override Bundle UpdateCredentials(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
        {
            // Update credentials for specified Account
            var result = new Bundle();

            result.PutBoolean(AccountManager.KeyBooleanResult, false);
            return(result);
        }
Beispiel #3
0
        public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, string[] features)
        {
            // Returns supported Authenticator features for specified Account
            var result = new Bundle();

            result.PutBoolean(AccountManager.KeyBooleanResult, false);
            return(result);
        }
Beispiel #4
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     mAccountAuthenticatorResponse = Intent.GetParcelableExtra(AccountManager.KeyAccountManagerResponse) as AccountAuthenticatorResponse;
     if (mAccountAuthenticatorResponse != null)
     {
         mAccountAuthenticatorResponse.OnRequestContinued();
     }
 }
Beispiel #5
0
        public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, string[] features)
        {
            Console.WriteLine("UdinicAuthenticator: HasFeatures");

            Bundle result = new Bundle();

            result.PutBoolean(AccountManager.KeyBooleanResult, false);
            return(result);
        }
        // Adds an account of the specified accountType.
        public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
        {
            var acc = new Account(options.GetString(AccountManager.KeyAccountName), accountType);

            var am = AccountManager.Get(this.context);

            am.AddAccountExplicitly(acc, null, options);

            return(null);
        }
 public override Bundle AddAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)
 {
     System.Console.WriteLine ("KiwiAuthenticator-AddAccount");
     Intent intent = new Intent(mContext, typeof(LoginActivity));
     intent.PutExtra("accountType", accountType);
     intent.PutExtra("authTokenType", authTokenType);
     intent.PutExtra("isAddingNewAccount", true);
     intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
     Bundle bundle = new Bundle();
     bundle.PutParcelable(AccountManager.KeyIntent, intent);
     return bundle;
 }
Beispiel #8
0
 // Don't add additional accounts //throws NetworkErrorException
 public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
 {
     var intent = new Intent(mContext, typeof(LoginActivity));
     intent.PutExtra(LoginActivity.EXTRA_TOKEN_TYPE, accountType);
     intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
     var bundle = new Bundle();
     if (options != null)
     {
         bundle.PutAll(options);
     }
     bundle.PutParcelable(AccountManager.KeyIntent, intent);
     return bundle;
 }
Beispiel #9
0
        public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
        {
            var intent = new Intent(_context, typeof(AccountActivity));

            intent.PutExtra(AccountManager.KeyAccountType, accountType);
            intent.PutExtra(nameof(AddAccount), true);
            intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);

            var bundle = new Bundle();

            bundle.PutParcelable(AccountManager.KeyIntent, intent);

            return(bundle);
        }
Beispiel #10
0
        public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
        {
            Console.WriteLine("UdinicAuthenticator: AddAccount");

            Intent intent = new Intent(mContext, typeof(AuthenticatorActivity));

            intent.PutExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, accountType);
            intent.PutExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);
            intent.PutExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
            intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);

            Bundle bundle = new Bundle();

            bundle.PutParcelable(AccountManager.KeyIntent, intent);
            return(bundle);
        }
Beispiel #11
0
 public override void Finish()
 {
     if (mAccountAuthenticatorResponse != null)
     {
         // send the result bundle back if set, otherwise send an error.
         if (mResultBundle != null)
         {
             mAccountAuthenticatorResponse.OnResult(mResultBundle);
         }
         else
         {
             mAccountAuthenticatorResponse.OnError(ErrorCode.Canceled, "canceled");
         }
         mAccountAuthenticatorResponse = null;
     }
     base.Finish();
 }
Beispiel #12
0
        public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)
        {
            // Extract the username and password from the Account Manager, and ask
            // the server for an appropriate AuthToken.
            AccountManager am = AccountManager.Get(mContext);

            String authToken = am.PeekAuthToken(account, authTokenType);

            // Lets give another try to authenticate the user
            if (TextUtils.IsEmpty(authToken)) {
                String password = am.GetPassword(account);
                if (password != null) {
                    //var auth = new KiwiServerAuthenticate ();
                    var auth = new KiwiLoginService ();
                    var authTokenResult = auth.Login(account.Name, password);
                    Task.WaitAll(authTokenResult);
                    authToken = authTokenResult.Result.AuthToken;
                }
            }

            // If we get an authToken - we return it
            if (!TextUtils.IsEmpty(authToken)) {
                Bundle result = new Bundle();
                result.PutString(AccountManager.KeyAccountName, account.Name);
                result.PutString(AccountManager.KeyAccountType, account.Type);
                result.PutString(AccountManager.KeyAuthtoken, authToken);
                return result;
            }

            // If we get here, then we couldn't access the user's password - so we
            // need to re-prompt them for their credentials. We do that by creating
            // an intent to display our AuthenticatorActivity.
            Intent intent = new Intent(mContext, typeof(LoginActivity));
            intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
            intent.PutExtra("accountType", account.Type);
            intent.PutExtra("authTokenType", authTokenType);
            intent.PutExtra ("accountName", account.Name);
            Bundle bundle = new Bundle();
            bundle.PutParcelable(AccountManager.KeyIntent, intent);
            return bundle;
        }
Beispiel #13
0
        public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
        {
            try
            {
                Log.Debug("IIM", TAG + "> addAccount");

                Intent intent = new Intent(mContext, typeof(AuthenticatorActivity));
                intent.PutExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, accountType);
                intent.PutExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);
                intent.PutExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
                intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);

                Bundle bundle = new Bundle();
                bundle.PutParcelable(AccountManager.KeyIntent, intent);
                return(bundle);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Beispiel #14
0
        public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
        {
            var accountManager = AccountManager.Get(_context);
            var authToken      = accountManager.PeekAuthToken(account, authTokenType);

            if (string.IsNullOrWhiteSpace(authToken))
            {
                var username = account.Name;
                var password = accountManager.GetPassword(account);
                if (!string.IsNullOrWhiteSpace(username) &&
                    !string.IsNullOrWhiteSpace(password))
                {
                    authToken = _authService.GetAuthToken(username, password).Result;
                }
            }

            if (!string.IsNullOrWhiteSpace(authToken))
            {
                var result = new Bundle();
                result.PutString(AccountManager.KeyAccountName, account.Name);
                result.PutString(AccountManager.KeyAccountType, account.Type);
                result.PutString(AccountManager.KeyAuthtoken, authToken);
                return(result);
            }

            var intent = new Intent(_context, typeof(AccountActivity));

            intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
            intent.PutExtra(AccountManager.KeyAccountType, account.Type);
            intent.PutExtra(AccountManager.KeyAccountName, account.Name);

            var bundle = new Bundle();

            bundle.PutParcelable(AccountManager.KeyIntent, intent);
            return(bundle);
        }
Beispiel #15
0
 // Getting an authentication token is not supported //throws NetworkErrorException
 public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     throw new UnsupportedOperationException();
 }
Beispiel #16
0
 public override Bundle UpdateCredentials(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     Console.WriteLine("UdinicAuthenticator: UpdateCredentials");
     return(null);
 }
Beispiel #17
0
        public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
        {
            Console.WriteLine("UdinicAuthenticator: GetAuthToken");

            // If the caller requested an authToken type we don't support, then
            // return an error
            if (!authTokenType.Equals(AccountGeneral.AUTHTOKEN_TYPE_READ_ONLY) && !authTokenType.Equals(AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS))
            {
                Bundle result = new Bundle();
                result.PutString(AccountManager.KeyErrorMessage, "invalid authTokenType");
                return(result);
            }

            // Extract the username and password from the Account Manager, and ask
            // the server for an appropriate AuthToken.
            AccountManager am = AccountManager.Get(mContext);

            String authToken = am.PeekAuthToken(account, authTokenType);
            String userId    = null; //User identifier, needed for creating ACL on our server-side

            //Log.d("udinic", TAG + "> peekAuthToken returned - " + authToken);

            // Lets give another try to authenticate the user
            if (TextUtils.IsEmpty(authToken))
            {
                String password = am.GetPassword(account);
                if (password != null)
                {
                    try
                    {
                        //Log.d("udinic", TAG + "> re-authenticating with the existing password");
                        User user = AccountGeneral.sServerAuthenticate.UserSignIn(account.Name, password, authTokenType);
                        if (user != null)
                        {
                            authToken = user.getSessionToken();
                            userId    = user.getObjectId();
                        }
                    }
                    catch (Exception e)
                    {
                        //e.printStackTrace();
                    }
                }
            }

            // If we get an authToken - we return it
            if (!TextUtils.IsEmpty(authToken))
            {
                Bundle result = new Bundle();
                result.PutString(AccountManager.KeyAccountName, account.Name);
                result.PutString(AccountManager.KeyAccountType, account.Type);
                result.PutString(AccountManager.KeyAuthtoken, authToken);
                return(result);
            }

            // If we get here, then we couldn't access the user's password - so we
            // need to re-prompt them for their credentials. We do that by creating
            // an intent to display our AuthenticatorActivity.
            Intent intent = new Intent(mContext, typeof(AuthenticatorActivity));

            intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
            intent.PutExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, account.Type);
            intent.PutExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);
            Bundle bundle = new Bundle();

            bundle.PutParcelable(AccountManager.KeyIntent, intent);
            return(bundle);
        }
Beispiel #18
0
 public override Android.OS.Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Android.OS.Bundle options)
 {
     throw new System.NotImplementedException();
 }
Beispiel #19
0
 public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
 {
     Console.WriteLine("UdinicAuthenticator: ConfirmCredentials");
     return(null);
 }
Beispiel #20
0
 public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
 {
     throw new NotImplementedException();
 }
Beispiel #21
0
 /// <summary>
 /// Adds the account.
 /// </summary>
 /// <returns>The account.</returns>
 /// <param name="response">Response.</param>
 /// <param name="accountType">Account type.</param>
 /// <param name="authTokenType">Auth token type.</param>
 /// <param name="requiredFeatures">Required features.</param>
 /// <param name="options">Options.</param>
 public override Android.OS.Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Android.OS.Bundle options)
 {
     throw new System.NotImplementedException();
 }
 public override Bundle EditProperties(AccountAuthenticatorResponse response, string accountType)
 {
     throw new UnsupportedOperationException();
 }
 // Stub Method
 public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     Console.WriteLine("Get Auth Token");
     return(null);
 }
 public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, string[] features)
 {
     return(null);
 }
 public override Bundle UpdateCredentials(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     return(null);
 }
Beispiel #26
0
 public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
 {
     // Checks credentials against an existing account
     return(null);
 }
Beispiel #27
0
 // Checking features for the account is not supported
 public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, string[] features)
 {
     //throws NetworkErrorException
     throw new Java.Lang.UnsupportedOperationException();
 }
Beispiel #28
0
 public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
 {
     return(null);
 }
Beispiel #29
0
 // Updating user credentials is not supported
 public override Bundle UpdateCredentials(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     //throws NetworkErrorException
     throw new Java.Lang.UnsupportedOperationException();
 }
Beispiel #30
0
 public override Bundle UpdateCredentials(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     throw new NotImplementedException();
 }
Beispiel #31
0
 /// <summary>
 /// Gets the auth token.
 /// </summary>
 /// <returns>The auth token.</returns>
 /// <param name="response">Response.</param>
 /// <param name="account">Account.</param>
 /// <param name="authTokenType">Auth token type.</param>
 /// <param name="options">Options.</param>
 public override Android.OS.Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Android.OS.Bundle options)
 {
     throw new System.NotImplementedException();
 }
Beispiel #32
0
 public override Bundle UpdateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)
 {
     return null;
 }
Beispiel #33
0
 public override Bundle EditProperties(AccountAuthenticatorResponse response, String accountType)
 {
     return null;
 }
Beispiel #34
0
 // Don't add additional accounts //throws NetworkErrorException
 public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
 {
     throw new UnsupportedOperationException();
 }
Beispiel #35
0
 public override Bundle EditProperties(AccountAuthenticatorResponse response, string accountType)
 {
     Console.WriteLine("UdinicAuthenticator: EditProperties");
     return(null);
 }
Beispiel #36
0
 // Ignore attempts to confirm credentials
 public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
 {
     //throws NetworkErrorException
     return null;
 }
Beispiel #37
0
 public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
 {
     return null;
 }
Beispiel #38
0
 // Editing properties is not supported
 public override Bundle EditProperties(AccountAuthenticatorResponse response, string accountType)
 {
     throw new Java.Lang.UnsupportedOperationException();
 }
 // Stub Method
 public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, string[] features)
 {
     Console.WriteLine("Has Feature");
     return(null);
 }
Beispiel #40
0
 public override Bundle EditProperties(AccountAuthenticatorResponse response, string accountType)
 {
     // Returns Bundle containing Intent for an Activity to edit properties
     return(null);
 }
Beispiel #41
0
 public override Bundle EditProperties(AccountAuthenticatorResponse response, string accountType)
 {
     throw new NotImplementedException();
 }
Beispiel #42
0
 public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
 {
     Console.WriteLine("Confirm Credentials");
     return(this.ConfirmCredentials(response, account, options));
 }
Beispiel #43
0
 public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
 {
     return(null);
 }
Beispiel #44
0
        public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
        {
            Log.Debug("IIM", TAG + "> GetAuthToken");

            // If the caller requested an authToken type we don't support, then
            // return an error
            if (!authTokenType.Equals(AccountGeneral.AUTHTOKEN_TYPE_READ_ONLY) && !authTokenType.Equals(AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS))
            {
                Bundle result = new Bundle();
                result.PutString(AccountManager.KeyErrorMessage, "invalid authTokenType");
                return(result);
            }

            // Extract the username and password from the Account Manager, and ask
            // the server for an appropriate AuthToken.
            AccountManager am = AccountManager.Get(mContext);

            String authToken = am.PeekAuthToken(account, authTokenType);

            Log.Debug("IIM", TAG + "> peekAuthToken returned - " + authToken);

            // Lets give another try to authenticate the user
            //if (string.IsNullOrEmpty(authToken))
            //{
            //    string password = am.GetPassword(account);
            //    if (password != null)
            //    {
            //        try
            //        {
            //            Log.Debug("IIM", TAG + "> re-authenticating with the existing password");
            //            ParseComServerAuthenticate parseCom = new ParseComServerAuthenticate();
            //            authToken = parseCom.UserSignIn(ServiceConstants.GRAPHURI, new PlatformParameters(mContext));
            //        }
            //        catch (Exception e)
            //        {
            //            Console.WriteLine(e.InnerException);
            //        }
            //    }
            //}

            // If we get an authToken - we return it
            if (!string.IsNullOrEmpty(authToken))
            {
                Bundle result = new Bundle();
                result.PutString(AccountManager.KeyAccountName, account.Name);
                result.PutString(AccountManager.KeyAccountType, account.Type);
                result.PutString(AccountManager.KeyAuthtoken, authToken);
                return(result);
            }

            // If we get here, then we couldn't access the user's password - so we
            // need to re-prompt them for their credentials. We do that by creating
            // an intent to display our AuthenticatorActivity.
            Intent intent = new Intent(mContext, typeof(AuthenticatorActivity));

            intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
            intent.PutExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, account.Type);
            intent.PutExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);
            intent.PutExtra(AuthenticatorActivity.ARG_ACCOUNT_NAME, account.Name);
            Bundle bundle = new Bundle();

            bundle.PutParcelable(AccountManager.KeyIntent, intent);
            return(bundle);
        }
Beispiel #45
0
 public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, string[] features)
 {
     throw new NotImplementedException();
 }
Beispiel #46
0
 public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, String[] features)
 {
     Bundle result = new Bundle();
     result.PutBoolean(AccountManager.KeyBooleanResult, false);
     return result;
 }