.getBuilderForKeyStoreFileType(storeFileType) .setKeyStorePath(keyStoreLocation) .setKeyStorePassword(keyStorePassword) .build() .loadKeyStore();
@Test(expected = Exception.class) public void testLoadKeyStoreWithWrongPassword() throws Exception { String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM) .getAbsolutePath(); new PEMFileLoader.Builder() .setKeyStorePath(path) .setKeyStorePassword("wrong password") .build() .loadKeyStore(); }
@Test(expected = Exception.class) public void testLoadKeyStoreWithWrongPassword() throws Exception { String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS) .getAbsolutePath(); new JKSFileLoader.Builder() .setKeyStorePath(path) .setKeyStorePassword("wrong password") .build() .loadKeyStore(); }
@Test public void testLoadKeyStore() throws Exception { String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS) .getAbsolutePath(); KeyStore ks = new JKSFileLoader.Builder() .setKeyStorePath(path) .setKeyStorePassword(x509TestContext.getKeyStorePassword()) .build() .loadKeyStore(); Assert.assertEquals(1, ks.size()); }
@Test(expected = IOException.class) public void testLoadKeyStoreWithWrongFilePath() throws Exception { String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM) .getAbsolutePath(); new PEMFileLoader.Builder() .setKeyStorePath(path + ".does_not_exist") .setKeyStorePassword(x509TestContext.getKeyStorePassword()) .build() .loadKeyStore(); }
@Test(expected = IOException.class) public void testLoadKeyStoreWithWrongFilePath() throws Exception { String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS) .getAbsolutePath(); new JKSFileLoader.Builder() .setKeyStorePath(path + ".does_not_exist") .setKeyStorePassword(x509TestContext.getKeyStorePassword()) .build() .loadKeyStore(); }
@Test(expected = IOException.class) public void testLoadKeyStoreWithWrongFileType() throws Exception { // Trying to load a PEM file with JKS loader should fail String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM) .getAbsolutePath(); new JKSFileLoader.Builder() .setKeyStorePath(path) .setKeyStorePassword(x509TestContext.getKeyStorePassword()) .build() .loadKeyStore(); }
@Test public void testLoadKeyStore() throws Exception { String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM) .getAbsolutePath(); KeyStore ks = new PEMFileLoader.Builder() .setKeyStorePath(path) .setKeyStorePassword(x509TestContext.getKeyStorePassword()) .build() .loadKeyStore(); Assert.assertEquals(1, ks.size()); }
@Test(expected = KeyStoreException.class) public void testLoadKeyStoreWithWrongFileType() throws Exception { // Trying to load a JKS file with PEM loader should fail String path = x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS) .getAbsolutePath(); new PEMFileLoader.Builder() .setKeyStorePath(path) .setKeyStorePassword(x509TestContext.getKeyStorePassword()) .build() .loadKeyStore(); }