public RateLimitProcessor(RateLimitOptions options, ICacheManager cacheManager, IPolicyStore policyStore, IRateLimitCounterStore counterStore)
 {
     _options      = options;
     _cacheManager = cacheManager;
     _policyStore  = policyStore;
     _counterStore = counterStore;
 }
Example #2
0
		public void Export(IPolicyStore policyStore, List<Guid> policiesToExport)
		{
			if ((!policyStore.CanWrite) || (null == policyStore.Writer))
				throw new Workshare.Policy.Exceptions.PolicyException("Argument Exception! Incorrect policy store, unable to export policy to a  storage that doesn't support a writer");

			IPolicyStoreWriter writer = policyStore.Writer;
			writer.WritePolicySet(this);

			foreach (Guid guid in policiesToExport)
			{
				IPolicy policy = Policies[guid];

				if (policy == null)
					throw new Exception("Failed to find policy : " + guid.ToString());

				writer.WritePolicy(this, policy);

				if (null != policy.Conditions)
					writer.WriteChildCollection(this, policy, policy.Name.Value, policy.Conditions);

				if (null != policy.Channels)
					writer.WriteChildCollection(this, policy, policy.Name.Value, CollectionConverter.Convert<IPolicyChannel, IPolicyObject>(policy.Channels));

			}
			writer.Close();
		}
Example #3
0
 public Context(MDIChildForm parent, IPolicyStore policyStore)
 {
     m_parent = parent;
     m_policyStore = policyStore;
     //TODO: this will be refactored when IPolicy layer is removed
     m_policySet = m_policyStore.Reader.PolicySets[0];
 }
Example #4
0
		public PolicySet(PolicyType type, Guid guid, IPolicyLanguageItem name, IPolicyStore policyStore, IPolicyCatalogue policyCatalogue, bool readOnly)
			: base(guid, name, readOnly)
		{
			m_type = type;
			m_policyStore = policyStore;
			m_masterCatalogue = policyCatalogue;
			(m_masterCatalogue as PolicyCatalogue).PolicySet = this;
		}
Example #5
0
        public ClaimsPolicyEvaluator(IPolicyStore store)
        {
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }

            this.store = store;
        }
Example #6
0
 public PolicyRule(IPolicyStore policyStore, IPolicy policy, IRule rule, bool readOnly)
     : base(rule, readOnly)
 {
     if (policyStore == null)
         throw new Workshare.Policy.Exceptions.ArgumentNullException("policyStore", "Input policy store is null", null);
     
     m_store = policyStore;
     SetPolicy(policy);
 }
Example #7
0
        public PolicyRule(IPolicyStore policyStore, IPolicy policy, Guid guid, string name, RuleStatus status, bool readOnly)
            : base(guid, name, status, readOnly)
        {
            if (policyStore == null)
                throw new Workshare.Policy.Exceptions.ArgumentNullException("policyStore", "Input policy store is null", null);

            m_store = policyStore;
            SetPolicy(policy);
        }
        public void ShouldRetriveScopeViaWCF()
        {
            ChannelFactory <IPolicyStore> factory = new ChannelFactory <IPolicyStore>(new BasicHttpBinding(), new EndpointAddress("http://localhost:3333/policystore"));
            IPolicyStore store  = factory.CreateChannel();
            var          scopes = store.RetrieveScopes();

            Assert.AreEqual(1, scopes.Count());
            Assert.AreEqual(2, scopes.ElementAt(0).Rules.Count());
        }
        public ClaimsPolicyEvaluator(IPolicyStore store)
        {
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }

            this.store = store;
        }
Example #10
0
 public ClientStore(
     IPolicyDbContext context,
     IPolicyStore policyStore,
     ILogger <ClientStore> logger
     )
 {
     _context     = context ?? throw new ArgumentNullException(nameof(context));
     _policyStore = policyStore;
     _logger      = logger;
 }
 public WindowsServerRestartPolicy(
     IHealthCheck healthCheck,
     IPolicyStore policyStore,
     FabricClient.RepairManagementClient repairMgmtClient,
     IConfigStore configStore,
     string configSectionName)
 {
     this.HealthCheck                = healthCheck;
     this.PolicyStore                = policyStore;
     this.repairManagementClient     = repairMgmtClient;
     this.currentChosenUpgradeDomain = EmptyUpgradeDomainValue;
     this.maxTimeRepairTaskActive    = WindowsServerRestartConstant.MaxTimeRepairTaskActiveDefault;
 }
        public WindowsServerRestartPolicyFactory(
            IHealthCheck healthCheck,
            IPolicyStore policyStore,
            FabricClient.RepairManagementClient repairMgmtClient,
            IConfigStore configStore,
            string configSectionName)
        {
            repairMgmtClient.ThrowIfNull("repairMgmtClient");

            this.policyStore            = policyStore;
            this.healthCheck            = healthCheck;
            this.repairManagementClient = repairMgmtClient;
            this.configStore            = configStore;
            this.configSectionName      = configSectionName;
        }
        public void ShouldAddRuleViaWCF()
        {
            ChannelFactory <IPolicyStore> factory = new ChannelFactory <IPolicyStore>(new BasicHttpBinding(), new EndpointAddress("http://localhost:3333/policystore"));
            IPolicyStore store = factory.CreateChannel();
            var          scope = store.RetrieveScopes().ElementAt(0);

            InputPolicyClaim  inputClaim  = new InputPolicyClaim(scope.Issuers.ElementAt(0), scope.ClaimTypes.ElementAt(0), "thevalue");
            OutputPolicyClaim outputClaim = new OutputPolicyClaim(scope.ClaimTypes.ElementAt(0), CopyFromConstants.InputValue);

            PolicyRule rule = new PolicyRule(AssertionsMatch.All, new[] { inputClaim }, outputClaim);

            store.AddPolicyRule(scope.Uri, rule);

            var updatedScope = store.RetrieveScopes().ElementAt(0);

            Assert.AreEqual(3, updatedScope.Rules.Count());
        }
Example #14
0
        public void Export(IPolicyStore policyStore)
        {
			if (!policyStore.CanWrite || policyStore.Writer == null)
				throw new System.ArgumentException("Incorrect policy store, unable to export policy to a  storage that doesn't support a writer", "store");

			IPolicyStoreWriter writer = policyStore.Writer;
            writer.WritePolicy(this);

			foreach (IPolicyRule rule in Rules)
			{
				writer.WriteRule(this, rule);
                
                if (rule.Conditions != null)
                    writer.WriteChildCollection(this, rule, rule.Name, rule.Conditions);

                if (rule.Channels != null)
                    writer.WriteChildCollection(this, rule, rule.Name, CollectionConverter.Convert<IPolicyChannel, IPolicyObject>(rule.Channels));
			}
			writer.Close();
        }
Example #15
0
        public MDIChild(IPolicyStore store, string filename)
        {
            InitializeComponent();

            this.rootNode.Text = Path.GetFileName(filename);
            this.rootNode.Object = store;

            this.Text = this.rootNode.Text;

            CustomGXNode policies = new CustomGXNode("Policies", store);
            policies.Style = DevComponents.Tree.NodeStyles.Blue;
            this.rootNode.Nodes.Add(policies);

            this.gxPolicyTree.AfterNodeSelect += new DevComponents.Tree.TreeGXNodeEventHandler(gxPolicyTree_AfterNodeSelect);

            foreach (IPolicy policy in store.Reader.Policies)
            {
                AddPolicyToTree(policies, policy);
            }

            this.rootNode.ExpandAll();
        }
 public ProfileController(ILogger <ProfileController> logger, IPolicyStore db)
 {
     _logger = logger;
     _db     = db;
 }
Example #17
0
 private void CreatePolicyStore()
 {
     m_xmlPolicyCatalogueStore = new XMLPolicyCatalogueStore();
     m_policyStore = new XmlStore(m_xmlPolicyCatalogueStore.PolicyCataloguesCache);
 }
Example #18
0
 public Policy(Guid guid, string name, IPolicyStore policyStore, bool readOnly)
     : base(guid, name, readOnly)
 {
     m_store = policyStore;
 }
Example #19
0
		public void Export(IPolicyStore policyStore)
		{
			if ((!policyStore.CanWrite) || (null == policyStore.Writer))
				throw new Workshare.Policy.Exceptions.PolicyException("Argument Exception! Incorrect policy store, unable to export policy to a  storage that doesn't support a writer");

			IPolicyStoreWriter writer = policyStore.Writer;
			writer.WritePolicySet(this);
			foreach (IPolicy policy in Policies)
			{
				writer.WritePolicy(this, policy);

				if (null != policy.Conditions)
					writer.WriteChildCollection(this, policy, policy.Name.Value, policy.Conditions);

				if (null != policy.Channels)
					writer.WriteChildCollection(this, policy, policy.Name.Value, CollectionConverter.Convert<IPolicyChannel, IPolicyObject>(policy.Channels));
			}
			writer.Close();
		}