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


Java AuthenticationHandler类代码示例

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


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

示例1: create

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
@Override
public AuthenticationHandler create()
{
    return new AuthenticationHandler() {
        @Override
        public String auth(String clientInput)
                throws RejectException
        {
            auth.add(clientInput);
            throw new RejectException();
        }

        @Override
        public Object getIdentity()
        {
            throw new AssertionError();
        }
    };
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:20,代码来源:ServerModeHiddenMailConfigIT.java

示例2: create

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
public AuthenticationHandler create() {
  PluginAuthenticationHandler ret = new PluginAuthenticationHandler();
  UsernamePasswordValidator validator = new UsernamePasswordValidator() {
    public void login(String username, String password)
            throws LoginFailedException {
      if (!username.equals(password)) {
        throw new LoginFailedException("username=" + username + ", password=" + password);
      }
    }
  };
  ret.addPlugin(new PlainAuthenticationHandler(validator));
  ret.addPlugin(new LoginAuthenticationHandler(validator));
  return ret;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:SMTPAppender_SubethaSMTPTest.java

示例3: startSMTP

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的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

示例4: create

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
@Override
   public AuthenticationHandler create() {
return smtpAuthHandler;
   }
 
开发者ID:sleroy,项目名称:fakesmtp-junit-runner,代码行数:5,代码来源:SMTPAuthHandlerFactory.java

示例5: testCreate

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
@Test
public void testCreate() throws Exception {
	AuthenticationHandler newAuthHandler = sMTPAuthHandlerFactory.create();
	Assert.assertEquals(smtpAuthHandler, newAuthHandler);

}
 
开发者ID:sleroy,项目名称:fakesmtp-junit-runner,代码行数:7,代码来源:SMTPAuthHandlerFactoryTest.java

示例6: create

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
@Override
public AuthenticationHandler create() {
    return new SMTPAuthHandler();
}
 
开发者ID:anlar,项目名称:LunaticSMTP,代码行数:5,代码来源:SMTPAuthHandlerFactory.java

示例7: create

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
/** */
public AuthenticationHandler create()
{
	return new Handler();
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:6,代码来源:MultipleAuthenticationHandlerFactory.java

示例8: getAuthenticationHandler

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
/** */
@Override
public AuthenticationHandler getAuthenticationHandler()
{
	return this.authenticationHandler;
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:7,代码来源:Session.java

示例9: setAuthenticationHandler

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
/**
 * This is called by the AuthCommand when a session is successfully authenticated.  The
 * handler will be an object created by the AuthenticationHandlerFactory.
 */
public void setAuthenticationHandler(AuthenticationHandler handler)
{
	this.authenticationHandler = handler;
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:9,代码来源:Session.java

示例10: execute

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
/** */
@Override
public void execute(String commandString, Session sess)
		throws IOException
{
	if (sess.isAuthenticated())
	{
		sess.sendResponse("503 Refusing any other AUTH command.");
		return;
	}

	AuthenticationHandlerFactory authFactory = sess.getServer().getAuthenticationHandlerFactory();

	if (authFactory == null)
	{
		sess.sendResponse("502 Authentication not supported");
		return;
	}

	AuthenticationHandler authHandler = authFactory.create();

	String[] args = this.getArgs(commandString);
	// Let's check the command syntax
	if (args.length < 2)
	{
		sess.sendResponse("501 Syntax: " + VERB + " mechanism [initial-response]");
		return;
	}

	// Let's check if we support the required authentication mechanism
	String mechanism = args[1];
	if (!authFactory.getAuthenticationMechanisms().contains(mechanism.toUpperCase(Locale.ENGLISH)))
	{
		sess.sendResponse("504 The requested authentication mechanism is not supported");
		return;
	}
	// OK, let's go trough the authentication process.
	try
	{
		// The authentication process may require a series of challenge-responses
		CRLFTerminatedReader reader = sess.getReader();

		String response = authHandler.auth(commandString);
		if (response != null)
		{
			// challenge-response iteration
			sess.sendResponse(response);
		}

		while (response != null)
		{
			String clientInput = reader.readLine();
			if (clientInput.trim().equals(AUTH_CANCEL_COMMAND))
			{
				// RFC 2554 explicitly states this:
				sess.sendResponse("501 Authentication canceled by client.");
				return;
			}
			else
			{
				response = authHandler.auth(clientInput);
				if (response != null)
				{
					// challenge-response iteration
					sess.sendResponse(response);
				}
			}
		}

		sess.sendResponse("235 Authentication successful.");
		sess.setAuthenticationHandler(authHandler);
	}
	catch (RejectException authFailed)
	{
		sess.sendResponse(authFailed.getErrorResponse());
	}
}
 
开发者ID:voodoodyne,项目名称:subethasmtp,代码行数:78,代码来源:AuthCommand.java

示例11: startMailServer

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
public static Wiser startMailServer(String hostname, String user, String password)
{
    AuthenticationHandlerFactory authenticationHandlerFactory = new AuthenticationHandlerFactory()
    {
        @Override
        public List<String> getAuthenticationMechanisms()
        {
            return ImmutableList.of("PLAIN");
        }

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

                private String identity;

                @Override
                public String auth(String clientInput)
                        throws RejectException
                {
                    String prefix = "AUTH PLAIN ";
                    if (!clientInput.startsWith(prefix)) {
                        throw new RejectException();
                    }
                    String credentialsBase64 = clientInput.substring(prefix.length());
                    byte[] credentials = Base64.getDecoder().decode(credentialsBase64);

                    // [authzid] UTF8NUL authcid UTF8NUL passwd
                    byte[] expectedCredentials = concat(
                            user.getBytes(UTF_8),
                            new byte[] {0},
                            user.getBytes(UTF_8),
                            new byte[] {0},
                            password.getBytes(UTF_8)
                    );

                    if (!Arrays.equals(credentials, expectedCredentials)) {
                        throw new RejectException();
                    }

                    this.identity = user;
                    return null;
                }

                @Override
                public Object getIdentity()
                {
                    return identity;
                }
            };
        }
    };
    return startMailServer(hostname, authenticationHandlerFactory);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:57,代码来源:TestUtils.java

示例12: isSatisfiedBy

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
@Override
public boolean isSatisfiedBy(MailTransaction mailTransaction) {
    AuthenticationHandler authenticationHandler =
            mailTransaction.getMessageContext().getAuthenticationHandler();
    return authenticationHandler != null;
}
 
开发者ID:hontvari,项目名称:mireka,代码行数:7,代码来源:SmtpAuthenticated.java

示例13: SMTPAuthHandlerFactory

import org.subethamail.smtp.AuthenticationHandler; //导入依赖的package包/类
/**
    * Instantiates a new SMTP auth handler factory.
    *
    * @param smtpAuthHandler
    *            the smtp auth handler
    */
   public SMTPAuthHandlerFactory(final AuthenticationHandler smtpAuthHandler) {
super();
this.smtpAuthHandler = smtpAuthHandler;
   }
 
开发者ID:sleroy,项目名称:fakesmtp-junit-runner,代码行数:11,代码来源:SMTPAuthHandlerFactory.java


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