Esempio n. 1
0
        /// <summary>
        /// 当前用户是否具有指定
        /// </summary>
        /// <param name="Me"></param>
        /// <param name="droit"></param>
        /// <returns></returns>
        public static bool Authorize(this Me Me, IDroit droit)
        {
            BzurePrincipal principal = Me.Principal as BzurePrincipal;

            if (principal == default(BzurePrincipal))
            {
                return(false);
            }
            return(principal.GetPermission().Authentication(droit));
        }
Esempio n. 2
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            foreach (IAccessCode code in codes)
            {
                this._droit.AddAccessCode(code);
            }
            IDroit droit = this._droit.Copy();

            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (!httpContext.User.Identity.IsAuthenticated)
            {
                return(false);
            }
            BzurePrincipal principal = httpContext.User as BzurePrincipal;

            if (principal == default(BzurePrincipal))
            {
                return(false);
            }
            return(principal.GetPermission().Authentication(droit));
        }