@Test public void testGetEmptyCommonNameFromApplicationCertificate() { Keystore keystore = new Keystore(); keystore.setPassword(DEFAULT_KEYSTORE_PASSWORD); Application application = getApplication(keystore); String name = service.getCommonNameFromApplicationCertificate(application); assertTrue(StringUtils.isEmpty(name)); }
public String getCommonNameFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { Principal principal = certificate.getSubjectX500Principal(); Pattern p = Pattern.compile("(^|,)CN=([^,]*)(,|$)"); Matcher m = p.matcher(principal.getName()); m.find(); return m.group(2); } return StringUtils.EMPTY; }
CompanyCertificateService { public String getCommonNameFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { Principal principal = certificate.getSubjectX500Principal(); Pattern p = Pattern.compile("(^|,)CN=([^,]*)(,|$)"); Matcher m = p.matcher(principal.getName()); m.find(); return m.group(2); } return StringUtils.EMPTY; } }
CompanyCertificateService { public String getCommonNameFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { Principal principal = certificate.getSubjectX500Principal(); Pattern p = Pattern.compile("(^|,)CN=([^,]*)(,|$)"); Matcher m = p.matcher(principal.getName()); m.find(); return m.group(2); } return StringUtils.EMPTY; }  }
CompanyCertificateService { public String getCommonNameFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { Principal principal = certificate.getSubjectX500Principal(); Pattern p = Pattern.compile("(^|,)CN=([^,]*)(,|$)"); Matcher m = p.matcher(principal.getName()); m.find(); return m.group(2); } return StringUtils.EMPTY; }  @PostConstruct void init(); void importCertificate(Application application); void importUserCertificate(Application application); void importAppCertificate(Application application); String getPem(String fileName); String getCommonNameFromApplicationCertificate(Application application); String getEmailAddressFromApplicationCertificate(Application application); }
CompanyCertificateService { public String getCommonNameFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { Principal principal = certificate.getSubjectX500Principal(); Pattern p = Pattern.compile("(^|,)CN=([^,]*)(,|$)"); Matcher m = p.matcher(principal.getName()); m.find(); return m.group(2); } return StringUtils.EMPTY; }  @PostConstruct void init(); void importCertificate(Application application); void importUserCertificate(Application application); void importAppCertificate(Application application); String getPem(String fileName); String getCommonNameFromApplicationCertificate(Application application); String getEmailAddressFromApplicationCertificate(Application application);  }