use of java.security.Provider in project robovm by robovm.
the class ProviderServiceTest method testGetClassName.
public void testGetClassName() {
Provider p = new MyProvider();
Provider.Service s1 = new Provider.Service(p, "type", "algorithm", "className", null, null);
assertTrue(s1.getClassName().equals("className"));
Provider.Service s2 = new Provider.Service(p, "SecureRandom", "algorithm", "tests.java.security.support.RandomImpl", null, null);
assertTrue(s2.getClassName().equals("tests.java.security.support.RandomImpl"));
}
use of java.security.Provider in project robovm by robovm.
the class ProviderServiceTest method testGetAttribute.
public void testGetAttribute() {
Provider p = new MyProvider();
Provider.Service s = new Provider.Service(p, "type", "algorithm", "className", null, null);
try {
s.getAttribute(null);
fail("No expected NullPointerException");
} catch (NullPointerException e) {
}
if (s.getAttribute("aaa") != null) {
fail("getAttribute(aaa) failed");
}
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("attribute", "value");
hm.put("KeySize", "1024");
hm.put("AAA", "BBB");
s = new Provider.Service(p, "type", "algorithm", "className", null, hm);
if (s.getAttribute("bbb") != null) {
fail("getAttribute(bbb) failed");
}
if (!s.getAttribute("attribute").equals("value")) {
fail("getAttribute(attribute) failed");
}
if (!s.getAttribute("KeySize").equals("1024")) {
fail("getAttribute(KeySize) failed");
}
}
use of java.security.Provider in project robovm by robovm.
the class ProviderServiceTest method testGetType.
public void testGetType() {
Provider p = new MyProvider();
Provider.Service s1 = new Provider.Service(p, "type", "algorithm", "className", null, null);
assertTrue(s1.getType().equals("type"));
Provider.Service s2 = new Provider.Service(p, "SecureRandom", "algorithm", "tests.java.security.support.RandomImpl", null, null);
assertTrue(s2.getType().equals("SecureRandom"));
}
use of java.security.Provider in project robovm by robovm.
the class CertificateFactory2Test method GetInstance03.
/**
* Test for <code>getInstance(String type, Provider provider)</code>
* method
* Assertions:
* throws NullPointerException when type is null
* throws CertificateException when type is not available
* throws IllegalArgumentException when provider is null;
* returns CertificateFactory object
*/
public void GetInstance03(boolean mode) throws CertificateException, IllegalArgumentException, CRLException {
try {
CertificateFactory.getInstance(null, mProv);
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);
fail("CertificateException must be thrown (type: ".concat(invalidValues[i]).concat(")"));
} catch (CertificateException e) {
}
}
Provider 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) {
}
}
CertificateFactory cerF;
for (int i = 0; i < validValues.length; i++) {
cerF = CertificateFactory.getInstance(validValues[i], mProv);
assertEquals("Incorrect type", cerF.getType(), validValues[i]);
assertEquals("Incorrect provider", cerF.getProvider(), mProv);
checkResult(cerF, mode);
}
}
use of java.security.Provider in project robovm by robovm.
the class CertificateFactory4Test method test_getInstanceLjava_lang_StringLjava_lang_String.
/**
* java.security.cert.CertificateFactory#getInstance(java.lang.String,
* java.lang.String)
*/
public void test_getInstanceLjava_lang_StringLjava_lang_String() throws Exception {
// Test for method java.security.cert.CertificateFactory
// java.security.cert.CertificateFactory.getInstance(java.lang.String,
// java.lang.String)
Provider[] providers = Security.getProviders("CertificateFactory.X.509");
if (providers != null) {
for (int i = 0; i < providers.length; i++) {
CertificateFactory fact = CertificateFactory.getInstance("X.509", providers[i].getName());
assertNotNull("factory is null", fact);
}
// end for
} else {
fail("No providers support CertificateFactory.X.509");
}
// exception case
try {
CertificateFactory.getInstance("X.509", "IHaventBeenConfigured");
fail("Should have thrown NoSuchProviderException");
} catch (NoSuchProviderException e) {
// Expected
}
}
Aggregations