use of java.security.NoSuchProviderException in project robovm by robovm.
the class invalidParams method testCertPathValidator13.
/**
* Test for <code>getAlgorithm()</code> method
*/
public void testCertPathValidator13() throws NoSuchAlgorithmException {
if (!PKIXSupport) {
fail(NotSupportMsg);
return;
}
CertPathValidator certPV;
for (int i = 0; i < validValues.length; i++) {
certPV = CertPathValidator.getInstance(validValues[i]);
assertEquals("Incorrect algorithm", certPV.getAlgorithm(), validValues[i]);
try {
certPV = CertPathValidator.getInstance(validValues[i], defaultProviderName);
assertEquals("Incorrect algorithm", certPV.getAlgorithm(), validValues[i]);
} catch (NoSuchProviderException e) {
fail("Unexpected NoSuchAlgorithmException " + e.getMessage());
}
certPV = CertPathValidator.getInstance(validValues[i], defaultProvider);
assertEquals("Incorrect algorithm", certPV.getAlgorithm(), validValues[i]);
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class CipherTest method test_getInstanceLjava_lang_StringLjava_lang_String.
/**
* javax.crypto.Cipher#getInstance(java.lang.String,
* java.lang.String)
*/
public void test_getInstanceLjava_lang_StringLjava_lang_String() throws Exception {
Provider[] providers = Security.getProviders("Cipher.DES");
assertNotNull("No installed providers support Cipher.DES", providers);
for (int i = 0; i < providers.length; i++) {
Cipher cipher = Cipher.getInstance("DES", providers[i].getName());
assertNotNull("Cipher.getInstance() returned a null value", cipher);
try {
cipher = Cipher.getInstance("DoBeDoBeDo", providers[i]);
fail();
} catch (NoSuchAlgorithmException expected) {
}
}
try {
Cipher.getInstance("DES", (String) null);
fail();
} catch (IllegalArgumentException expected) {
}
try {
Cipher.getInstance("DES", "IHaveNotBeenConfigured");
fail();
} catch (NoSuchProviderException expected) {
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class EncryptedPrivateKeyInfoTest method testGetKeySpecKeyString01.
public final void testGetKeySpecKeyString01() throws Exception {
boolean performed = false;
for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
try {
EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfoData.algName0[i][0], EncryptedPrivateKeyInfoData.encryptedData);
try {
// check that method under test throws NPE
epki.getKeySpec((Key) null, "SomeProviderName");
fail(getName() + "NullPointerException has not been thrown");
} catch (NullPointerException ok) {
}
try {
epki.getKeySpec(new Key() {
public String getAlgorithm() {
return "alg";
}
public String getFormat() {
return "fmt";
}
public byte[] getEncoded() {
return new byte[] {};
}
}, "StrangeProviderName");
fail(getName() + "NoSuchProviderException has not been thrown");
} catch (NoSuchProviderException ok) {
//expected
}
try {
// check that method under test throws NPE
epki.getKeySpec(new Key() {
public String getAlgorithm() {
return "alg";
}
public String getFormat() {
return "fmt";
}
public byte[] getEncoded() {
return new byte[] {};
}
}, (String) null);
fail(getName() + "NullPointerException has not been thrown");
} catch (NullPointerException ok) {
}
performed = true;
} catch (NoSuchAlgorithmException allowedFailure) {
}
}
assertTrue("Test not performed", performed);
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class AlgorithmParametersTest method test_getInstanceLjava_lang_StringLjava_lang_String.
/**
* java.security.AlgorithmParameters#getInstance(String, String)
*/
public void test_getInstanceLjava_lang_StringLjava_lang_String() {
String[] alg = { "", "qwertyu", "!@#$%^&*()" };
String[] prv = { "", null };
String[] prv1 = { "1234567890", "qwertyu", "!@#$%^&*()" };
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", "MyProvider");
checkUnititialized(ap);
ap.init(new byte[6]);
checkAP(ap, p);
} catch (Exception e) {
fail("Unexpected exception");
}
for (int i = 0; i < alg.length; i++) {
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance(alg[i], "MyProvider");
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]);
}
}
for (int i = 0; i < prv.length; i++) {
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", prv[i]);
fail("IllegalArgumentException was not thrown for parameter " + prv[i]);
} catch (IllegalArgumentException iae) {
//expected
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown for " + prv[i]);
}
}
for (int i = 0; i < prv1.length; i++) {
try {
AlgorithmParameters ap = AlgorithmParameters.getInstance("ABC", prv1[i]);
fail("NoSuchProviderException was not thrown for parameter " + prv1[i]);
} catch (NoSuchProviderException nspe) {
//expected
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown for " + prv1[i]);
}
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class NoSuchProviderExceptionTest method testNoSuchProviderException01.
/**
* Test for <code>NoSuchProviderException()</code> constructor Assertion:
* constructs NoSuchProviderException with no detail message
*/
public void testNoSuchProviderException01() {
NoSuchProviderException tE = new NoSuchProviderException();
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
Aggregations