org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory Java Examples
The following examples show how to use
org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubethaEmailServer.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@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()); }
Example #2
Source File: SmtpServerConfiguratorTest.java From fake-smtp-server with Apache License 2.0 | 6 votes |
@Test public void shouldConfigureAuthenticationWhenAuthenticationIsConfiguredProperly(){ var username = "username"; var password = "password"; var authentication = mock(FakeSmtpConfigurationProperties.Authentication.class); when(authentication.getUsername()).thenReturn(username); when(authentication.getPassword()).thenReturn(password); when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication); var smtpServer = mock(SMTPServer.class); sut.configure(smtpServer); var argumentCaptor = ArgumentCaptor.forClass(AuthenticationHandlerFactory.class); verify(smtpServer).setAuthenticationHandlerFactory(argumentCaptor.capture()); var authenticationHandlerFactory = argumentCaptor.getValue(); assertNotNull(authenticationHandlerFactory); assertThat(authenticationHandlerFactory, instanceOf(EasyAuthenticationHandlerFactory.class)); var easyAuthenticationHandlerFactory = (EasyAuthenticationHandlerFactory)authenticationHandlerFactory; assertSame(basicUsernamePasswordValidator, easyAuthenticationHandlerFactory.getValidator()); }
Example #3
Source File: SmtpServerConfigurator.java From fake-smtp-server with Apache License 2.0 | 5 votes |
private void configureAuthentication(SMTPServer smtpServer, FakeSmtpConfigurationProperties.Authentication authentication) { if (StringUtils.isEmpty(authentication.getUsername())) { logger.error("Username is missing; skip configuration of authentication"); } else if (StringUtils.isEmpty(authentication.getPassword())) { logger.error("Password is missing; skip configuration of authentication"); } else { logger.info("Setup simple username and password authentication for SMTP server"); smtpServer.setAuthenticationHandlerFactory(new EasyAuthenticationHandlerFactory(basicUsernamePasswordValidator)); } }
Example #4
Source File: RequireAuthTest.java From subethasmtp with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { this.wiser = new TestWiser(); this.wiser.setHostname("localhost"); this.wiser.setPort(PORT); UsernamePasswordValidator validator = new RequiredUsernamePasswordValidator(); EasyAuthenticationHandlerFactory fact = new EasyAuthenticationHandlerFactory(validator); this.wiser.getServer().setAuthenticationHandlerFactory(fact); this.wiser.getServer().setRequireAuth(true); this.wiser.start(); this.c = new Client("localhost", PORT); }
Example #5
Source File: AuthTest.java From subethasmtp with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { this.wiser = new TestWiser(); this.wiser.setHostname("localhost"); this.wiser.setPort(PORT); UsernamePasswordValidator validator = new RequiredUsernamePasswordValidator(); EasyAuthenticationHandlerFactory fact = new EasyAuthenticationHandlerFactory(validator); this.wiser.getServer().setAuthenticationHandlerFactory(fact); this.wiser.start(); this.c = new Client("localhost", PORT); }