@Test public void testConfigureStoreWithSSL() throws Exception { GetMailInput input = inputBuilder.build(); doReturn(objectMock).when(propertiesMock) .setProperty(String.format(PropNames.MAIL_SOCKET_FACTORY_CLASS, Constants.POP3), SecurityConstants.SSL_SOCKET_FACTORY); doReturn(objectMock).when(propertiesMock) .setProperty(String.format(PropNames.MAIL_SOCKET_FACTORY_FALLBACK, Constants.POP3), String.valueOf(false)); doReturn(objectMock).when(propertiesMock) .setProperty(String.format(PropNames.MAIL_PORT, Constants.POP3), Constants.POP3_PORT); doReturn(objectMock).when(propertiesMock) .setProperty(String.format(PropNames.MAIL_SOCKET_FACTORY_PORT, Constants.POP3), Constants.POP3_PORT); PowerMockito.mockStatic(Session.class); PowerMockito.doReturn(sessionMock).when(Session.class, "getInstance", Matchers.<Properties>any(), Matchers.<Authenticator>any()); doReturn(storeMock).when(sessionMock).getStore(any(URLName.class)); Store store = SSLUtils.configureStoreWithSSL(propertiesMock, authenticatorMock, input); assertEquals(storeMock, store); verify(propertiesMock).setProperty(String.format(PropNames.MAIL_SOCKET_FACTORY_CLASS, Constants.POP3), SecurityConstants.SSL_SOCKET_FACTORY); verify(propertiesMock).setProperty(String.format(PropNames.MAIL_SOCKET_FACTORY_FALLBACK, Constants.POP3), String.valueOf(false)); verify(propertiesMock).setProperty(String.format(PropNames.MAIL_PORT, Constants.POP3), Constants.POP3_PORT); verify(propertiesMock).setProperty(String.format(PropNames.MAIL_SOCKET_FACTORY_PORT, Constants.POP3), Constants.POP3_PORT); PowerMockito.verifyStatic(); Session.getInstance(Matchers.<Properties>any(), Matchers.<Authenticator>any()); verify(sessionMock).getStore(any(URLName.class)); }
public static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input) throws NoSuchProviderException { configureWithSSL(props, input); URLName url = new URLName(input.getProtocol(), input.getHostname(), input.getPort(), StringUtils.EMPTY, input.getUsername(), input.getPassword()); Session session = Session.getInstance(props, auth); return session.getStore(url); }
SSLUtils { public static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input) throws NoSuchProviderException { configureWithSSL(props, input); URLName url = new URLName(input.getProtocol(), input.getHostname(), input.getPort(), StringUtils.EMPTY, input.getUsername(), input.getPassword()); Session session = Session.getInstance(props, auth); return session.getStore(url); } }
SSLUtils { public static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input) throws NoSuchProviderException { configureWithSSL(props, input); URLName url = new URLName(input.getProtocol(), input.getHostname(), input.getPort(), StringUtils.EMPTY, input.getUsername(), input.getPassword()); Session session = Session.getInstance(props, auth); return session.getStore(url); }  }
SSLUtils { public static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input) throws NoSuchProviderException { configureWithSSL(props, input); URLName url = new URLName(input.getProtocol(), input.getHostname(), input.getPort(), StringUtils.EMPTY, input.getUsername(), input.getPassword()); Session session = Session.getInstance(props, auth); return session.getStore(url); }  static KeyStore createKeyStore(final URL url, final String password); static KeyManager[] createKeyManagers(final KeyStore keystore, final String password); static TrustManager[] createAuthTrustManagers(final KeyStore keystore); static Store createMessageStore(GetMailInput input); static void addSSLSettings(boolean trustAllRoots, String keystore,
                                      String keystorePassword, String trustKeystore, String trustPassword); static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input); static Store tryTLSOtherwiseTrySSL(Authenticator auth, Properties props, GetMailInput input); static Store configureStoreWithTLS(Properties props, Authenticator auth, MailInput input); static void configureWithTLS(Properties props, final MailInput input); static void clearTLSProperties(Properties props, MailInput input); }
SSLUtils { public static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input) throws NoSuchProviderException { configureWithSSL(props, input); URLName url = new URLName(input.getProtocol(), input.getHostname(), input.getPort(), StringUtils.EMPTY, input.getUsername(), input.getPassword()); Session session = Session.getInstance(props, auth); return session.getStore(url); }  static KeyStore createKeyStore(final URL url, final String password); static KeyManager[] createKeyManagers(final KeyStore keystore, final String password); static TrustManager[] createAuthTrustManagers(final KeyStore keystore); static Store createMessageStore(GetMailInput input); static void addSSLSettings(boolean trustAllRoots, String keystore,
                                      String keystorePassword, String trustKeystore, String trustPassword); static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input); static Store tryTLSOtherwiseTrySSL(Authenticator auth, Properties props, GetMailInput input); static Store configureStoreWithTLS(Properties props, Authenticator auth, MailInput input); static void configureWithTLS(Properties props, final MailInput input); static void clearTLSProperties(Properties props, MailInput input);  }