示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool Create(MembershipEntity entity, DbConnection connection, DbTransaction transaction, out MembershipCreateStatus status)
        {
            status = MembershipCreateStatus.ProviderError;

            entity.Password = KandaHashAlgorithm.ComputeHash(typeof(SHA512Managed).FullName, ((SecureString)entity.Password).GetString(), Encoding.Unicode);

            var error = MembershipsGateway.Insert(entity, connection, transaction);

            switch (error)
            {
            case KandaTableDataGateway.NO_ERRORS:
                status = MembershipCreateStatus.Success;
                return(true);

            case KandaTableDataGateway.DUPLICATE_USER_NAME:
                status = MembershipCreateStatus.DuplicateUserName;
                break;

            //case KandaTableDataGateway.DUPLICATE_PROVIDER_USER_KEY:
            //    status = MembershipCreateStatus.DuplicateProviderUserKey;
            //    break;

            default:
                break;
            }

            return(false);

            //return (error == KandaTableDataGateway.NO_ERRORS);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public MembershipEntity Find(MembershipsCriteria criteria, DbConnection connection, DbTransaction transaction)
        {
            var password = criteria.Password;

            if (password == null)
            {
                this.DoNothing();
            }
            else
            {
                if (criteria.Password is SecureString)
                {
                    password = ((SecureString)criteria.Password).GetString();
                }

                var hash = KandaHashAlgorithm.ComputeHash(typeof(SHA512Managed).FullName, (string)password, Encoding.Unicode);
                password = hash;
            }
            criteria.Password = password;

            var reader = default(KandaDbDataReader);

            try
            {
                reader = MembershipsGateway.Select(criteria, connection, transaction);

                var found = (reader.Read() ? KandaDbDataMapper.MapToObject <MembershipEntity>(reader) : MembershipEntity.Empty);

                return(found);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
示例#3
0
 public void ComputeHashFact()
 {
     var hash = KandaHashAlgorithm.ComputeHash(typeof(SHA256).FullName, @"s", Encoding.Default);
 }