use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X500PrincipalTest method test_equals.
/**
* javax.security.auth.x500.X500Principal#equals(Object o)
*/
public void test_equals() {
String name1 = "CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US";
String name2 = "cn=duke,ou=javasoft,o=sun microsystems,c=us";
String name3 = "CN=Alex Astapchuk, OU=SSG, O=Intel ZAO, C=RU";
X500Principal xpr1 = new X500Principal(name1);
X500Principal xpr2 = new X500Principal(name2);
X500Principal xpr3 = new X500Principal(name3);
try {
assertTrue("False returned", xpr1.equals(xpr2));
assertFalse("True returned", xpr1.equals(xpr3));
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X500PrincipalTest method test_getName_Format.
/**
* javax.security.auth.x500.X500Principal#getName(String format)
*/
public void test_getName_Format() {
String name = "CN=Duke,OU=JavaSoft,O=Sun Microsystems,C=US";
String expectedName = "cn=duke,ou=javasoft,o=sun microsystems,c=us";
X500Principal xpr = new X500Principal(name);
try {
String resName = xpr.getName(X500Principal.CANONICAL);
assertEquals(expectedName, resName);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
expectedName = "CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US";
try {
String resName = xpr.getName(X500Principal.RFC1779);
assertEquals(expectedName, resName);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
try {
String resName = xpr.getName(X500Principal.RFC2253);
assertEquals(name, resName);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
try {
String resName = xpr.getName(null);
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException iae) {
}
try {
String resName = xpr.getName("RFC2254");
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException iae) {
}
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X500PrincipalTest method test_getEncoded.
/**
* javax.security.auth.x500.X500Principal#getEncoded()
*/
public void test_getEncoded() {
byte[] ba = getByteArray(TestUtils.getX509Certificate_v1());
X500Principal xpr = new X500Principal(ba);
try {
byte[] res = xpr.getEncoded();
assertNotNull(res);
assertEquals(ba.length, res.length);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X500PrincipalTest method test_getName.
/**
* javax.security.auth.x500.X500Principal#getName()
*/
public void test_getName() {
String name = "CN=Duke,OU=JavaSoft,O=Sun Microsystems,C=US";
X500Principal xpr = new X500Principal(name);
try {
String resName = xpr.getName();
assertEquals(name, resName);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X500PrincipalTest method test_X500Principal_01.
/**
* javax.security.auth.x500.X500Principal#X500Principal(String name)
*/
public void test_X500Principal_01() {
String name = "CN=Duke,OU=JavaSoft,O=Sun Microsystems,C=US";
try {
X500Principal xpr = new X500Principal(name);
assertNotNull("Null object returned", xpr);
String resName = xpr.getName();
assertEquals(name, resName);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
try {
X500Principal xpr = new X500Principal((String) null);
fail("NullPointerException wasn't thrown");
} catch (NullPointerException npe) {
} catch (Exception e) {
fail(e + " was thrown instead of NullPointerException");
}
try {
X500Principal xpr = new X500Principal("X500PrincipalName");
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException npe) {
} catch (Exception e) {
fail(e + " was thrown instead of IllegalArgumentException");
}
}
Aggregations