当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationHandlerFactory类代码示例

本文整理汇总了Java中org.subethamail.smtp.AuthenticationHandlerFactory的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationHandlerFactory类的具体用法?Java AuthenticationHandlerFactory怎么用?Java AuthenticationHandlerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationHandlerFactory类属于org.subethamail.smtp包,在下文中一共展示了AuthenticationHandlerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startup

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
@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());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:SubethaEmailServer.java

示例2: shouldConfigureAuthenticationWhenAuthenticationIsConfiguredProperly

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
@Test
public void shouldConfigureAuthenticationWhenAuthenticationIsConfiguredProperly(){
    final String username = "username";
    final String password = "password";
    final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
    when(authentication.getUsername()).thenReturn(username);
    when(authentication.getPassword()).thenReturn(password);
    when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);

    final SMTPServer smtpServer = mock(SMTPServer.class);

    sut.configure(smtpServer);

    ArgumentCaptor<AuthenticationHandlerFactory> argumentCaptor = ArgumentCaptor.forClass(AuthenticationHandlerFactory.class);
    verify(smtpServer).setAuthenticationHandlerFactory(argumentCaptor.capture());

    AuthenticationHandlerFactory authenticationHandlerFactory = argumentCaptor.getValue();
    assertNotNull(authenticationHandlerFactory);
    assertThat(authenticationHandlerFactory, instanceOf(EasyAuthenticationHandlerFactory.class));

    EasyAuthenticationHandlerFactory easyAuthenticationHandlerFactory = (EasyAuthenticationHandlerFactory)authenticationHandlerFactory;
    assertSame(basicUsernamePasswordValidator, easyAuthenticationHandlerFactory.getValidator());
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:24,代码来源:SmtpServerConfiguratorTest.java

示例3: SMTPServer

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/**
 * Complex constructor.
 * 
 * @param authHandlerFact
 *            the {@link AuthenticationHandlerFactory} which performs
 *            authentication in the SMTP AUTH command. If null,
 *            authentication is not supported. Note that setting an
 *            authentication handler does not enforce authentication, it
 *            only makes authentication possible. Enforcing authentication
 *            is the responsibility of the client application, which usually
 *            enforces it only selectively. Use
 *            {@link Session#isAuthenticated} to check whether the client
 *            was authenticated in the session.
 * @param executorService
 *            the ExecutorService which will handle client connections, one
 *            task per connection. The SMTPServer will shut down this
 *            ExecutorService when the SMTPServer itself stops. If null, a
 *            default one is created by
 *            {@link Executors#newCachedThreadPool()}.
 */
public SMTPServer(MessageHandlerFactory msgHandlerFact, AuthenticationHandlerFactory authHandlerFact, ExecutorService executorService)
{
	this.messageHandlerFactory = msgHandlerFact;
	this.authenticationHandlerFactory = authHandlerFact;

	if (executorService != null) {
		this.executorService = executorService;
	} else {
		this.executorService = Executors.newCachedThreadPool();
	}

	try
	{
		this.hostName = InetAddress.getLocalHost().getCanonicalHostName();
	}
	catch (UnknownHostException e)
	{
		this.hostName = UNKNOWN_HOSTNAME;
	}

	this.commandHandler = new CommandHandler();
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:43,代码来源:SMTPServer.java

示例4: shouldConfigureBasicParameters

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
@Test
public void shouldConfigureBasicParameters(){
    final Integer port = 1234;
    final InetAddress bindingAddress = mock(InetAddress.class);
    when(fakeSmtpConfigurationProperties.getPort()).thenReturn(port);
    when(fakeSmtpConfigurationProperties.getBindAddress()).thenReturn(bindingAddress);

    final SMTPServer smtpServer = mock(SMTPServer.class);

    sut.configure(smtpServer);

    verify(smtpServer).setPort(port);
    verify(smtpServer).setBindAddress(bindingAddress);
    verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:16,代码来源:SmtpServerConfiguratorTest.java

示例5: shouldSkipConfigurationOfAuthenticationWhenUsernameIsNull

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenUsernameIsNull(){
    final String password = "password";
    final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
    when(authentication.getUsername()).thenReturn(null);
    when(authentication.getPassword()).thenReturn(password);
    when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);

    final SMTPServer smtpServer = mock(SMTPServer.class);

    sut.configure(smtpServer);

    verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
    verify(logger).error(startsWith("Username"));
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:16,代码来源:SmtpServerConfiguratorTest.java

示例6: shouldSkipConfigurationOfAuthenticationWhenUsernameIsEmptyString

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenUsernameIsEmptyString(){
    final String password = "password";
    final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
    when(authentication.getUsername()).thenReturn("");
    when(authentication.getPassword()).thenReturn(password);
    when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);

    final SMTPServer smtpServer = mock(SMTPServer.class);

    sut.configure(smtpServer);

    verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
    verify(logger).error(startsWith("Username"));
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:16,代码来源:SmtpServerConfiguratorTest.java

示例7: shouldSkipConfigurationOfAuthenticationWhenPasswordIsNull

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenPasswordIsNull(){
    final String username = "username";
    final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
    when(authentication.getUsername()).thenReturn(username);
    when(authentication.getPassword()).thenReturn(null);
    when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);

    final SMTPServer smtpServer = mock(SMTPServer.class);

    sut.configure(smtpServer);

    verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
    verify(logger).error(startsWith("Password"));
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:16,代码来源:SmtpServerConfiguratorTest.java

示例8: shouldSkipConfigurationOfAuthenticationWhenPasswordIsEmptyString

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenPasswordIsEmptyString(){
    final String username = "username";
    final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
    when(authentication.getUsername()).thenReturn(username);
    when(authentication.getPassword()).thenReturn("");
    when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);

    final SMTPServer smtpServer = mock(SMTPServer.class);

    sut.configure(smtpServer);

    verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
    verify(logger).error(startsWith("Password"));
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:16,代码来源:SmtpServerConfiguratorTest.java

示例9: startSMTP

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
protected void startSMTP(String factory) {
  wiser = new Wiser();

  wiser.setPort(1587);
  wiser.getServer().setAuthenticationHandlerFactory(new AuthenticationHandlerFactory() {
    /*
     * AUTH PLAIN handler which returns success on any string
     */
    @Override
    public List<String> getAuthenticationMechanisms() {
      return Arrays.asList("PLAIN");
    }

    @Override
    public AuthenticationHandler create() {
      return new AuthenticationHandler() {

        @Override
        public String auth(final String clientInput) throws RejectException {
          log.info(clientInput);
          return null;
        }

        @Override
        public Object getIdentity() {
          return "username";
        }
      };
    }
  });

  Security.setProperty("ssl.SocketFactory.provider", factory);
  wiser.getServer().setEnableTLS(true);

  wiser.start();
}
 
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:37,代码来源:SMTPTestWiser.java

示例10: MultipleAuthenticationHandlerFactory

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/** */
public MultipleAuthenticationHandlerFactory(Collection<AuthenticationHandlerFactory> factories)
{
	for (AuthenticationHandlerFactory fact: factories)
	{
		this.addFactory(fact);
	}
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:9,代码来源:MultipleAuthenticationHandlerFactory.java

示例11: addFactory

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/** */
public void addFactory(AuthenticationHandlerFactory fact)
{
	List<String> partialMechanisms = fact.getAuthenticationMechanisms();
	for (String mechanism: partialMechanisms)
	{
		if (!this.mechanisms.contains(mechanism))
		{
			this.mechanisms.add(mechanism);
			this.plugins.put(mechanism, fact);
		}
	}
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:14,代码来源:MultipleAuthenticationHandlerFactory.java

示例12: startMailServer

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
public static Wiser startMailServer(String hostname, AuthenticationHandlerFactory authenticationHandlerFactory)
{
    Wiser server = new Wiser();
    server.getServer().setAuthenticationHandlerFactory(authenticationHandlerFactory);
    server.setHostname(hostname);
    server.setPort(0);
    server.start();
    return server;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:10,代码来源:TestUtils.java

示例13: getAuthenticationHandlerFactory

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/**
 * @return the factory for auth handlers, or null if no such factory has been set.
 */
public AuthenticationHandlerFactory getAuthenticationHandlerFactory()
{
	return this.authenticationHandlerFactory;
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:8,代码来源:SMTPServer.java

示例14: setAuthenticationHandlerFactory

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/** */
public void setAuthenticationHandlerFactory(AuthenticationHandlerFactory fact)
{
	this.authenticationHandlerFactory = fact;
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:6,代码来源:SMTPServer.java

示例15: execute

import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/** */
	@Override
	public void execute(String commandString, Session sess) throws IOException
	{
		String[] args = this.getArgs(commandString);
		if (args.length < 2)
		{
			sess.sendResponse("501 Syntax: EHLO hostname");
			return;
		}

		sess.resetMailTransaction();
		sess.setHelo(args[1]);

//		postfix returns...
//		250-server.host.name
//		250-PIPELINING
//		250-SIZE 10240000
//		250-ETRN
//		250 8BITMIME

		// Once upon a time this code tracked whether or not HELO/EHLO has been seen
		// already and gave an error msg.  However, this is stupid and pointless.
		// Postfix doesn't care, so we won't either.  If you want more, read:
		// http://homepages.tesco.net/J.deBoynePollard/FGA/smtp-avoid-helo.html

		StringBuilder response = new StringBuilder();

		response.append("250-");
		response.append(sess.getServer().getHostName());
		response.append("\r\n" + "250-8BITMIME");

		int maxSize = sess.getServer().getMaxMessageSize();
		if (maxSize > 0)
		{
			response.append("\r\n" + "250-SIZE ");
			response.append(maxSize);
		}

		// Enabling / Hiding TLS is a server setting
		if (sess.getServer().getEnableTLS() && !sess.getServer().getHideTLS())
		{
			response.append("\r\n" + "250-STARTTLS");
		}

		// Check to see if we support authentication
		AuthenticationHandlerFactory authFact = sess.getServer().getAuthenticationHandlerFactory();
		if (authFact != null)
		{
			List<String> supportedMechanisms = authFact.getAuthenticationMechanisms();
			if (!supportedMechanisms.isEmpty())
			{
				response.append("\r\n" + "250-" + AuthCommand.VERB + " ");
				response.append(TextUtils.joinTogether(supportedMechanisms, " "));
			}
		}

		response.append("\r\n" + "250 Ok");

		sess.sendResponse(response.toString());
	}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:62,代码来源:EhloCommand.java


注:本文中的org.subethamail.smtp.AuthenticationHandlerFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。