/// <summary>
 /// Creates an instance of {@code PKIXCertPathBuilderResult}
 /// containing the specified parameters.
 /// </summary>
 /// <param name="certPath"> the validated {@code CertPath} </param>
 /// <param name="trustAnchor"> a {@code TrustAnchor} describing the CA that
 /// served as a trust anchor for the certification path </param>
 /// <param name="policyTree"> the immutable valid policy tree, or {@code null}
 /// if there are no valid policies </param>
 /// <param name="subjectPublicKey"> the public key of the subject </param>
 /// <exception cref="NullPointerException"> if the {@code certPath},
 /// {@code trustAnchor} or {@code subjectPublicKey} parameters
 /// are {@code null} </exception>
 public PKIXCertPathBuilderResult(CertPath certPath, TrustAnchor trustAnchor, PolicyNode policyTree, PublicKey subjectPublicKey) : base(trustAnchor, policyTree, subjectPublicKey)
 {
     if (certPath == null)
     {
         throw new NullPointerException("certPath must be non-null");
     }
     this.CertPath_Renamed = certPath;
 }
Example #2
0
        public void PolicyIsAddedWithSensibleDefaultName()
        {
            AddPolicyCommand addPolicyCommand = new AddPolicyCommand(ServiceProvider);

            addPolicyCommand.Execute(ApplicationNode);

            PolicyNode policyNode = ApplicationNode.Hierarchy.FindNodeByType(typeof(PolicyNode)) as PolicyNode;

            Assert.IsNotNull(policyNode);
            Assert.AreEqual("Policy", policyNode.Name);
        }
Example #3
0
        public void AddPolicyCommandAddsCallHandlersContainer()
        {
            AddPolicyCommand addPolicyCommand = new AddPolicyCommand(ServiceProvider);

            addPolicyCommand.Execute(ApplicationNode);

            PolicyNode policyNode = ApplicationNode.Hierarchy.FindNodeByType(typeof(PolicyNode)) as PolicyNode;
            CallHandlersCollectionNode handlersContainer = ApplicationNode.Hierarchy.FindNodeByType(typeof(CallHandlersCollectionNode)) as CallHandlersCollectionNode;

            Assert.IsNotNull(policyNode);
            Assert.IsNotNull(handlersContainer);
            Assert.AreEqual(policyNode, handlersContainer.Parent);
        }
Example #4
0
        public void AddPolicyCommandAddsMatchingRuleContainerNode()
        {
            AddPolicyCommand addPolicyCommand = new AddPolicyCommand(ServiceProvider);

            addPolicyCommand.Execute(ApplicationNode);

            PolicyNode policyNode = ApplicationNode.Hierarchy.FindNodeByType(typeof(PolicyNode)) as PolicyNode;
            MatchingRuleCollectionNode ruleContainer = ApplicationNode.Hierarchy.FindNodeByType(typeof(MatchingRuleCollectionNode)) as MatchingRuleCollectionNode;

            Assert.IsNotNull(policyNode);
            Assert.IsNotNull(ruleContainer);
            Assert.AreEqual(policyNode, ruleContainer.Parent);
        }
 /// <summary>
 /// Creates an instance of {@code PKIXCertPathValidatorResult}
 /// containing the specified parameters.
 /// </summary>
 /// <param name="trustAnchor"> a {@code TrustAnchor} describing the CA that
 /// served as a trust anchor for the certification path </param>
 /// <param name="policyTree"> the immutable valid policy tree, or {@code null}
 /// if there are no valid policies </param>
 /// <param name="subjectPublicKey"> the public key of the subject </param>
 /// <exception cref="NullPointerException"> if the {@code subjectPublicKey} or
 /// {@code trustAnchor} parameters are {@code null} </exception>
 public PKIXCertPathValidatorResult(TrustAnchor trustAnchor, PolicyNode policyTree, PublicKey subjectPublicKey)
 {
     if (subjectPublicKey == null)
     {
         throw new NullPointerException("subjectPublicKey must be non-null");
     }
     if (trustAnchor == null)
     {
         throw new NullPointerException("trustAnchor must be non-null");
     }
     this.TrustAnchor_Renamed = trustAnchor;
     this.PolicyTree_Renamed  = policyTree;
     this.SubjectPublicKey    = subjectPublicKey;
 }
Example #6
0
        public void ShouldBeAbleToMoveHandlers()
        {
            ApplicationNode.Hierarchy.Load();
            ApplicationNode.Hierarchy.Open();
            ConfigurationNode policyInjectionNode =
                ApplicationNode.Hierarchy.FindNodeByType(typeof(PolicyInjectionSettingsNode));
            ConfigurationNode policyCollectionNode =
                policyInjectionNode.Hierarchy.FindNodeByType(typeof(PolicyCollectionNode));

            PolicyNode policy1Node = (PolicyNode)policyCollectionNode.Nodes[0];

            CallHandlersCollectionNode handlersNode =
                (CallHandlersCollectionNode)
                policy1Node.Hierarchy.FindNodeByType(typeof(CallHandlersCollectionNode));
            ExceptionCallHandlerNode     exceptionNode = (ExceptionCallHandlerNode)handlersNode.Nodes[3];
            AuthorizationCallHandlerNode authNode      =
                (AuthorizationCallHandlerNode)handlersNode.Nodes[0];

            ConfigurationNode logNode =
                handlersNode.Hierarchy.FindNodeByType(typeof(LogCallHandlerNode));
            ConfigurationNode validationNode =
                handlersNode.Hierarchy.FindNodeByType(typeof(ValidationCallHandlerNode));

            handlersNode.MoveBefore(exceptionNode, authNode);
            handlersNode.MoveAfter(logNode, validationNode);

            IConfigurationSource configSource = ApplicationNode.Hierarchy.BuildConfigurationSource();

            PolicyInjectionSettings settings =
                (PolicyInjectionSettings)
                configSource.GetSection(PolicyInjectionSettings.SectionName);

            PolicyData policy1Data = settings.Policies.Get(0);

            Assert.IsTrue(policy1Data.Handlers.Get(0) is ExceptionCallHandlerData);
            Assert.IsTrue(policy1Data.Handlers.Get(1) is AuthorizationCallHandlerData);
            Assert.IsTrue(policy1Data.Handlers.Get(policy1Data.Handlers.Count - 2) is ValidationCallHandlerData);
            Assert.IsTrue(policy1Data.Handlers.Get(policy1Data.Handlers.Count - 1) is LogCallHandlerData);
        }
Example #7
0
        public void ShouldBeAbleToMovePolicies()
        {
            ApplicationNode.Hierarchy.Load();
            ApplicationNode.Hierarchy.Open();
            ConfigurationNode policyInjectionNode =
                ApplicationNode.Hierarchy.FindNodeByType(typeof(PolicyInjectionSettingsNode));

            Assert.IsNotNull(policyInjectionNode);
            Assert.IsTrue(policyInjectionNode is PolicyInjectionSettingsNode);
            Assert.AreEqual(2, policyInjectionNode.Nodes.Count);

            ConfigurationNode policyCollectionNode =
                policyInjectionNode.Hierarchy.FindNodeByType(typeof(PolicyCollectionNode));

            Assert.IsNotNull(policyCollectionNode);
            PolicyNode policy1Node = (PolicyNode)policyCollectionNode.Nodes[0];
            PolicyNode policy2Node = (PolicyNode)policyCollectionNode.Nodes[1];

            Assert.AreEqual("Policy One", policy1Node.Name);
            Assert.AreEqual("Policy Two", policy2Node.Name);

            policyCollectionNode.MoveAfter(policy1Node, policy2Node);

            Assert.AreSame(policy2Node, policyCollectionNode.Nodes[0]);
            Assert.AreSame(policy1Node, policyCollectionNode.Nodes[1]);

            IConfigurationSource configSource = ApplicationNode.Hierarchy.BuildConfigurationSource();

            Assert.IsNotNull(configSource);
            PolicyInjectionSettings settings =
                (PolicyInjectionSettings)
                configSource.GetSection(PolicyInjectionSettings.SectionName);

            Assert.AreEqual(2, settings.Policies.Count);
            Assert.AreEqual("Policy Two", settings.Policies.Get(0).Name);
            Assert.AreEqual("Policy One", settings.Policies.Get(1).Name);
        }