Search in sources :

Example 1 with PrivateKeyStub

use of org.apache.harmony.security.tests.support.PrivateKeyStub in project robovm by robovm.

the class SignerTest method testGetPrivateKey.

/**
     * 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());
    s.setKeyPair(kp);
    assertSame(privateKey, s.getPrivateKey());
}
Also used : Signer(java.security.Signer) KeyPair(java.security.KeyPair) PrivateKeyStub(org.apache.harmony.security.tests.support.PrivateKeyStub) SignerStub(org.apache.harmony.security.tests.support.SignerStub) PublicKeyStub(org.apache.harmony.security.tests.support.PublicKeyStub)

Example 2 with PrivateKeyStub

use of org.apache.harmony.security.tests.support.PrivateKeyStub in project robovm by robovm.

the class SignerTest method test_toString.

/**
     * java.security.Signer#toString()
     */
public void test_toString() throws Exception {
    Signer s1 = new SignerStub("testToString1");
    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();
}
Also used : Signer(java.security.Signer) KeyPair(java.security.KeyPair) PrivateKeyStub(org.apache.harmony.security.tests.support.PrivateKeyStub) SignerStub(org.apache.harmony.security.tests.support.SignerStub) PublicKeyStub(org.apache.harmony.security.tests.support.PublicKeyStub)

Aggregations

KeyPair (java.security.KeyPair)2 Signer (java.security.Signer)2 PrivateKeyStub (org.apache.harmony.security.tests.support.PrivateKeyStub)2 PublicKeyStub (org.apache.harmony.security.tests.support.PublicKeyStub)2 SignerStub (org.apache.harmony.security.tests.support.SignerStub)2