@SuppressWarnings("static-method") @Test public void testGetCN() { final String principals[][] = { {"CN=\"fulanito Menganito\", C=ES", "fulanito Menganito"}, {" CN=\"fulanito Menganito\", C=ES", "fulanito Menganito"}, {"CN=\"fulanito, Menganito\", C=ES", "fulanito, Menganito"}, {"CN=fulanito Menganito, C=ES", "fulanito Menganito"}, {"CN=fulanito Menganito , C=ES", "fulanito Menganito"}, {"CN = fulanito Menganito, C=ES", "fulanito Menganito"}, {"CN=fulanito Menganito, C=ES", "fulanito Menganito"}, {"C=ES, CN=fulanito Menganito", "fulanito Menganito"}, {"C=ES,CN=fulanito Menganito", "fulanito Menganito"}, {"C=ES,CN =fulanito Menganito", "fulanito Menganito"}, {"C=ES,CN = fulanito Menganito", "fulanito Menganito"}, {"C=ES,CN=fulanito Menganito", "fulanito Menganito"}, {"C=ES,CN =\"fulanito Menganito\"", "fulanito Menganito"}, {"C=ES,CN= \"fulanito Menganito\"", "fulanito Menganito"}, {"OU=\"mi organizacion\", C=ES", "mi organizacion"}, {" OU=\"mi organizacion\", C=ES", "mi organizacion"}, {"OU=\"mi organizacion\", C=ES", "mi organizacion"}, {"OU=mi organizacion, C=ES", "mi organizacion"}, {"OU=mi organizacion , C=ES", "mi organizacion"}, {"OU = mi organizacion, C=ES", "mi organizacion"}, {"OU=mi organizacion, C=ES", "mi organizacion"}, {"C=ES, OU=mi organizacion", "mi organizacion"}, {"C=ES, OU = mi organizacion", "mi organizacion"}, {"C=ES,OU=mi organizacion", "mi organizacion"}, {"C=ES,OU = mi organizacion", "mi organizacion"}, {"C=ES,OU=\"mi organizacion\"", "mi organizacion"}, {"C=ES,OU= \"mi organizacion\"", "mi organizacion"}, {"PCN=mi organizacion, C=ES", "mi organizacion"}, {"CN=, C=ES", ""}, {"C=ES, PCN=fulanito Menganito", "ES"}, {"C=ES, P CN=\"fulanito Menganito\"", "fulanito Menganito"}, {"C=ES, P ,CN=\"fulanito Menganito\"", "fulanito Menganito"}, {"C=ES, CN=\"\"", ""}, {"C=ES, CN=", ""}, {"C=ES, CN=\"", ""}, {"C=ES, CN=\" ", " "}, {"C=ES, CN", "ES"}, {"C=ES, CN a", "ES"}, {"Hola Mundo!!", "Hola Mundo!!"}, {null, null} }; for (final String principal[] : principals) { System.out.println(principal[0] + ": " + principal[1]); Assert.assertEquals("El metodo getCN() no devuelve el resultado correcto para " + principal[0], AOUtil.getCN(principal[0]), principal[1]); } }
public static String getCN(final X509Certificate c) { if (c == null) { return null; } return getCN(c.getSubjectX500Principal().toString()); }
AOUtil { public static String getCN(final X509Certificate c) { if (c == null) { return null; } return getCN(c.getSubjectX500Principal().toString()); } }
AOUtil { public static String getCN(final X509Certificate c) { if (c == null) { return null; } return getCN(c.getSubjectX500Principal().toString()); } private  AOUtil(); }
AOUtil { public static String getCN(final X509Certificate c) { if (c == null) { return null; } return getCN(c.getSubjectX500Principal().toString()); } private  AOUtil(); static URI createURI(final String file); static InputStream loadFile(final URI uri); static byte[] getDataFromInputStream(final InputStream input); static String getCN(final X509Certificate c); static String getCN(final String principal); static String getRDNvalueFromLdapName(final String rdn, final String principal); static boolean isPseudonymCert(final X509Certificate cert); static String hexify(final byte abyte0[], final boolean separator); static String hexify(final byte abyte0[], final String separator); static void loadNativeLibrary(final String path); static void copyFile(final File source, final File dest); static String[] split(final String text, final String sp); static String properties2Base64(final Properties p); static Properties base642Properties(final String base64); static String propertiesAsString(final Properties p); static boolean isJava9orNewer(); static boolean isOnlyNumber(final String value); }
AOUtil { public static String getCN(final X509Certificate c) { if (c == null) { return null; } return getCN(c.getSubjectX500Principal().toString()); } private  AOUtil(); static URI createURI(final String file); static InputStream loadFile(final URI uri); static byte[] getDataFromInputStream(final InputStream input); static String getCN(final X509Certificate c); static String getCN(final String principal); static String getRDNvalueFromLdapName(final String rdn, final String principal); static boolean isPseudonymCert(final X509Certificate cert); static String hexify(final byte abyte0[], final boolean separator); static String hexify(final byte abyte0[], final String separator); static void loadNativeLibrary(final String path); static void copyFile(final File source, final File dest); static String[] split(final String text, final String sp); static String properties2Base64(final Properties p); static Properties base642Properties(final String base64); static String propertiesAsString(final Properties p); static boolean isJava9orNewer(); static boolean isOnlyNumber(final String value);  }