Пример #1
0
        public void testTpmLocator()
        {
            /* foreach */
            foreach (PibDataFixture2 fixture  in  pibImpls)
            {
                PibImpl pib = fixture.pib;

                // Basic getting and setting
                try {
                    pib.getTpmLocator();
                } catch (Exception ex) {
                    Assert.Fail("Unexpected exception: " + ex.Message);
                }

                try {
                    pib.setTpmLocator("tpmLocator");
                } catch (Exception ex_0) {
                    Assert.Fail("Unexpected exception: " + ex_0.Message);
                }
                Assert.AssertEquals(pib.getTpmLocator(), "tpmLocator");

                // Add a certificate, and do not change the TPM locator.
                pib.addCertificate(fixture.id1Key1Cert1);
                Assert.AssertTrue(pib.hasIdentity(fixture.id1));
                Assert.AssertTrue(pib.hasKey(fixture.id1Key1Name));
                Assert.AssertTrue(pib.hasCertificate(fixture.id1Key1Cert1.getName()));

                // Set the TPM locator to the same value. Nothing should change.
                pib.setTpmLocator("tpmLocator");
                Assert.AssertTrue(pib.hasIdentity(fixture.id1));
                Assert.AssertTrue(pib.hasKey(fixture.id1Key1Name));
                Assert.AssertTrue(pib.hasCertificate(fixture.id1Key1Cert1.getName()));

                // Change the TPM locator. (The contents of the PIB should not change.)
                pib.setTpmLocator("newTpmLocator");
                Assert.AssertTrue(pib.hasIdentity(fixture.id1));
                Assert.AssertTrue(pib.hasKey(fixture.id1Key1Name));
                Assert.AssertTrue(pib.hasCertificate(fixture.id1Key1Cert1.getName()));
            }
        }
Пример #2
0
        public void testClearIdentities()
        {
            /* foreach */
            foreach (PibDataFixture2 fixture  in  pibImpls)
            {
                PibImpl pib = fixture.pib;

                pib.setTpmLocator("tpmLocator");

                // Add id, key, and cert.
                pib.addCertificate(fixture.id1Key1Cert1);
                Assert.AssertTrue(pib.hasIdentity(fixture.id1));
                Assert.AssertTrue(pib.hasKey(fixture.id1Key1Name));
                Assert.AssertTrue(pib.hasCertificate(fixture.id1Key1Cert1.getName()));

                // Clear identities.
                pib.clearIdentities();
                Assert.AssertEquals(0, pib.getIdentities().Count);
                Assert.AssertEquals(0, pib.getKeysOfIdentity(fixture.id1).Count);
                Assert.AssertEquals(0, pib.getCertificatesOfKey(fixture.id1Key1Name).Count);
                Assert.AssertEquals("tpmLocator", pib.getTpmLocator());
            }
        }