當前位置: 首頁>>代碼示例>>Java>>正文


Java CertificateStub類代碼示例

本文整理匯總了Java中org.apache.harmony.security.tests.support.CertificateStub的典型用法代碼示例。如果您正苦於以下問題:Java CertificateStub類的具體用法?Java CertificateStub怎麽用?Java CertificateStub使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CertificateStub類屬於org.apache.harmony.security.tests.support包,在下文中一共展示了CertificateStub類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testAddCertificate1

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify addCertificate(Certificate certificate) adds a certificate for this identity.
 * If the identity has a public key, the public key in the certificate must be the same
 *
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "addCertificate",
    args = {java.security.Certificate.class}
)
public void testAddCertificate1() throws Exception {
    Identity i = new IdentityStub("iii");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", new byte[]{1,2,3,4,5});
    i.setPublicKey(pk1);
    // try with the same key
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    i.addCertificate(c1);
    assertSame(c1, i.certificates()[0]);
    // try Certificate with different key
    try {
        i.addCertificate(new CertificateStub("ccc", null, null, new PublicKeyStub("k2", "fff", new byte[]{6,7,8,9,0})));
        fail("KeyManagementException should be thrown");
    } catch (KeyManagementException ok) {}
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:26,代碼來源:IdentityTest.java

示例2: testAddCertificate2

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify addCertificate(Certificate certificate) adds a certificate for this identity.
 * if the identity does not have a public key, the identity's public key is set to be that specified in the certificate.
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "addCertificate",
    args = {java.security.Certificate.class}
)
public void testAddCertificate2() throws Exception {
    Identity i = new IdentityStub("iii");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    i.addCertificate(c1);
    assertSame(c1, i.certificates()[0]);
    assertSame(pk1, i.getPublicKey());

}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:20,代碼來源:IdentityTest.java

示例3: testCertificates

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify certificates() returns a copy of all certificates for this identity
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "certificates",
    args = {}
)
public void testCertificates() throws Exception {
    Identity i = new IdentityStub("iii");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
    i.addCertificate(c1);
    i.addCertificate(c2);
    java.security.Certificate[] s = i.certificates();
    assertEquals(2, s.length);
    assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
    assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
    s[0] = null;
    s[1] = null;
    // check that the copy was modified
    s = i.certificates();
    assertEquals(2, s.length);
    assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
    assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:29,代碼來源:IdentityTest.java

示例4: testSetPublicKey4

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 *
 * verify Identity.setPublicKey()  removes old key and all identity's certificates
 *
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "setPublicKey",
    args = {java.security.PublicKey.class}
)
public void testSetPublicKey4() throws Exception {
    Identity i = new IdentityStub("testSetPublicKey4");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "Identity.testSetPublicKey4", null);
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
    i.addCertificate(c1);
    i.addCertificate(c2);
    assertEquals(2, i.certificates().length);
    assertSame(pk1, i.getPublicKey());

    PublicKeyStub pk2 = new PublicKeyStub("zzz", "Identity.testSetPublicKey4", null);
    i.setPublicKey(pk2);
    assertSame(pk2, i.getPublicKey());
    assertEquals(0, i.certificates().length);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:27,代碼來源:IdentityTest.java

示例5: testRemoveCertificate2

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify removeCertificate(Certificate certificate) throws SecurityException if permission is denied
 */
public void testRemoveCertificate2() throws Exception{
    MySecurityManager sm = new MySecurityManager();
    sm.denied.add(new SecurityPermission("removeIdentityCertificate"));
    Identity i = new IdentityStub("iii");
    i.addCertificate(new CertificateStub("ccc", null, null, null));
    System.setSecurityManager(sm);
    try {
        i.removeCertificate(i.certificates()[0]);
        fail("SecurityException should be thrown");
    } catch (SecurityException ok) {
    } finally {
        System.setSecurityManager(null);
    }
    
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:19,代碼來源:IdentityTest.java

示例6: testCertificates

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify certificates() returns a copy of all certificates for this identity
 */
public void testCertificates() throws Exception {
    Identity i = new IdentityStub("iii");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);        
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
    i.addCertificate(c1);
    i.addCertificate(c2);
    Certificate[] s = i.certificates();
    assertEquals(2, s.length);
    assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
    assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
    s[0] = null;
    s[1] = null;
    // check that the copy was modified
    s = i.certificates();
    assertEquals(2, s.length);
    assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
    assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:IdentityTest.java

示例7: testSetPublicKey4

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * 
 * verify Identity.setPublicKey()  removes old key and all identity's certificates
 *
 */
public void testSetPublicKey4() throws Exception {
    Identity i = new IdentityStub("testSetPublicKey4");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "Identity.testSetPublicKey4", null);        
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
    i.addCertificate(c1);
    i.addCertificate(c2);
    assertEquals(2, i.certificates().length);
    assertSame(pk1, i.getPublicKey());
    
    PublicKeyStub pk2 = new PublicKeyStub("zzz", "Identity.testSetPublicKey4", null);    
    i.setPublicKey(pk2);
    assertSame(pk2, i.getPublicKey());
    assertEquals(0, i.certificates().length);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:IdentityTest.java

示例8: testAddCertificate1

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify addCertificate(Certificate certificate) adds a certificate for this identity.
 * If the identity has a public key, the public key in the certificate must be the same
 *  
 */
public void testAddCertificate1() throws Exception {
    Identity i = new IdentityStub("iii");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", new byte[]{1,2,3,4,5});
    i.setPublicKey(pk1);
    // try with the same key
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    i.addCertificate(c1);
    assertSame(c1, i.certificates()[0]);
    // try Certificate with different key
    try {
        i.addCertificate(new CertificateStub("ccc", null, null, new PublicKeyStub("k2", "fff", new byte[]{6,7,8,9,0})));
        fail("KeyManagementException should be thrown");
    } catch (KeyManagementException ok) {}        
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:20,代碼來源:IdentityTest.java

示例9: testAddCertificate2

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify addCertificate(Certificate certificate) adds a certificate for this identity.
 * if the identity does not have a public key, the identity's public key is set to be that specified in the certificate.
 */
public void testAddCertificate2() throws Exception {
    Identity i = new IdentityStub("iii");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);        
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    i.addCertificate(c1);
    assertSame(c1, i.certificates()[0]);
    assertSame(pk1, i.getPublicKey());
    	
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:14,代碼來源:IdentityTest.java

示例10: testAddCertificate3

import org.apache.harmony.security.tests.support.CertificateStub; //導入依賴的package包/類
/**
 * verify addCertificate(Certificate certificate) throws SecurityException is permission is denied
 */
public void testAddCertificate3() throws Exception {
    MySecurityManager sm = new MySecurityManager();
    sm.denied.add(new SecurityPermission("addIdentityCertificate"));
    System.setSecurityManager(sm);
    try {
        new IdentityStub("iii").addCertificate(new CertificateStub("ccc", null, null, null));
        fail("SecurityException should be thrown");
    } catch (SecurityException ok) {
    } finally {
        System.setSecurityManager(null);
    }        
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:16,代碼來源:IdentityTest.java


注:本文中的org.apache.harmony.security.tests.support.CertificateStub類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。