use of java.security.NoSuchAlgorithmException in project j2objc by google.
the class SignatureTest method testInitVerifyCertificate.
/*
* Class under test for void initVerify(Certificate)
*/
public void testInitVerifyCertificate() throws InvalidKeyException {
MySignature1 s = new MySignature1("ABC");
s.initVerify(new MyCertificate());
assertEquals("state", MySignature1.VERIFY, s.getState());
assertTrue("initVerify() failed", s.runEngineInitVerify);
try {
Signature sig = getTestSignature();
sig.initVerify(new MyCertificate());
fail("expected InvalidKeyException");
} catch (InvalidKeyException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected : " + e);
}
}
use of java.security.NoSuchAlgorithmException in project j2objc by google.
the class SignatureTest method testInitSignPrivateKey.
/*
* Class under test for void initSign(PrivateKey)
*/
public void testInitSignPrivateKey() throws InvalidKeyException {
MySignature1 s = new MySignature1("ABC");
s.initSign(new MyPrivateKey());
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("initSign() failed", s.runEngineInitSign);
try {
Signature signature = getTestSignature();
signature.initSign(null);
fail("expected InvalidKeyException");
} catch (InvalidKeyException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected: " + e);
}
}
use of java.security.NoSuchAlgorithmException in project j2objc by google.
the class SignatureTest method testInitVerifyPublicKey.
/*
* Class under test for void initVerify(PublicKey)
*/
public void testInitVerifyPublicKey() throws InvalidKeyException {
MySignature1 s = new MySignature1("ABC");
s.initVerify(new MyPublicKey());
assertEquals("state", MySignature1.VERIFY, s.getState());
assertTrue("initVerify() failed", s.runEngineInitVerify);
try {
Signature sig = getTestSignature();
sig.initVerify((PublicKey) null);
} catch (InvalidKeyException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected : " + e);
}
}
use of java.security.NoSuchAlgorithmException in project j2objc by google.
the class SignatureTest method testInitSignPrivateKeySecureRandom.
/*
* Class under test for void initSign(PrivateKey, SecureRandom)
*/
public void testInitSignPrivateKeySecureRandom() throws InvalidKeyException {
MySignature1 s = new MySignature1("ABC");
s.initSign(new MyPrivateKey(), new SecureRandom());
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("initSign() failed", s.runEngineInitSign);
try {
Signature sig = getTestSignature();
sig.initSign(null, null);
fail("expected InvalidKeyException");
} catch (InvalidKeyException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected : " + e);
}
}
use of java.security.NoSuchAlgorithmException in project j2objc by google.
the class AlgorithmParametersTest method test_getInstanceLjava_lang_StringLjava_security_Provider.
/**
* java.security.AlgorithmParameters#getInstance(String, Provider)
*/
public void test_getInstanceLjava_lang_StringLjava_security_Provider() {
String[] alg = { "", "qwertyu", "!@#$%^&*()" };
Provider pp = null;
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", p);
checkUnititialized(ap);
ap.init(new byte[6], "aaa");
checkAP(ap, p);
} catch (Exception e) {
fail("Unexpected exception");
}
for (int i = 0; i < alg.length; i++) {
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance(alg[i], p);
fail("NoSuchAlgorithmException was not thrown for parameter " + alg[i]);
} catch (NoSuchAlgorithmException nsae) {
//expected
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown for " + alg[i]);
}
}
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", pp);
fail("IllegalArgumentException was not thrown for NULL provider");
} catch (IllegalArgumentException iae) {
//expected
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown");
}
}
Aggregations