示例#1
0
        public override int GetHashCode()
        {
            var hash = 3;

            hash = (hash * 2) + EnableLdapAuthentication.GetHashCode();
            hash = (hash * 2) + StartTls.GetHashCode();
            hash = (hash * 2) + Ssl.GetHashCode();
            hash = (hash * 2) + SendWelcomeEmail.GetHashCode();
            hash = (hash * 2) + Server.GetHashCode();
            hash = (hash * 2) + UserDN.GetHashCode();
            hash = (hash * 2) + PortNumber.GetHashCode();
            hash = (hash * 2) + UserFilter.GetHashCode();
            hash = (hash * 2) + LoginAttribute.GetHashCode();
            hash = (hash * 2) + GroupMembership.GetHashCode();
            hash = (hash * 2) + GroupDN.GetHashCode();
            hash = (hash * 2) + GroupNameAttribute.GetHashCode();
            hash = (hash * 2) + GroupFilter.GetHashCode();
            hash = (hash * 2) + UserAttribute.GetHashCode();
            hash = (hash * 2) + GroupAttribute.GetHashCode();
            hash = (hash * 2) + Authentication.GetHashCode();
            hash = (hash * 2) + Login.GetHashCode();

            foreach (var pair in LdapMapping)
            {
                hash = (hash * 2) + pair.Value.GetHashCode();
            }

            foreach (var pair in AccessRights)
            {
                hash = (hash * 2) + pair.Value.GetHashCode();
            }

            return(hash);
        }
        public override int GetHashCode()
        {
            var hash = 3;

            hash = (hash * 2) + EnableLdapAuthentication.GetHashCode();
            hash = (hash * 2) + StartTls.GetHashCode();
            hash = (hash * 2) + Server.GetHashCode();
            hash = (hash * 2) + UserDN.GetHashCode();
            hash = (hash * 2) + PortNumber.GetHashCode();
            hash = (hash * 2) + UserFilter.GetHashCode();
            hash = (hash * 2) + LoginAttribute.GetHashCode();
            hash = (hash * 2) + FirstNameAttribute.GetHashCode();
            hash = (hash * 2) + SecondNameAttribute.GetHashCode();
            hash = (hash * 2) + MailAttribute.GetHashCode();
            hash = (hash * 2) + TitleAttribute.GetHashCode();
            hash = (hash * 2) + MobilePhoneAttribute.GetHashCode();
            hash = (hash * 2) + LocationAttribute.GetHashCode();
            hash = (hash * 2) + GroupMembership.GetHashCode();
            hash = (hash * 2) + GroupDN.GetHashCode();
            hash = (hash * 2) + GroupNameAttribute.GetHashCode();
            hash = (hash * 2) + GroupFilter.GetHashCode();
            hash = (hash * 2) + UserAttribute.GetHashCode();
            hash = (hash * 2) + GroupAttribute.GetHashCode();
            hash = (hash * 2) + Authentication.GetHashCode();
            hash = (hash * 2) + Login.GetHashCode();
            return(hash);
        }
示例#3
0
        /// <summary>
        /// 执行,按实际结果返回
        /// </summary>
        /// <param name="letter">客户端递交的参数信息</param>
        /// <returns></returns>
        public static object Exec(Letter letter)
        {
            //1.创建对象,即$api.get("account/single")中的account
            object execObj = ExecuteMethod.CreateInstance(letter);
            //2.获取要执行的方法,即$api.get("account/single")中的single
            MethodInfo method = getMethod(execObj.GetType(), letter);

            //3#.验证方法的特性,一是验证Http动词,二是验证是否登录后操作,三是验证权限
            //----验证Http谓词访问限制
            HttpAttribute.Verify(letter.HTTP_METHOD, method);
            //LoginAttribute.Verify(method);
            //----范围控制,本机或局域网,或同域
            bool isRange = RangeAttribute.Verify(letter, method);
            //----验证是否需要登录
            LoginAttribute loginattr = LoginAttribute.Verify(method);


            //4.构建执行该方法所需要的参数
            object[] parameters = getInvokeParam(method, letter);
            //5.执行方法,返回结果
            object objResult = method.Invoke(execObj, parameters);

            //将执行结果写入日志
            LoginAttribute.LogWrite(loginattr, objResult);
            return(objResult);
        }
示例#4
0
        /// <summary>
        /// 执行,按实际结果返回
        /// </summary>
        /// <param name="letter">客户端递交的参数信息</param>
        /// <returns></returns>
        public static object Exec(Letter letter)
        {
            //1.创建对象,即$api.get("account/single")中的account
            IViewAPI execObj = ExecuteMethod.CreateInstance(letter);
            //2.获取要执行的方法,即$api.get("account/single")中的single
            MethodInfo method = getMethod(execObj.GetType(), letter);

            //清除缓存
            if (letter.HTTP_METHOD.Equals("put", StringComparison.CurrentCultureIgnoreCase))
            {
                CacheAttribute.Remove(method, letter);
            }
            //3#.验证方法的特性,一是验证Http动词,二是验证是否登录后操作,三是验证权限
            //----验证Http谓词访问限制
            HttpAttribute.Verify(letter.HTTP_METHOD, method);
            //LoginAttribute.Verify(method);
            //----范围控制,本机或局域网,或同域
            bool isRange = RangeAttribute.Verify(method, letter);
            //----验证是否需要登录
            LoginAttribute loginattr = LoginAttribute.Verify(method, letter);

            //----清理参数值中的html标签,默认全部清理,通过设置not参数不过虑某参数
            HtmlClearAttribute.Clear(method, letter);


            //4.构建执行该方法所需要的参数
            object[] parameters = getInvokeParam(method, letter);
            //5.执行方法,返回结果
            object objResult = null;    //结果
            //只有get方式时,才使用缓存
            CacheAttribute cache = null;

            //if (letter.HTTP_METHOD.Equals("put", StringComparison.CurrentCultureIgnoreCase))
            //    CacheAttribute.Remove(method, letter);
            if (letter.HTTP_METHOD.Equals("get", StringComparison.CurrentCultureIgnoreCase))
            {
                cache = CacheAttribute.GetAttr <CacheAttribute>(method);
            }
            if (cache != null)
            {
                objResult = CacheAttribute.GetResult(method, letter);
                if (objResult == null)
                {
                    objResult = method.Invoke(execObj, parameters);
                    CacheAttribute.Insert(cache.Expires, method, letter, objResult);
                }
            }
            else
            {
                objResult = method.Invoke(execObj, parameters);
            }
            //将执行结果写入日志
            LoginAttribute.LogWrite(loginattr, objResult);
            return(objResult);
        }
示例#5
0
        public ResponseDto IsLogin()
        {
            Sessions.Session session        = null;
            LoginAttribute   loginAttribute = new LoginAttribute();
            bool             result         = loginAttribute.CheckAuthorized(ActionContext, out session);

            return(new ResponseDto()
            {
                IsSuccess = result
            });
        }
示例#6
0
        /// <summary>
        /// 执行,按实际结果返回
        /// </summary>
        /// <param name="letter">客户端递交的参数信息</param>
        /// <returns></returns>
        public static object Exec(Letter letter)
        {
            //1.创建对象,即$api.get("account/single")中的account
            object execObj = ExecuteMethod.CreateInstance(letter);
            //2.获取要执行的方法,即$api.get("account/single")中的single
            MethodInfo method = getMethod(execObj.GetType(), letter);

            //3#.验证方法的特性,一是验证Http动词,二是验证是否登录后操作,三是验证权限
            //----验证Http谓词访问限制
            HttpAttribute.Verify(letter.HTTP_METHOD, method);
            //LoginAttribute.Verify(method);
            //----范围控制,本机或局域网,或同域
            bool isRange = RangeAttribute.Verify(letter, method);
            //----验证是否需要登录
            LoginAttribute loginattr = LoginAttribute.Verify(method);


            //4.构建执行该方法所需要的参数
            object[] parameters = getInvokeParam(method, letter);
            //5.执行方法,返回结果
            object objResult = null;    //结果
            //只有get方式时,才使用缓存
            CacheAttribute cache = null;

            if (letter.HTTP_METHOD == "GET")
            {
                cache = CacheAttribute.GetAttr <CacheAttribute>(method);
            }
            if (cache != null)
            {
                objResult = CacheAttribute.GetResult(method, letter);
                if (objResult == null)
                {
                    objResult = method.Invoke(execObj, parameters);
                    CacheAttribute.Insert(cache.Expires, method, letter, objResult);
                }
            }
            else
            {
                objResult = method.Invoke(execObj, parameters);
            }
            //将执行结果写入日志
            LoginAttribute.LogWrite(loginattr, objResult);
            return(objResult);
        }
示例#7
0
        public async Task <MethodResults> AddUserToAccount(string userId, string emailAddress, string userName, CoreLoggerProvider logger, string IPAddress, string instigator, BPMainContext context, int accountId, int loginTypeId, int presidenceTypeId)
        {
            var methodResults = new MethodResults {
                Success = false, Message = "Something went wrong.  Nothing was changed.  Please try again or contact your network or system administrator."
            };
            // we're adding a user to either an existing account, or to a new account
            var account = new BPAccount();

            if (accountId == 0)
            {
                var dateType = await context.AccountDateTypes.FirstOrDefaultAsync(x => x.Index == 1);

                var accountType = await context.AccountTypes.FirstOrDefaultAsync(x => x.Index == 1);

                var accountDates = new List <AccountDate> {
                    new AccountDate {
                        DateLine = DateTimeOffset.Now, AccountDateType = dateType
                    }
                };

                account.EntityAttribute = new EntityAttribute
                {
                    AccountDates = accountDates,
                    AccountType  = accountType
                };
                account.UserAttribute = new UserAttribute();
            }
            else
            {
                account = await context.Accounts.FindAsync(accountId);
            }
            var loginType = await context.LoginIdTypes.FirstOrDefaultAsync(x => x.Index == loginTypeId);

            var presidenceType = await context.PresidenceTypes.FirstOrDefaultAsync(x => x.Index == presidenceTypeId);

            var loginIds = new List <LoginId> {
                new LoginId {
                    UserId         = userId,
                    EmailAddress   = emailAddress,
                    PresidenceType = presidenceType,
                    LoginIdType    = loginType
                }
            };
            var loginAttribute = new LoginAttribute
            {
                LoginIds = loginIds
            };

            if (accountId > 0)
            {
                var entry = context.Entry(account);
                entry.Entity.LoginAttribute = loginAttribute;
                entry.State = EntityState.Modified;
            }
            else
            {
                account.LoginAttribute = loginAttribute;
                context.Accounts.Add(account);
            }
            methodResults = await context.SaveChangesAsync(context);

            var subject = "Add user to account";
            var system  = "User Service";

            if (methodResults.Success)
            {
                await logger.CreateNewLog($"Successfully added user {emailAddress} to account {account.ID} on {IPAddress} by {instigator}.", subject, instigator, system);
            }
            else
            {
                await logger.CreateNewLog($"Unable to add user {emailAddress} to an account on {IPAddress} by {instigator}.", subject, instigator, system);
            }
            return(methodResults);
        }