本文整理汇总了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());
}
示例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());
}
示例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();
}
示例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));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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();
}
示例10: MultipleAuthenticationHandlerFactory
import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/** */
public MultipleAuthenticationHandlerFactory(Collection<AuthenticationHandlerFactory> factories)
{
for (AuthenticationHandlerFactory fact: factories)
{
this.addFactory(fact);
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例14: setAuthenticationHandlerFactory
import org.subethamail.smtp.AuthenticationHandlerFactory; //导入依赖的package包/类
/** */
public void setAuthenticationHandlerFactory(AuthenticationHandlerFactory fact)
{
this.authenticationHandlerFactory = fact;
}
示例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());
}