use of java.security.NoSuchProviderException in project robovm by robovm.
the class NoSuchProviderExceptionTest method testNoSuchProviderException03.
/**
* Test for <code>NoSuchProviderException(String)</code> constructor
* Assertion: constructs NoSuchProviderException when <code>msg</code> is
* null
*/
public void testNoSuchProviderException03() {
String msg = null;
NoSuchProviderException tE = new NoSuchProviderException(msg);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class CertificateFactory2Test method GetInstance02.
/**
* Test for <code>getInstance(String type, String provider)</code> method
* Assertions:
* throws NullPointerException when type is null
* throws CertificateException when type is not available
* throws IllegalArgumentException when provider is null or empty;
* throws NoSuchProviderException when provider is available;
* returns CertificateFactory object
*/
public void GetInstance02(boolean mode) throws CertificateException, NoSuchProviderException, IllegalArgumentException, CRLException {
try {
CertificateFactory.getInstance(null, mProv.getName());
fail("NullPointerException or CertificateException must be thrown when type is null");
} catch (CertificateException e) {
} catch (NullPointerException e) {
}
for (int i = 0; i < invalidValues.length; i++) {
try {
CertificateFactory.getInstance(invalidValues[i], mProv.getName());
fail("CertificateException must be thrown (type: ".concat(invalidValues[i]).concat(")"));
} catch (CertificateException e) {
}
}
String prov = null;
for (int i = 0; i < validValues.length; i++) {
try {
CertificateFactory.getInstance(validValues[i], prov);
fail("IllegalArgumentException must be thrown when provider is null (type: ".concat(validValues[i]).concat(")"));
} catch (IllegalArgumentException e) {
}
try {
CertificateFactory.getInstance(validValues[i], "");
fail("IllegalArgumentException must be thrown when provider is empty (type: ".concat(validValues[i]).concat(")"));
} catch (IllegalArgumentException e) {
}
}
for (int i = 0; i < validValues.length; i++) {
for (int j = 1; j < invalidValues.length; j++) {
try {
CertificateFactory.getInstance(validValues[i], invalidValues[j]);
fail("NoSuchProviderException must be thrown (type: ".concat(validValues[i]).concat(" provider: ").concat(invalidValues[j]).concat(")"));
} catch (NoSuchProviderException e) {
}
}
}
CertificateFactory cerF;
for (int i = 0; i < validValues.length; i++) {
cerF = CertificateFactory.getInstance(validValues[i], mProv.getName());
assertEquals("Incorrect type", cerF.getType(), validValues[i]);
assertEquals("Incorrect provider", cerF.getProvider().getName(), mProv.getName());
checkResult(cerF, mode);
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class CertificateTest method testVerifyPublicKey2.
/**
* This test just calls <code>verify(PublicKey)</code> method<br>
*
* @throws InvalidKeyException
* @throws CertificateException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* @throws SignatureException
* @throws IOException
* @throws InvalidAlgorithmParameterException
*/
public final void testVerifyPublicKey2() throws InvalidKeyException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, InvalidAlgorithmParameterException, IOException {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
c1.verify(null);
cert.verify(cert.getPublicKey());
PublicKey k = cert.getPublicKey();
MyModifiablePublicKey changedEncoding = new MyModifiablePublicKey(k);
changedEncoding.setEncoding(new byte[cert.getEncoded().length - 1]);
try {
cert.verify(c1.getPublicKey());
fail();
} catch (InvalidKeyException expected) {
}
try {
cert.verify(changedEncoding);
fail();
} catch (Exception expected) {
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class CertStore2Test method testGetInstanceStringCertStoreParametersString.
public void testGetInstanceStringCertStoreParametersString() {
try {
CertStoreParameters parameters = new MyCertStoreParameters();
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, parameters, CERT_STORE_PROVIDER_NAME);
assertNotNull(certStore);
assertNotNull(certStore.getCertStoreParameters());
assertNotSame(parameters, certStore.getCertStoreParameters());
assertEquals(CERT_STORE_PROVIDER_NAME, certStore.getProvider().getName());
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
try {
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, null, CERT_STORE_PROVIDER_NAME);
assertNotNull(certStore);
assertNull(certStore.getCertStoreParameters());
assertEquals(CERT_STORE_PROVIDER_NAME, certStore.getProvider().getName());
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
try {
CertStore.getInstance("UnknownCertStore", new MyCertStoreParameters(), CERT_STORE_PROVIDER_NAME);
fail("expected NoSuchAlgorithmException");
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
// ok
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
try {
CertStore.getInstance(CERT_STORE_NAME, null, "UnknownCertStoreProvider");
fail("expected NoSuchProviderException");
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
// ok
}
try {
CertStore.getInstance(CERT_STORE_NAME, new MyOtherCertStoreParameters(), CERT_STORE_PROVIDER_NAME);
} catch (InvalidAlgorithmParameterException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class myCertStore method testCertStore16.
/**
* Test for <code>getType()</code> method
*/
public void testCertStore16() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
if (!initParams()) {
return;
}
CertStore certS;
for (int i = 0; i < dValid.length; i++) {
certS = CertStore.getInstance(dValid[i], dParams);
assertEquals("Incorrect type", certS.getType(), dValid[i]);
try {
certS = CertStore.getInstance(dValid[i], dParams, defaultProviderCol);
assertEquals("Incorrect type", certS.getType(), dValid[i]);
} catch (IllegalArgumentException e) {
fail("Unexpected IllegalArgumentException " + e.getMessage());
}
try {
certS = CertStore.getInstance(dValid[i], dParams, defaultProviderColName);
assertEquals("Incorrect type", certS.getType(), dValid[i]);
} catch (NoSuchProviderException e) {
fail("Unexpected IllegalArgumentException " + e.getMessage());
}
}
}
Aggregations