/** * Checks that SSLFactory initialization is successful with the given * arguments. This is a helper method for writing test cases that cover * different combinations of settings for the store password and key password. * It takes care of bootstrapping a keystore, a truststore, and SSL client or * server configuration. Then, it initializes an SSLFactory. If no exception * is thrown, then initialization was successful. * * @param mode SSLFactory.Mode mode to test * @param password String store password to set on keystore * @param keyPassword String key password to set on keystore * @param confPassword String store password to set in SSL config file, or null * to avoid setting in SSL config file * @param confKeyPassword String key password to set in SSL config file, or * null to avoid setting in SSL config file * @throws Exception for any error */ private void checkSSLFactoryInitWithPasswords(SSLFactory.Mode mode, String password, String keyPassword, String confPassword, String confKeyPassword) throws Exception { checkSSLFactoryInitWithPasswords(mode, password, keyPassword, confPassword, confKeyPassword, false); }
/** * Checks that SSLFactory initialization is successful with the given * arguments. This is a helper method for writing test cases that cover * different combinations of settings for the store password and key password. * It takes care of bootstrapping a keystore, a truststore, and SSL client or * server configuration. Then, it initializes an SSLFactory. If no exception * is thrown, then initialization was successful. * * @param mode SSLFactory.Mode mode to test * @param password String store password to set on keystore * @param keyPassword String key password to set on keystore * @param confPassword String store password to set in SSL config file, or null * to avoid setting in SSL config file * @param confKeyPassword String key password to set in SSL config file, or * null to avoid setting in SSL config file * @throws Exception for any error */ private void checkSSLFactoryInitWithPasswords(SSLFactory.Mode mode, String password, String keyPassword, String confPassword, String confKeyPassword) throws Exception { checkSSLFactoryInitWithPasswords(mode, password, keyPassword, confPassword, confKeyPassword, false); }
@Test public void testServerKeyPasswordDefaultsToPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.SERVER, "password", "password", "password", null); }
@Test public void testServerKeyPasswordDefaultsToPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.SERVER, "password", "password", "password", null); }
@Test public void testServerDifferentPasswordAndKeyPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.SERVER, "password", "keyPassword", "password", "keyPassword"); }
@Test public void testServerDifferentPasswordAndKeyPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.SERVER, "password", "keyPassword", "password", "keyPassword"); }
@Test public void testClientKeyPasswordDefaultsToPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.CLIENT, "password", "password", "password", null); }
@Test public void testClientDifferentPasswordAndKeyPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.CLIENT, "password", "keyPassword", "password", "keyPassword"); }
@Test public void testClientDifferentPasswordAndKeyPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.CLIENT, "password", "keyPassword", "password", "keyPassword"); }
@Test public void testClientKeyPasswordDefaultsToPassword() throws Exception { checkSSLFactoryInitWithPasswords(SSLFactory.Mode.CLIENT, "password", "password", "password", null); }
@Test public void testServerCredProviderPasswords() throws Exception { KeyStoreTestUtil.provisionPasswordsToCredentialProvider(); checkSSLFactoryInitWithPasswords(SSLFactory.Mode.SERVER, "storepass", "keypass", null, null, true); }
@Test public void testServerCredProviderPasswords() throws Exception { KeyStoreTestUtil.provisionPasswordsToCredentialProvider(); checkSSLFactoryInitWithPasswords(SSLFactory.Mode.SERVER, "storepass", "keypass", null, null, true); }