use of java.security.Signer 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());
}
use of java.security.Signer 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());
}
use of java.security.Signer 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());
}
use of java.security.Signer 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());
}
use of java.security.Signer 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();
}
Aggregations