use of org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass in project robovm by robovm.
the class Identity2Test method test_certificates.
/**
* java.security.Identity#certificates()
*/
public void test_certificates() throws Exception {
IdentitySubclass sub = new IdentitySubclass("test", new IdentityScopeSubclass());
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate[] cert = new X509Certificate[1];
cert[0] = (X509Certificate) cf.generateCertificate(certArray);
sub.setPublicKey(cert[0].getPublicKey());
CertificateImpl certImpl = new CertificateImpl(cert[0]);
sub.addCertificate(certImpl);
java.security.Certificate[] certs = sub.certificates();
assertEquals("Certificate not contained in the identity", certs[0], certImpl);
}
use of org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass in project robovm by robovm.
the class Identity2Test method test_getPublicKey.
/**
* java.security.Identity#getPublicKey()
*/
public void test_getPublicKey() throws Exception {
IdentitySubclass sub = new IdentitySubclass("test", new IdentityScopeSubclass());
sub.setPublicKey(getPubKey());
PublicKey returnedPubKey = sub.getPublicKey();
assertEquals("Wrong PublicKey returned", getPubKey(), returnedPubKey);
}
use of org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass in project robovm by robovm.
the class Identity2Test method test_getScope.
/**
* java.security.Identity#getScope()
*/
public void test_getScope() throws Exception {
IdentityScope scope = new IdentityScopeSubclass();
IdentitySubclass sub = new IdentitySubclass("test", scope);
IdentityScope returnedScope = sub.getScope();
assertEquals("Wrong Scope returned", scope, returnedScope);
}
use of org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass in project robovm by robovm.
the class Identity2Test method testSetInfo.
/**
* java.security.Identity#setInfo(String)
*/
public void testSetInfo() throws Exception {
String[] info = { "This is the general information.", "test", "", null };
IdentitySubclass sub = new IdentitySubclass("test", new IdentityScopeSubclass());
for (int i = 0; i < info.length; i++) {
try {
sub.setInfo(info[i]);
assertEquals("Wrong Info returned", info[i], sub.getInfo());
} catch (Exception e) {
fail("Unexpected exception for parameter " + info[i]);
}
}
}
use of org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass in project robovm by robovm.
the class Identity2Test method test_ConstructorLjava_lang_StringLjava_security_IdentityScope.
/**
* java.security.Identity#Identity(java.lang.String,
* java.security.IdentityScope)
*/
public void test_ConstructorLjava_lang_StringLjava_security_IdentityScope() throws Exception {
String nameNull = null;
String[] str = { "test", "", "!@#$%^&*()", "identity name" };
IdentityScopeSubclass iss = new IdentityScopeSubclass("name");
IdentitySubclass is;
for (int i = 0; i < str.length; i++) {
try {
is = new IdentitySubclass(str[i], new IdentityScopeSubclass());
assertNotNull(is);
assertTrue(is instanceof Identity);
} catch (Exception e) {
System.out.println(e);
fail("Unexpected exception for parameter " + str[i]);
}
}
try {
is = new IdentitySubclass(nameNull, new IdentityScopeSubclass());
} catch (NullPointerException npe) {
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown");
}
try {
is = new IdentitySubclass("test", iss);
is = new IdentitySubclass("test", iss);
fail("KeyManagementException was not thrown");
} catch (KeyManagementException expected) {
}
}
Aggregations