public void test_setKeyPairLjava_security_KeyPair() throws Exception {
// Regression for HARMONY-2408
// test: NullPointerException if pair is null
try {
new SignerStub("name").setKeyPair(null);
fail("No expected NullPointerException");
} catch (NullPointerException e) {
}
// test: SecurityException if permission is denied
SecurityManager oldSm = System.getSecurityManager();
MySecurityManager sm = new MySecurityManager();
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 {