org.subethamail.smtp.AuthenticationHandler Java Examples
The following examples show how to use
org.subethamail.smtp.AuthenticationHandler.
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: ServerModeHiddenMailConfigIT.java From digdag with Apache License 2.0 | 6 votes |
@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(); } }; }
Example #2
Source File: SMTPTestWiser.java From vertx-mail-client with Apache License 2.0 | 5 votes |
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(); }
Example #3
Source File: MultipleAuthenticationHandlerFactory.java From subethasmtp with Apache License 2.0 | 4 votes |
/** */ public AuthenticationHandler create() { return new Handler(); }
Example #4
Source File: PlainAuthenticationHandlerFactory.java From subethasmtp with Apache License 2.0 | 4 votes |
/** */ public AuthenticationHandler create() { return new Handler(); }
Example #5
Source File: LoginAuthenticationHandlerFactory.java From subethasmtp with Apache License 2.0 | 4 votes |
/** */ public AuthenticationHandler create() { return new Handler(); }
Example #6
Source File: Session.java From subethasmtp with Apache License 2.0 | 4 votes |
/** */ @Override public AuthenticationHandler getAuthenticationHandler() { return this.authenticationHandler; }
Example #7
Source File: Session.java From subethasmtp with Apache License 2.0 | 4 votes |
/** * 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; }
Example #8
Source File: AuthCommand.java From subethasmtp with Apache License 2.0 | 4 votes |
/** */ @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()); } }
Example #9
Source File: TestUtils.java From digdag with Apache License 2.0 | 4 votes |
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); }
Example #10
Source File: SmtpAuthenticated.java From mireka with Apache License 2.0 | 4 votes |
@Override public boolean isSatisfiedBy(MailTransaction mailTransaction) { AuthenticationHandler authenticationHandler = mailTransaction.getMessageContext().getAuthenticationHandler(); return authenticationHandler != null; }
Example #11
Source File: MockAuthenticationHandlerFactory.java From entando-components with GNU Lesser General Public License v3.0 | 4 votes |
@Override public AuthenticationHandler create() { return new MockAuthenticationHandler(); }