Java Code Examples for javax.security.auth.x500.X500Principal#toString()
The following examples show how to use
javax.security.auth.x500.X500Principal#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NameFormat.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 2
Source File: X500PrincipalTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testStreamPosition_0() throws Exception { //this encoding is read from the file /*byte [] mess = {0x30, 0x30, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41, }; */ InputStream is = Support_Resources .getResourceStream("X500PrincipalTest.1.dat"); X500Principal principal = new X500Principal(is); String s = principal.toString(); assertEquals("CN=A, CN=B, CN=A, CN=B", s); assertEquals(0, is.available()); is.close(); }
Example 3
Source File: X500PrincipalTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testStreamPosition() throws Exception { //this encoding is read from the file /*byte [] mess = {0x30, 0x30, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41, 1, 2, 3//extra bytes }; */ InputStream is = Support_Resources .getResourceStream("X500PrincipalTest.0.dat"); X500Principal principal = new X500Principal(is); String s = principal.toString(); assertEquals("CN=A, CN=B, CN=A, CN=B", s); byte[] restBytes = new byte[] { 0, 0, 0 }; is.read(restBytes); assertEquals(restBytes[0], 1); assertEquals(restBytes[1], 2); assertEquals(restBytes[2], 3); is.close(); }
Example 4
Source File: NameFormat.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 5
Source File: NameFormat.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 6
Source File: NameFormat.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 7
Source File: NameFormat.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 8
Source File: NameFormat.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 9
Source File: NameFormat.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 10
Source File: NameFormat.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 11
Source File: NameFormat.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 12
Source File: NameFormat.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 13
Source File: KeyInformation.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public String toString () { if ( this.certificate instanceof X509Certificate ) { final X500Principal subject = ( (X509Certificate)this.certificate ).getSubjectX500Principal (); if ( subject != null ) { return subject.toString (); } } if ( this.key != null ) { return this.key.toString (); } else { return null; } }
Example 14
Source File: NameFormat.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 15
Source File: NameFormat.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 16
Source File: NameFormat.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void testName(String in, String outFormat, String expect, int n) throws Exception { X500Principal p = new X500Principal(in); if (outFormat.equalsIgnoreCase("toString")) { if (p.toString().equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.toString() + "'"); } } else { if (p.getName(outFormat).equals(expect)) { System.out.println("test " + n + " succeeded"); } else { throw new SecurityException("test " + n + " failed:\n" + "expected '" + expect + "'\n" + "got '" + p.getName(outFormat) + "'"); } } }
Example 17
Source File: X500PrincipalTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * javax.security.auth.x500.X500Principal#toString() */ public void test_toString() { String name = "CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US"; X500Principal xpr = new X500Principal(name); try { String res = xpr.toString(); assertNotNull(res); assertEquals(name, res); } catch (Exception e) { fail("Unexpected exception: " + e); } }
Example 18
Source File: X500PrincipalTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testEncodingFromFile() throws Exception { //this encoding is read from the file /*byte [] mess = {0x30, 0x30, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41 }; */ InputStream is = Support_Resources .getResourceStream("X500PrincipalTest.1.dat"); X500Principal principal = new X500Principal(is); String s = principal.toString(); assertEquals("CN=A, CN=B, CN=A, CN=B", s); is.close(); }
Example 19
Source File: X500PrincipalTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Inits X500Principal with byte array * gets toString * checks the result */ public void testToString() throws Exception { byte[] mess = { 0x30, 0x18, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41 }; X500Principal principal = new X500Principal(mess); String s = principal.toString(); assertNotNull(s); }