示例#1
0
        public bool Evaluate(EvaluationContext evaluationContext, ref object state)
        {
            object list;

            if (!evaluationContext.Properties.TryGetValue("Identities", out list))
            {
                return(false);
            }

            IList <IIdentity> identities = list as IList <IIdentity>;

            if (list == null || identities.Count <= 0)
            {
                return(false);
            }


            RBACPrincipalCache principalCache = RBACPrincipalCache.GetInstance();
            RBACPrincipal      principal      = principalCache.GetPrincipal(identities[0]);

            if (principal == null)
            {
                principal = GetPrincipal(identities[0]);
                principalCache.PutPrincipal(identities[0], principal);
            }

            evaluationContext.Properties["Principal"] = principal;
            return(true);
        }
示例#2
0
        public RBACPrincipal GetPrincipal(IIdentity identity)
        {
            RBACPrincipal princpial = null;

            cacheDict.TryGetValue(identity, out princpial);

            return(princpial);
        }
示例#3
0
        protected virtual RBACPrincipal GetPrincipal(IIdentity identity)
        {
            lock (locker)
            {
                RBACPrincipal   principal       = null;
                WindowsIdentity windowsIdentity = identity as WindowsIdentity;

                if (windowsIdentity != null)
                {
                    //Audit.AuthenticationSuccess(windowsIdentity.Name);
                    principal = new RBACPrincipal(windowsIdentity);
                }
                else
                {
                    X509Certificate2 cert = GetCertificate(identity);
                    //Console.WriteLine(cert.SubjectName.Name);
                    principal = new RBACPrincipal(cert, identity);
                }

                return(principal);
            }
        }
示例#4
0
 public void PutPrincipal(IIdentity identity, RBACPrincipal principal)
 {
     cacheDict[identity] = principal;
 }