@Test(expected = CompanyCertificateException.class) public void testFailGetEmailAddressFromApplicationCertificate() throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { Keystore keystore = new Keystore(); keystore.setPassword(INVALID_KEYSTORE_PASSWORD); keystore.setFile(MOCK_WITH_EMAIL_ADDRESS_KEYSTORE_FILE); Application application = getApplication(keystore); service.getEmailAddressFromApplicationCertificate(application); }
public String getEmailAddressFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { String subjectDNName = certificate.getSubjectDN().getName(); if (subjectDNName.contains(EMAIL_ADDRESS)) { Map<String, String> subjectMap = parseSubjectToMap(subjectDNName); String emailAddress = subjectMap.get(EMAIL_ADDRESS); if (StringUtils.isNotEmpty(emailAddress)) { return emailAddress; } } } return StringUtils.EMPTY; }
CompanyCertificateService { public String getEmailAddressFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { String subjectDNName = certificate.getSubjectDN().getName(); if (subjectDNName.contains(EMAIL_ADDRESS)) { Map<String, String> subjectMap = parseSubjectToMap(subjectDNName); String emailAddress = subjectMap.get(EMAIL_ADDRESS); if (StringUtils.isNotEmpty(emailAddress)) { return emailAddress; } } } return StringUtils.EMPTY; } }
CompanyCertificateService { public String getEmailAddressFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { String subjectDNName = certificate.getSubjectDN().getName(); if (subjectDNName.contains(EMAIL_ADDRESS)) { Map<String, String> subjectMap = parseSubjectToMap(subjectDNName); String emailAddress = subjectMap.get(EMAIL_ADDRESS); if (StringUtils.isNotEmpty(emailAddress)) { return emailAddress; } } } return StringUtils.EMPTY; }  }
CompanyCertificateService { public String getEmailAddressFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { String subjectDNName = certificate.getSubjectDN().getName(); if (subjectDNName.contains(EMAIL_ADDRESS)) { Map<String, String> subjectMap = parseSubjectToMap(subjectDNName); String emailAddress = subjectMap.get(EMAIL_ADDRESS); if (StringUtils.isNotEmpty(emailAddress)) { return emailAddress; } } } 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 getEmailAddressFromApplicationCertificate(Application application) { X509Certificate certificate = readPKCS12Certificate(application); if (certificate != null) { String subjectDNName = certificate.getSubjectDN().getName(); if (subjectDNName.contains(EMAIL_ADDRESS)) { Map<String, String> subjectMap = parseSubjectToMap(subjectDNName); String emailAddress = subjectMap.get(EMAIL_ADDRESS); if (StringUtils.isNotEmpty(emailAddress)) { return emailAddress; } } } 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);  }