private void Initialise()
 {
     _iDCredential = new DCredential();
     _iFCredential = new FCredential(_iDCredential);
     _iDRole       = new DRole();
     _iFRole       = new FRole(_iDRole);
 }
示例#2
0
 public AuthorizationProvider()
 {
     _iDCredential     = new DCredential();
     _iFCredential     = new FCredential(_iDCredential);
     _iDCredentialRole = new DCredentialRole();
     _iFCredentialRole = new FCredentialRole(_iDCredentialRole);
 }
示例#3
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            bool authorized = false;

            if (AllowAnonymous || (Cookies.IsLoggedIn && AllowedRoles.Length == 0))
            {
                authorized = true;
            }
            else if (Cookies.IsLoggedIn)
            {
                _iDCredential = new DCredential();
                _iDRole       = new DRole();
                _iFCredential = new FCredential(_iDCredential);
                _iFRole       = new FRole(_iDRole);

                authorized = _iFRole.HasRole(Cookies.CredentialId, AllowedRoles);
            }

            if (!authorized && !string.IsNullOrEmpty(RedirectController) && !string.IsNullOrEmpty(RedirectMethod))
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = RedirectController, action = RedirectMethod }));
            }
            else if (!authorized)
            {
                filterContext.Result = new HttpUnauthorizedResult();
            }
        }
示例#4
0
 public MvcAuthorizationFilterAttribute(bool allowAnonymous, string redirectController, string redirectMethod, string[] allowedRoles)
 {
     AllowAnonymous     = allowAnonymous;
     AllowedRoles       = allowedRoles;
     RedirectController = redirectController;
     RedirectMethod     = redirectMethod;
     _iDCredential      = new DCredential();
     _iDRole            = new DRole();
     _iFCredential      = new FCredential(_iDCredential);
     _iFRole            = new FRole(_iDRole);
 }
示例#5
0
 public MvcAuthorizationFilterAttribute(bool allowAnonymous)
 {
     AllowAnonymous     = allowAnonymous;
     RedirectController = string.Empty;
     RedirectMethod     = string.Empty;
     AllowedRoles       = new string[0];
     _iDCredential      = new DCredential();
     _iDRole            = new DRole();
     _iFCredential      = new FCredential(_iDCredential);
     _iDRole            = new DRole();
     _iFRole            = new FRole(_iDRole);
 }
示例#6
0
 public FCredential()
 {
     _iDCredential = new DCredential();
 }
示例#7
0
 public FCredential(IDCredential iDCredential)
 {
     _iDCredential = iDCredential;
 }