Beispiel #1
0
 public AuthorizationResult(string mode, TSubject subject, AccessDecisionStrategy accessDecisionStrategy,
                            bool unanimousVoteAllowIfAllAbstain)
 {
     Mode    = mode;
     Subject = subject;
     AccessDecisionStrategy         = accessDecisionStrategy;
     UnanimousVoteAllowIfAllAbstain = unanimousVoteAllowIfAllAbstain;
 }
        public IAuthorizationResult <TSubject> GetAuthorizationResult <TSubject>(
            string mode,
            TSubject subject,
            AccessDecisionStrategy accessDecisionStrategy)
        {
            var voterServices       = serviceProvider.GetServices <IVoter <TSubject> >();
            var authorizationResult =
                new AuthorizationResult <TSubject>(mode, subject, accessDecisionStrategy, UnanimousVoteAllowIfAllAbstain);

            foreach (var voterService in voterServices)
            {
                if (voterService.WillVote(mode, subject))
                {
                    authorizationResult.Results.Add(voterService.GetType(), voterService.Vote(mode, subject));
                }
            }

            return(authorizationResult);
        }
 public bool IsAllowed <TSubject, TUser>(string mode, TSubject subject, TUser user, AccessDecisionStrategy accessDecisionStrategy)
 {
     return(GetAuthorizationResult(mode, subject, user, accessDecisionStrategy).IsAllowed());
 }