public override BoostInfoTree findMatchingRule(
					ConfigPolicyManager policyManager, Name objName,
					String matchType)
            {
                return policyManager.findMatchingRule(objName, matchType);
            }
 /// <summary>
 /// Call friend.setConfigPolicyManagerFriendAccess to pass an instance of
 /// a FriendAccess class to allow a friend class to call private methods.
 /// </summary>
 ///
 /// <param name="friend">Therefore, only a friend class gets an implementation of FriendAccess.</param>
 public static void setFriendAccess(ConfigPolicyManager.Friend  friend)
 {
     if (friend
                     .GetType().FullName
             .equals("src.net.named_data.jndn.tests.integration_tests.TestPolicyManager")
             || friend
                                     .GetType().FullName
                     .equals("src.net.named_data.jndn.tests.integration_tests.TestVerificationRules")) {
         friend.setConfigPolicyManagerFriendAccess(new ConfigPolicyManager.FriendAccessImpl ());
     }
 }
            public OnCertificateDownloadCompleteForInterest(
						ConfigPolicyManager manager, Interest originalInterest, int stepCount,
						OnVerifiedInterest onVerified,
						OnInterestValidationFailed onValidationFailed,
						WireFormat wireFormat)
            {
                outer_ConfigPolicyManager = manager;
                    originalInterest_ = originalInterest;
                    stepCount_ = stepCount;
                    onVerified_ = onVerified;
                    onValidationFailed_ = onValidationFailed;
                    wireFormat_ = wireFormat;
            }
            public override bool checkSignatureMatch(ConfigPolicyManager policyManager,
					Name signatureName, Name objectName, BoostInfoTree rule,
					String[] failureReason)
            {
                return policyManager.checkSignatureMatch(signatureName, objectName,
                        rule, failureReason);
            }
            public abstract BoostInfoTree findMatchingRule(
					ConfigPolicyManager policyManager, Name objName,
					String matchType);
            public OnCertificateDownloadComplete(ConfigPolicyManager manager, Data originalData, int stepCount,
						OnVerified onVerified, OnDataValidationFailed onValidationFailed)
            {
                outer_ConfigPolicyManager = manager;
                    originalData_ = originalData;
                    stepCount_ = stepCount;
                    onVerified_ = onVerified;
                    onValidationFailed_ = onValidationFailed;
            }
            public abstract bool checkSignatureMatch(
					ConfigPolicyManager policyManager, Name signatureName,
					Name objectName, BoostInfoTree rule, String[] failureReason);
        public void testSimpleRegex()
        {
            ConfigPolicyManager policyManager = new ConfigPolicyManager(System.IO.Path.GetFullPath(new FileInfo(System.IO.Path.Combine(policyConfigDirectory.FullName,"regex_ruleset.conf")).Name));

            Name dataName1 = new Name("/SecurityTestSecRule/Basic");
            Name dataName2 = new Name("/SecurityTestSecRule/Basic/More");
            Name dataName3 = new Name("/SecurityTestSecRule/");
            Name dataName4 = new Name("/SecurityTestSecRule/Other/TestData");
            Name dataName5 = new Name("/Basic/Data");

            BoostInfoTree matchedRule1 = friendAccess.findMatchingRule(
                    policyManager, dataName1, "data");
            BoostInfoTree matchedRule2 = friendAccess.findMatchingRule(
                    policyManager, dataName2, "data");
            BoostInfoTree matchedRule3 = friendAccess.findMatchingRule(
                    policyManager, dataName3, "data");
            BoostInfoTree matchedRule4 = friendAccess.findMatchingRule(
                    policyManager, dataName4, "data");
            BoostInfoTree matchedRule5 = friendAccess.findMatchingRule(
                    policyManager, dataName5, "data");

            AssertNotNull(matchedRule1);
            AssertNull(matchedRule2);
            AssertNotNull(matchedRule3);
            AssertNotSame("Rule regex matched extra components", matchedRule3,
                    matchedRule1);
            AssertNotNull(matchedRule4);
            AssertNotSame("Rule regex matched with missing component",
                    matchedRule4, matchedRule1);

            AssertNull(matchedRule5);
        }
        public void testNameRelation()
        {
            ConfigPolicyManager policyManagerPrefix = new ConfigPolicyManager(
                    System.IO.Path.GetFullPath(new FileInfo(System.IO.Path.Combine(policyConfigDirectory.FullName,"relation_ruleset_prefix.conf")).Name));
            ConfigPolicyManager policyManagerStrict = new ConfigPolicyManager(
                    System.IO.Path.GetFullPath(new FileInfo(System.IO.Path.Combine(policyConfigDirectory.FullName,"relation_ruleset_strict.conf")).Name));
            ConfigPolicyManager policyManagerEqual = new ConfigPolicyManager(
                    System.IO.Path.GetFullPath(new FileInfo(System.IO.Path.Combine(policyConfigDirectory.FullName,"relation_ruleset_equal.conf")).Name));

            Name dataName = new Name("/TestRule1");
            AssertNotNull("Prefix relation should match prefix name",
                    friendAccess.findMatchingRule(policyManagerPrefix, dataName,
                            "data"));
            AssertNotNull("Equal relation should match prefix name",
                    friendAccess.findMatchingRule(policyManagerEqual, dataName,
                            "data"));
            AssertNull("Strict-prefix relation should not match prefix name",
                    friendAccess.findMatchingRule(policyManagerStrict, dataName,
                            "data"));

            dataName = new Name("/TestRule1/hi");
            AssertNotNull("Prefix relation should match longer name",
                    friendAccess.findMatchingRule(policyManagerPrefix, dataName,
                            "data"));
            AssertNull("Equal relation should not match longer name",
                    friendAccess.findMatchingRule(policyManagerEqual, dataName,
                            "data"));
            AssertNotNull("Strict-prefix relation should match longer name",
                    friendAccess.findMatchingRule(policyManagerStrict, dataName,
                            "data"));

            dataName = new Name("/Bad/TestRule1/");
            AssertNull("Prefix relation should not match inner components",
                    friendAccess.findMatchingRule(policyManagerPrefix, dataName,
                            "data"));
            AssertNull("Equal relation should not match inner components",
                    friendAccess.findMatchingRule(policyManagerEqual, dataName,
                            "data"));
            AssertNull("Strict-prefix relation should  not match inner components",
                    friendAccess.findMatchingRule(policyManagerStrict, dataName,
                            "data"));
        }
        public void testHyperRelation()
        {
            ConfigPolicyManager policyManager = new ConfigPolicyManager(System.IO.Path.GetFullPath(new FileInfo(System.IO.Path.Combine(policyConfigDirectory.FullName,"/hyperrelation_ruleset.conf")).Name));

            Name dataName = new Name("/SecurityTestSecRule/Basic/Longer/Data2");
            Data data1 = new Data(dataName);
            Data data2 = new Data(dataName);

            BoostInfoTree matchedRule = friendAccess.findMatchingRule(
                    policyManager, dataName, "data");
            keyChain.sign(data1, defaultCertName);
            keyChain.sign(data2, shortCertName);

            Name signatureName1 = ((Sha256WithRsaSignature) data1.getSignature())
                    .getKeyLocator().getKeyName();
            Name signatureName2 = ((Sha256WithRsaSignature) data2.getSignature())
                    .getKeyLocator().getKeyName();

            String[] failureReason = new String[] { "unknown" };
            AssertTrue(friendAccess.checkSignatureMatch(policyManager,
                    signatureName1, dataName, matchedRule, failureReason));
            AssertFalse(friendAccess.checkSignatureMatch(policyManager,
                    signatureName2, dataName, matchedRule, failureReason));

            dataName = new Name("/SecurityTestSecRule/Basic/Other/Data1");
            data1 = new Data(dataName);
            data2 = new Data(dataName);

            matchedRule = friendAccess.findMatchingRule(policyManager, dataName,
                    "data");
            keyChain.sign(data1, defaultCertName);
            keyChain.sign(data2, shortCertName);

            signatureName1 = ((Sha256WithRsaSignature) data1.getSignature())
                    .getKeyLocator().getKeyName();
            signatureName2 = ((Sha256WithRsaSignature) data2.getSignature())
                    .getKeyLocator().getKeyName();

            AssertFalse(friendAccess.checkSignatureMatch(policyManager,
                    signatureName1, dataName, matchedRule, failureReason));
            AssertTrue(friendAccess.checkSignatureMatch(policyManager,
                    signatureName2, dataName, matchedRule, failureReason));
        }
        public virtual void setConfigPolicyManagerFriendAccess(
				ConfigPolicyManager.FriendAccess friendAccess)
        {
            this.friendAccess = friendAccess;
        }