CertificateManager { private String getSubjectDN(String hostname, String containerId, String appName) { return String.format("/CN=%s%s%s", SliderUtils.extractDomainNameFromFQDN(hostname), containerId != null ? "/OU=" + containerId : "", appName != null ? "/OU=" + appName : ""); }  void initialize(MapOperations compOperations); void initialize(MapOperations compOperations,
                         String hostname, String containerId,
                         String appName); void setPassphrase(String passphrase); synchronized void generateContainerCertificate(String hostname,
                                                        String identifier); synchronized SecurityStore generateContainerKeystore(String hostname,
                                                              String requesterId,
                                                              String role,
                                                              String keystorePass); SecurityStore generateContainerTruststore(String containerId,
                                                   String role,
                                                   String truststorePass); String getServerCert(); static File getServerCertficateFilePath(); static File getAgentCertficateFilePath(String containerId); static File getContainerKeystoreFilePath(String containerId,
                                                  String role); static File getContainerTruststoreFilePath(String role,
                                                    String containerId); static File getAgentKeyFilePath(String containerId); synchronized SignCertResponse signAgentCrt(String agentHostname,
                                                    String agentCrtReqContent,
                                                    String passphraseAgent);  }
@Test public void testAMKeystoreGenerated() throws Exception { File keystoreFile = new File(secDir, SliderKeys.KEYSTORE_FILE_NAME); Assert.assertTrue("Keystore does not exist: " + keystoreFile, keystoreFile.exists()); InputStream is = null; try { is = new FileInputStream(keystoreFile); KeyStore keystore = KeyStore.getInstance("pkcs12"); String password = SecurityUtils.getKeystorePass(); keystore.load(is, password.toCharArray()); Certificate certificate = keystore.getCertificate( keystore.aliases().nextElement()); Assert.assertNotNull(certificate); if (certificate instanceof X509Certificate) { X509Certificate x509cert = (X509Certificate) certificate; Principal principal = x509cert.getSubjectDN(); String subjectDn = principal.getName(); Assert.assertEquals("wrong DN", "CN=cahost", subjectDn); principal = x509cert.getIssuerDN(); String issuerDn = principal.getName(); Assert.assertEquals("wrong Issuer DN", "CN=cahost", issuerDn); } } finally { if(null != is) { is.close(); } } }