@Test(expected = CompanyCertificateException.class) public void testUserImportCertificateRemoteApiException() throws RemoteApiException { doThrow(RemoteApiException.class).when(securityApi).createCompanyCert(eq(MOCK_SESSION_ID), any(CompanyCert.class)); service.importUserCertificate(application); }
public void importUserCertificate(Application application) { String fileName = utils.getCertsDirectory() + application.getId() + ".pem"; String pem = getPem(fileName); if (StringUtils.isEmpty(pem) && shouldImportUserCertificate(application)) { fileName = utils.getCertsDirectory() + application.getKeystore().getFile(); char[] password = application.getKeystore().getPassword().toCharArray(); pem = getPemFromPKCS12(fileName, password); } if (StringUtils.isEmpty(pem)) { LOGGER.info("Skipping app certificate importing for: {}. File: {}", application.getComponent(), fileName); return; } LOGGER.info("Importing user company certificate for: {}. File: {}", application.getComponent(), fileName); CompanyCert companyCert = buildCompanyCertificate(application.getId(), pem, CompanyCertStatus.TypeEnum.KNOWN); importCertificate(companyCert); }
CompanyCertificateService { public void importUserCertificate(Application application) { String fileName = utils.getCertsDirectory() + application.getId() + ".pem"; String pem = getPem(fileName); if (StringUtils.isEmpty(pem) && shouldImportUserCertificate(application)) { fileName = utils.getCertsDirectory() + application.getKeystore().getFile(); char[] password = application.getKeystore().getPassword().toCharArray(); pem = getPemFromPKCS12(fileName, password); } if (StringUtils.isEmpty(pem)) { LOGGER.info("Skipping app certificate importing for: {}. File: {}", application.getComponent(), fileName); return; } LOGGER.info("Importing user company certificate for: {}. File: {}", application.getComponent(), fileName); CompanyCert companyCert = buildCompanyCertificate(application.getId(), pem, CompanyCertStatus.TypeEnum.KNOWN); importCertificate(companyCert); } }
CompanyCertificateService { public void importUserCertificate(Application application) { String fileName = utils.getCertsDirectory() + application.getId() + ".pem"; String pem = getPem(fileName); if (StringUtils.isEmpty(pem) && shouldImportUserCertificate(application)) { fileName = utils.getCertsDirectory() + application.getKeystore().getFile(); char[] password = application.getKeystore().getPassword().toCharArray(); pem = getPemFromPKCS12(fileName, password); } if (StringUtils.isEmpty(pem)) { LOGGER.info("Skipping app certificate importing for: {}. File: {}", application.getComponent(), fileName); return; } LOGGER.info("Importing user company certificate for: {}. File: {}", application.getComponent(), fileName); CompanyCert companyCert = buildCompanyCertificate(application.getId(), pem, CompanyCertStatus.TypeEnum.KNOWN); importCertificate(companyCert); }  }
CompanyCertificateService { public void importUserCertificate(Application application) { String fileName = utils.getCertsDirectory() + application.getId() + ".pem"; String pem = getPem(fileName); if (StringUtils.isEmpty(pem) && shouldImportUserCertificate(application)) { fileName = utils.getCertsDirectory() + application.getKeystore().getFile(); char[] password = application.getKeystore().getPassword().toCharArray(); pem = getPemFromPKCS12(fileName, password); } if (StringUtils.isEmpty(pem)) { LOGGER.info("Skipping app certificate importing for: {}. File: {}", application.getComponent(), fileName); return; } LOGGER.info("Importing user company certificate for: {}. File: {}", application.getComponent(), fileName); CompanyCert companyCert = buildCompanyCertificate(application.getId(), pem, CompanyCertStatus.TypeEnum.KNOWN); importCertificate(companyCert); }  @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 void importUserCertificate(Application application) { String fileName = utils.getCertsDirectory() + application.getId() + ".pem"; String pem = getPem(fileName); if (StringUtils.isEmpty(pem) && shouldImportUserCertificate(application)) { fileName = utils.getCertsDirectory() + application.getKeystore().getFile(); char[] password = application.getKeystore().getPassword().toCharArray(); pem = getPemFromPKCS12(fileName, password); } if (StringUtils.isEmpty(pem)) { LOGGER.info("Skipping app certificate importing for: {}. File: {}", application.getComponent(), fileName); return; } LOGGER.info("Importing user company certificate for: {}. File: {}", application.getComponent(), fileName); CompanyCert companyCert = buildCompanyCertificate(application.getId(), pem, CompanyCertStatus.TypeEnum.KNOWN); importCertificate(companyCert); }  @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);  }