Examples of PublicKeyStub


Examples of org.apache.harmony.security.tests.support.PublicKeyStub

     * 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);
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

     */
   
    public void testGetPublicKey() throws Exception {
        Identity i = new IdentityStub("testGetPublicKey");
        assertNull(i.getPublicKey());
        PublicKey pk = new PublicKeyStub("kkk", "Identity.testGetPublicKey", null);
        i.setPublicKey(pk);
        assertSame(pk, i.getPublicKey());       
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

    private KeyPair keyPair;

    protected void setUp() throws Exception {
        PrivateKeyStub privateKey = new PrivateKeyStub("privateAlgorithm",
                "privateFormat", new byte[] { 0x00, 0x05, 0x10 });
        PublicKeyStub publicKey = new PublicKeyStub("publicAlgorithm",
                "publicFormat", new byte[] { 0x01, 0x02, 0x12 });

        keyPair = new KeyPair(publicKey, privateKey);
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

    /*
     * verify  getIdentity(PublicKey) returns requested identity or null if not found
     */
    public void testGetIdentityPublicKey() throws Exception {
        //SystemScope ss = new SystemScope("SystemScope");
        java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);
        assertNull(ss.getIdentity(kkk));
        java.security.Identity aaa = new IdentityScopeStub("aaa");
        aaa.setPublicKey(kkk);
        ss.addIdentity(aaa);
       
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

     * verify that only one identity with given name or public key can be added
     * i.e. KeyManagementException is thrown
     */
    public void testAddIdentity() throws Exception {
//        SystemScope ss = new SystemScope("SystemScope");
        java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);       
        java.security.Identity aaa = new IdentityScopeStub("aaa");
        aaa.setPublicKey(kkk);
        ss.addIdentity(aaa);
       
        java.security.Identity bbb = new IdentityScopeStub("aaa");
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

        assertEquals("[Signer]testToString1", s1.toString());

        Signer s2 = new SignerStub("testToString2", IdentityScope.getSystemScope());
        s2.toString();

        KeyPair kp = new KeyPair(new PublicKeyStub("public", "SignerTest.testToString", null), new PrivateKeyStub("private", "SignerTest.testToString", null));
        s1.setKeyPair(kp);
        s1.toString();

        s2.setKeyPair(kp);
        s2.toString();
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

     * verify Signer.getPrivateKey() returns null or private key
     */
    public void testGetPrivateKey() throws Exception {
        byte [] privateKeyData = { 1, 2, 3, 4, 5}
        PrivateKeyStub privateKey = new PrivateKeyStub("private", "fff", privateKeyData);
        PublicKeyStub publicKey = new PublicKeyStub("public", "fff", null);
        KeyPair kp = new KeyPair(publicKey, privateKey);
       
        Signer s = new SignerStub("sss5");
       
        assertNull(s.getPrivateKey());
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

        MySecurityManager sm = new MySecurityManager();
        sm.denied.add(new SecurityPermission("getSignerPrivateKey"));
        System.setSecurityManager(sm);
        try {
            Signer s = new SignerStub("sss6");
            s.setKeyPair(new KeyPair(new PublicKeyStub("public", "fff", null), new PrivateKeyStub("private", "fff", null)));
            try {
                s.getPrivateKey();
                fail("SecurityException should be thrown");
            } catch (SecurityException ok) {}           
        } finally {
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

        sm.denied.add(new SecurityPermission("setSignerKeyPair"));
        System.setSecurityManager(sm);
        try {
            Signer s = new SignerStub("sss7");
            try {
                s.setKeyPair(new KeyPair(new PublicKeyStub("public", "fff",
                        null), new PrivateKeyStub("private", "fff", null)));
                fail("SecurityException should be thrown");
            } catch (SecurityException ok) {
            }
        } finally {
View Full Code Here

Examples of org.apache.harmony.security.tests.support.PublicKeyStub

    private KeyPair keyPair;

    protected void setUp() throws Exception {
        PrivateKeyStub privateKey = new PrivateKeyStub("privateAlgorithm",
                "privateFormat", new byte[] { 0x00, 0x05, 0x10 });
        PublicKeyStub publicKey = new PublicKeyStub("publicAlgorithm",
                "publicFormat", new byte[] { 0x01, 0x02, 0x12 });

        keyPair = new KeyPair(publicKey, privateKey);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.