@Test public void shouldSendTestEmailWithSTARTTLS() { smtpServer.getServer().setEnableTLS(true); smtpServer.getServer().setRequireTLS(true); configure(); when(configuration.getSecureConnection()).thenReturn("STARTTLS"); try { underTest.sendTestEmail("user@nowhere", "Test Message from SonarQube", "This is a test message from SonarQube."); fail("An SSL exception was expected a a proof that STARTTLS is enabled"); } catch (EmailException e) { // We don't have a SSL certificate so we are expecting a SSL error assertThat(e.getCause().getMessage()).isEqualTo("Could not convert socket to TLS"); } }
@Override public void startup() { serverImpl = new SMTPServer(new HandlerFactory()); // MER - May need to override SMTPServer.createSSLSocket to specify non default keystore. serverImpl.setPort(getPort()); serverImpl.setHostName(getDomain()); serverImpl.setMaxConnections(getMaxConnections()); serverImpl.setHideTLS(isHideTLS()); serverImpl.setEnableTLS(isEnableTLS()); serverImpl.setRequireTLS(isRequireTLS()); if(isAuthenticate()) { AuthenticationHandlerFactory authenticationHandler = new EasyAuthenticationHandlerFactory(new AlfrescoLoginUsernamePasswordValidator()); serverImpl.setAuthenticationHandlerFactory(authenticationHandler); } serverImpl.start(); log.info("Inbound SMTP Email Server has started successfully, on hostName:" + getDomain() + "port:" + getPort()); }
@Override public void startup() { serverImpl = new SMTPServer(new HandlerFactory()); // MER - May need to override SMTPServer.createSSLSocket to specify non default keystore. serverImpl.setPort(getPort()); serverImpl.setHostName(getDomain()); serverImpl.setMaxConnections(getMaxConnections()); serverImpl.setHideTLS(isHideTLS()); serverImpl.setEnableTLS(isEnableTLS()); serverImpl.setRequireTLS(isRequireTLS()); if(isAuthenticate()) { AuthenticationHandlerFactory authenticationHandler = new EasyAuthenticationHandlerFactory(new AlfrescoLoginUsernamePasswordValidator()); serverImpl.setAuthenticationHandlerFactory(authenticationHandler); } serverImpl.start(); log.info("Inbound SMTP Email Server has started successfully, on hostName:" + getDomain() + "port:" + getPort()); }