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); }
public static RBACPrincipalCache GetInstance() { if (instance == null) { instance = new RBACPrincipalCache(); RBACManager.GetInstance().AddObserver(instance); } return(instance); }