use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class KeyManagerFactorySpiTest method test_engineInit_02.
/**
* javax.net.ssl.KeyManagerFactorySpi#KengineInit(ManagerFactoryParameters spec)
*/
public void test_engineInit_02() {
KeyManagerFactorySpiImpl kmf = new KeyManagerFactorySpiImpl();
try {
kmf.engineInit(null);
fail("InvalidAlgorithmParameterException wasn't thrown");
} catch (InvalidAlgorithmParameterException iape) {
//expected
} catch (Exception e) {
fail(e + " was thrown instead of InvalidAlgorithmParameterException");
}
try {
char[] psw = "password".toCharArray();
Parameters pr = new Parameters(psw);
kmf.engineInit(pr);
} catch (Exception e) {
fail(e + " unexpected exception was thrown");
}
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class KeyManagerFactory2Test method checkResult.
private void checkResult(KeyManagerFactory keyMF) throws Exception {
KeyStore kStore = null;
ManagerFactoryParameters mfp = null;
char[] pass = { 'a', 'b', 'c' };
try {
keyMF.init(kStore, null);
fail("KeyStoreException must be thrown");
} catch (KeyStoreException e) {
}
try {
keyMF.init(kStore, pass);
fail("UnrecoverableKeyException must be thrown");
} catch (UnrecoverableKeyException e) {
}
try {
keyMF.init(mfp);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
assertNull("getKeyManagers() should return null object", keyMF.getKeyManagers());
try {
kStore = KeyStore.getInstance(KeyStore.getDefaultType());
kStore.load(null, null);
} catch (KeyStoreException e) {
fail("default keystore is not supported");
return;
}
keyMF.init(kStore, pass);
mfp = new MyKeyManagerFactorySpi.Parameters(kStore, null);
try {
keyMF.init(mfp);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
mfp = new MyKeyManagerFactorySpi.Parameters(kStore, pass);
keyMF.init(mfp);
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class invalidParams method testCertPathValidator11.
/**
* Test for <code>validate(CertPath certpath, CertPathParameters params)</code> method
* Assertion: throws InvalidAlgorithmParameterException params is not
* instance of PKIXParameters or null
*/
public void testCertPathValidator11() throws NoSuchAlgorithmException, NoSuchProviderException, CertPathValidatorException {
if (!PKIXSupport) {
fail(NotSupportMsg);
return;
}
CertPathValidator[] certPV = createCPVs();
assertNotNull("CertPathValidator objects were not created", certPV);
MyCertPath mCP = new MyCertPath(new byte[0]);
invalidParams mPar = new invalidParams();
for (int i = 0; i < certPV.length; i++) {
try {
certPV[i].validate(mCP, mPar);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
try {
certPV[i].validate(mCP, null);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
}
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class CertPathValidatorSpiTest method testCertPathValidatorSpi01.
/**
* Test for <code>CertPathValidatorSpi</code> constructor Assertion:
* constructs CertPathValidatorSpi
*/
public void testCertPathValidatorSpi01() throws CertPathValidatorException, InvalidAlgorithmParameterException {
CertPathValidatorSpi certPathValid = new MyCertPathValidatorSpi();
CertPathParameters params = null;
CertPath certPath = null;
CertPathValidatorResult cpvResult = certPathValid.engineValidate(certPath, params);
assertNull("Not null CertPathValidatorResult", cpvResult);
try {
certPathValid.engineValidate(certPath, params);
fail("CertPathValidatorException must be thrown");
} catch (CertPathValidatorException e) {
}
try {
certPathValid.engineValidate(certPath, params);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
}
use of java.security.InvalidAlgorithmParameterException in project robovm by robovm.
the class CertStore2Test method testGetInstanceStringCertStoreParametersProvider.
public void testGetInstanceStringCertStoreParametersProvider() {
try {
CertStoreParameters parameters = new MyCertStoreParameters();
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, parameters, provider);
assertNotNull(certStore);
assertNotNull(certStore.getCertStoreParameters());
assertNotSame(parameters, certStore.getCertStoreParameters());
assertSame(provider, certStore.getProvider());
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
}
try {
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, null, provider);
assertNotNull(certStore);
assertNull(certStore.getCertStoreParameters());
assertSame(provider, certStore.getProvider());
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
}
try {
CertStore.getInstance("UnknownCertStore", null, provider);
fail("expected NoSuchAlgorithmException");
} catch (NoSuchAlgorithmException e) {
// ok
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
}
try {
CertStore.getInstance(CERT_STORE_NAME, new MyOtherCertStoreParameters(), provider);
fail("expected InvalidAlgorithmParameterException");
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (InvalidAlgorithmParameterException e) {
// ok
}
}
Aggregations