예제 #1
0
        public void setUp()
        {
            // Don't show INFO log messages.
            ILOG.J2CsMapping.Util.Logging.Logger.getLogger("").setLevel(ILOG.J2CsMapping.Util.Logging.Level.WARNING);

            FileInfo policyConfigDirectory = net.named_data.jndn.tests.integration_tests.IntegrationTestsCommon
                    .getPolicyConfigDirectory();

            databaseFilePath = new FileInfo(System.IO.Path.Combine(policyConfigDirectory.FullName,"test-public-info.db"));
            databaseFilePath.delete();

            identityStorage = new BasicIdentityStorage(System.IO.Path.GetFullPath(databaseFilePath.Name));
            identityManager = new IdentityManager(identityStorage,
                    new FilePrivateKeyStorage());
            policyManager = new SelfVerifyPolicyManager(identityStorage);
            keyChain = new KeyChain(identityManager, policyManager);
        }
예제 #2
0
 /// <summary>
 /// Create a new KeyChain with the the default IdentityManager and a
 /// NoVerifyPolicyManager.
 /// </summary>
 ///
 public KeyChain()
 {
     this.face_ = null;
     identityManager_ = new IdentityManager();
     policyManager_ = new NoVerifyPolicyManager();
 }
예제 #3
0
        public void testPrepareUnsignedCertificate()
        {
            MemoryIdentityStorage identityStorage = new MemoryIdentityStorage();
            MemoryPrivateKeyStorage privateKeyStorage = new MemoryPrivateKeyStorage();
            IdentityManager identityManager = new IdentityManager(identityStorage,
                    privateKeyStorage);
            Name keyName = new Name("/test/ksk-1457560485494");
            identityStorage.addKey(keyName, net.named_data.jndn.security.KeyType.RSA,
                    new Blob(PUBLIC_KEY, false));

            ArrayList subjectDescriptions = new ArrayList();
            ILOG.J2CsMapping.Collections.Collections.Add(subjectDescriptions,new CertificateSubjectDescription(TEST_OID,
                            "TEST NAME"));
            IdentityCertificate newCertificate = identityManager
                    .prepareUnsignedIdentityCertificate(keyName,
                            keyName.getPrefix(1), toyCertNotBefore,
                            toyCertNotAfter, subjectDescriptions);

            // Update the generated certificate version to equal the one in toyCert.
            newCertificate.setName(new Name(newCertificate.getName().getPrefix(-1)
                    .append(toyCert.getName().get(-1))));

            // Make a copy to test encoding.
            IdentityCertificate certificateCopy = new IdentityCertificate(
                    newCertificate);
            Assert.AssertEquals(
                    "Prepared unsigned certificate dump does not have the expected format",
                    "" + toyCert, "" + certificateCopy);
        }
예제 #4
0
 /// <summary>
 /// Create a new KeyChain with the given IdentityManager and PolicyManager.
 /// </summary>
 ///
 /// <param name="identityManager">An object of a subclass of IdentityManager.</param>
 /// <param name="policyManager">An object of a subclass of PolicyManager.</param>
 public KeyChain(IdentityManager identityManager, PolicyManager policyManager)
 {
     this.face_ = null;
     identityManager_ = identityManager;
     policyManager_ = policyManager;
 }
예제 #5
0
        public void setUp()
        {
            // Don't show INFO log messages.
            ILOG.J2CsMapping.Util.Logging.Logger.getLogger("").setLevel(ILOG.J2CsMapping.Util.Logging.Level.WARNING);

            policyConfigDirectory_ = net.named_data.jndn.tests.integration_tests.IntegrationTestsCommon
                    .getPolicyConfigDirectory();

            testCertFile_ = new FileInfo(System.IO.Path.Combine(new FileInfo(System.IO.Path.Combine(policyConfigDirectory_.FullName,"certs")).FullName,"test.cert"));

            identityStorage_ = new MemoryIdentityStorage();
            privateKeyStorage_ = new MemoryPrivateKeyStorage();
            identityManager_ = new IdentityManager(identityStorage_,
                    privateKeyStorage_);
            policyManager_ = new ConfigPolicyManager(System.IO.Path.GetFullPath(new FileInfo(System.IO.Path.Combine(policyConfigDirectory_.FullName,"simple_rules.conf")).Name));

            identityName_ = new Name("/TestConfigPolicyManager/temp");
            // To match the anchor cert.
            Name keyName = new Name(identityName_).append("ksk-1416010123");
            identityStorage_.addKey(keyName, net.named_data.jndn.security.KeyType.RSA, new Blob(
                    DEFAULT_RSA_PUBLIC_KEY_DER, false));
            privateKeyStorage_.setKeyPairForKeyName(keyName, net.named_data.jndn.security.KeyType.RSA,
                    DEFAULT_RSA_PUBLIC_KEY_DER, DEFAULT_RSA_PRIVATE_KEY_DER);

            IdentityCertificate cert = identityManager_.selfSign(keyName);
            identityStorage_.setDefaultKeyNameForIdentity(keyName);
            identityManager_.addCertificateAsDefault(cert);

            face_ = new Face("localhost");
            keyChain_ = new KeyChain(identityManager_, policyManager_);
            keyName_ = keyName;

            net.named_data.jndn.security.policy.ConfigPolicyManager.setFriendAccess(this);
        }