Exemplo n.º 1
0
        public void Setup()
        {
            var userPolicies = new PolicyLookup <string, MyUserSecurityContext>
            {
                {
                    "user1",
                    new CustomerPolicy(
                        new CustomerPolicy.CustomerPolicyData(
                            create: false,
                            delete: false,
                            view: true,
                            update: false,
                            viewPersonnel: false,
                            viewVip: true,
                            viewBalanceLimit: 5000,
                            viewRealNames: false
                            ))
                }
            };

            var groupPolicies = new PolicyLookup <string, MyUserSecurityContext>();
            var rolePolicies  = new PolicyLookup <RolesEnum, MyUserSecurityContext>();

            var userPolicyRepo  = new SecurityObjectPolicyRepository <string, MyUserSecurityContext>(userPolicies);
            var groupPolicyRepo = new SecurityObjectPolicyRepository <string, MyUserSecurityContext>(groupPolicies);
            var rolePolicyRepo  = new SecurityObjectPolicyRepository <RolesEnum, MyUserSecurityContext>(rolePolicies);

            var policyRepo = new PolicyRepository(userPolicyRepo, groupPolicyRepo, rolePolicyRepo);

            var userSecurityContext1 = new MyUserSecurityContext("user1", new[] { "g1", "g2" }, new RolesEnum[] { RolesEnum.Cashier });

            UserContexts.User1 = new UserSecuritySchema <MyUserSecurityContext>(policyRepo, userSecurityContext1);
        }
Exemplo n.º 2
0
 public SecurityObjectPolicyRepository(PolicyLookup <TKey, TUserSecurityContext> policies)
 {
     this.policies = policies;
 }