Beispiel #1
0
        /// <summary>
        /// Load the credential associted with the specified user ID.
        /// </summary>
        /// <param name="userID">User identifier used to access appropriate credential.</param>
        /// <param name="ssoGroupKey">SSO Group Key.</param>
        override public Credential Load(string userID, string ssoGroupKey)
        {
            Credential credential = null;

            try
            {
                NativeCredential nc = null;

                var credentials = FindCredentialsForOrg(ssoGroupKey);

                foreach (var c in credentials)
                {
                    if (userID.Equals(string.Empty) ||
                        userID.Equals(c.UserID))
                    {
                        nc = c;
                        break;
                    }
                }

                if (nc != null)
                {
                    credential = Credential.From(nc);
                }
            }
            catch (System.Exception e)
            {
                string msg = e.Message;
            }

            return(credential);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new Credential object from a Kinvey user login/create request, and saves the it in the Credential Store.
        /// </summary>
        /// <returns>The and store credential.</returns>
        /// <param name="response">Response.</param>
        /// <param name="userId">User _id.</param>
        /// <param name="ssoGroupKey">SSO Group Key.</param>
        public Credential CreateAndStoreCredential(KinveyAuthResponse response, string userId, string ssoGroupKey, string deviceID)
        {
            Credential newCredential = Credential.From(response);

            newCredential.DeviceID = deviceID;
            if (userId != null && credentialStore != null)
            {
                var oldCred = credentialStore.Load(userId, ssoGroupKey);
                newCredential.MICClientID = oldCred?.MICClientID;
                credentialStore.Store(userId, ssoGroupKey, newCredential);
            }
            return(newCredential);
        }
        /// <summary>
        /// Load the specified userId.
        /// </summary>
        /// <param name="userId">User identifier.</param>
        /// <param name="ssoGroupKey">SSO Group Key.</param>
        virtual public Credential Load(string userId, string ssoGroupKey)
        {
            SQLCredential sqlcred;

            lock (SQLiteFiles[dbPath])
            {
                sqlcred = _dbConnection.Table <SQLCredential>().Where(t => t.UserID == userId).FirstOrDefault();
            }
            Credential cred = null;

            if (sqlcred != null)
            {
                cred = Credential.From(sqlcred);
            }

            return(cred);
        }
Beispiel #4
0
        /// <summary>
        /// Load the specified userID.
        /// </summary>
        /// <param name="userID">User identifier.</param>
        /// <param name="ssoGroupKey">SSO Group Key.</param>
        override public Credential Load(string userID, string ssoGroupKey)
        {
            Credential credential = null;

            try
            {
                NativeCredential nc = null;

                var credentials = FindCredentialsForOrg(ssoGroupKey);

                foreach (var c in credentials)
                {
                    if (userID.Equals(string.Empty) ||
                        userID.Equals(c.UserID))
                    {
                        nc = c;
                        break;
                    }
                }

                if (nc != null)
                {
                    credential = Credential.From(nc);
                }
            }
            catch (Exception e)
            {
                throw new KinveyException(
                          EnumErrorCategory.ERROR_USER,
                          EnumErrorCode.ERROR_USER_LOAD_CREDENTIAL,
                          "",
                          e
                          );
            }

            return(credential);
        }