use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class CertStore2Test method testGetCRLs.
public void testGetCRLs() {
CertStore certStore = null;
try {
certStore = CertStore.getInstance(CERT_STORE_NAME, new MyCertStoreParameters());
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
}
assertNotNull(certStore);
try {
Collection<? extends CRL> ls = certStore.getCRLs(null);
assertNull(ls);
} catch (CertStoreException e) {
fail("unexpected exception: " + e);
}
try {
Collection<? extends CRL> ls = certStore.getCRLs(new MyCRLSelector());
assertNotNull(ls);
assertTrue(ls.isEmpty());
} catch (CertStoreException e) {
fail("unexpected exception: " + e);
}
try {
certStore.getCRLs(new MyOtherCRLSelector());
fail("expected CertStoreException");
} catch (CertStoreException e) {
// ok
}
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class CertStore2Test method testGetInstanceStringCertStoreParameters.
public void testGetInstanceStringCertStoreParameters() {
try {
CertStoreParameters parameters = new MyCertStoreParameters();
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, parameters);
assertNotNull(certStore);
assertNotNull(certStore.getCertStoreParameters());
assertNotSame(parameters, certStore.getCertStoreParameters());
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
}
try {
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, null);
assertNotNull(certStore);
assertNull(certStore.getCertStoreParameters());
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
}
try {
CertStore.getInstance("UnknownCertStore", null);
fail("expected NoSuchAlgorithmException");
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
// ok
}
try {
CertStore.getInstance(CERT_STORE_NAME, new MyOtherCertStoreParameters());
fail("expected InvalidAlgorithmParameterException");
} catch (InvalidAlgorithmParameterException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
}
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class KeyPairGenerator1Test method testKeyPairGenerator13.
/**
* Test for methods: <code>initialize(int keysize)</code>
* <code>initialize(int keysize, SecureRandom random)</code>
* <code>initialize(AlgorithmParameterSpec param)</code>
* <code>initialize(AlgorithmParameterSpec param, SecureRandom random)</code>
* <code>generateKeyPair()</code>
* <code>genKeyPair()</code>
* Assertion: initialize(int ...) throws InvalidParameterException when
* keysize in incorrect Assertion: initialize(AlgorithmParameterSpec
* ...)throws UnsupportedOperationException Assertion: generateKeyPair() and
* genKeyPair() return not null KeyPair Additional class MyKeyPairGenerator2
* is used
*/
public void testKeyPairGenerator13() {
int[] keys = { -1, -250, 1, 63, -512, -1024 };
SecureRandom random = new SecureRandom();
KeyPairGenerator mKPG = new MyKeyPairGenerator2(null);
assertEquals("Algorithm must be null", mKPG.getAlgorithm(), MyKeyPairGenerator2.getResAlgorithm());
assertNull("genKeyPair() must return null", mKPG.genKeyPair());
assertNull("generateKeyPair() mut return null", mKPG.generateKeyPair());
for (int i = 0; i < keys.length; i++) {
try {
mKPG.initialize(keys[i]);
fail("InvalidParameterException must be thrown (key: " + Integer.toString(keys[i]) + ")");
} catch (InvalidParameterException e) {
}
try {
mKPG.initialize(keys[i], random);
fail("InvalidParameterException must be thrown (key: " + Integer.toString(keys[i]) + ")");
} catch (InvalidParameterException e) {
}
}
try {
mKPG.initialize(64);
} catch (InvalidParameterException e) {
fail("Unexpected InvalidParameterException was thrown");
}
try {
mKPG.initialize(64, null);
} catch (InvalidParameterException e) {
fail("Unexpected InvalidParameterException was thrown");
}
try {
mKPG.initialize(null, random);
} catch (UnsupportedOperationException e) {
// on j2se1.4 this exception is not thrown
} catch (InvalidAlgorithmParameterException e) {
fail("Unexpected InvalidAlgorithmParameterException was thrown");
}
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class KeyPairGenerator1Test method testKeyPairGenerator11.
/**
* Test for methods:
* <code>initialize(int keysize)</code>
* <code>initialize(int keysize, SecureRandom random)</code>
* <code>initialize(AlgorithmParameterSpec param)</code>
* <code>initialize(AlgorithmParameterSpec param, SecureRandom random)</code>
* Assertion: throws InvalidParameterException or
* InvalidAlgorithmParameterException when parameters keysize or param are
* incorrect
*/
public void testKeyPairGenerator11() throws NoSuchAlgorithmException, NoSuchProviderException {
if (!DSASupported) {
fail(NotSupportMsg);
return;
}
int[] keys = { -10000, -1024, -1, 0, 10000 };
KeyPairGenerator[] kpg = createKPGen();
assertNotNull("KeyPairGenerator objects were not created", kpg);
SecureRandom random = new SecureRandom();
AlgorithmParameterSpec aps = null;
for (int i = 0; i < kpg.length; i++) {
for (int j = 0; j < keys.length; j++) {
try {
kpg[i].initialize(keys[j]);
kpg[i].initialize(keys[j], random);
} catch (InvalidParameterException e) {
}
}
try {
kpg[i].initialize(aps);
kpg[i].initialize(aps, random);
} catch (InvalidAlgorithmParameterException e) {
}
}
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class InvalidAlgorithmParameterExceptionTest method testInvalidAlgorithmParameterException01.
/**
* Test for <code>InvalidAlgorithmParameterException()</code> constructor
* Assertion: constructs InvalidAlgorithmParameterException with no detail
* message
*/
public void testInvalidAlgorithmParameterException01() {
InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException();
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
Aggregations