Search in sources :

Example 1 with SignerStub

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

the class SignerTest method testSigner.

/**
     * verify Signer() creates instance
     */
public void testSigner() {
    Signer s = new SignerStub();
    assertNotNull(s);
    //assertNull(s.getName(), s.getName());
    assertNull(s.getPrivateKey());
}
Also used : Signer(java.security.Signer) SignerStub(org.apache.harmony.security.tests.support.SignerStub)

Example 2 with SignerStub

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

the class SignerTest method test_setKeyPairLjava_security_KeyPair.

/**
     * java.security.Signer#setKeyPair(java.security.KeyPair)
     */
public void test_setKeyPairLjava_security_KeyPair() throws Exception {
    // test: NullPointerException if pair is null
    try {
        new SignerStub("name").setKeyPair(null);
        fail("No expected NullPointerException");
    } catch (NullPointerException e) {
    }
    try {
        KeyPair kp = new KeyPair(null, null);
        SignerStub s = new SignerStub("name");
        s.setKeyPair(kp);
    } catch (InvalidParameterException e) {
    // ok
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) KeyPair(java.security.KeyPair) SignerStub(org.apache.harmony.security.tests.support.SignerStub)

Example 3 with SignerStub

use of org.apache.harmony.security.tests.support.SignerStub 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 4 with SignerStub

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

the class SignerTest method testSignerString.

/**
     * verify Signer(String) creates instance
     */
public void testSignerString() throws Exception {
    Signer s = new SignerStub("sss3");
    assertNotNull(s);
    assertEquals("sss3", s.getName());
    assertNull(s.getPrivateKey());
    Signer s2 = new SignerStub(null);
    assertNull(s2.getName());
}
Also used : Signer(java.security.Signer) SignerStub(org.apache.harmony.security.tests.support.SignerStub)

Example 5 with SignerStub

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

the class SignerTest method testSignerStringIdentityScope.

/**
     * verify  Signer(String, IdentityScope) creates instance
     */
public void testSignerStringIdentityScope() throws Exception {
    Signer s = new SignerStub("sss4", IdentityScope.getSystemScope());
    assertNotNull(s);
    assertEquals("sss4", s.getName());
    assertSame(IdentityScope.getSystemScope(), s.getScope());
    assertNull(s.getPrivateKey());
    try {
        Signer s2 = new SignerStub("sss4", IdentityScope.getSystemScope());
        fail("expected KeyManagementException not thrown");
    } catch (KeyManagementException e) {
    // ok
    }
    Signer s2 = new SignerStub(null);
    assertNull(s2.getName());
}
Also used : Signer(java.security.Signer) SignerStub(org.apache.harmony.security.tests.support.SignerStub) KeyManagementException(java.security.KeyManagementException)

Aggregations

SignerStub (org.apache.harmony.security.tests.support.SignerStub)6 Signer (java.security.Signer)5 KeyPair (java.security.KeyPair)3 PrivateKeyStub (org.apache.harmony.security.tests.support.PrivateKeyStub)2 PublicKeyStub (org.apache.harmony.security.tests.support.PublicKeyStub)2 InvalidParameterException (java.security.InvalidParameterException)1 KeyManagementException (java.security.KeyManagementException)1