All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.subethamail.smtp.internal.server.RequireTLSCommandWrapper Maven / Gradle / Ivy

Go to download

A fork of a fork (!) of SubEtha, an easy-to-use server-side SMTP library for Java.

There is a newer version: 7.1.3
Show newest version
package org.subethamail.smtp.internal.server;

import java.io.IOException;

import org.subethamail.smtp.DropConnectionException;
import org.subethamail.smtp.server.Session;

/**
 * Verifies the presence of a TLS connection if TLS is required.
 * The wrapped command is executed when the test succeeds.
 *
 * @author Erik van Oosten
 */
public final class RequireTLSCommandWrapper implements Command
{

	private final Command wrapped;

	/**
	 * @param wrapped the wrapped command (not null)
	 */
	public RequireTLSCommandWrapper(Command wrapped)
	{
		this.wrapped = wrapped;
	}

	@Override
    public void execute(String commandString, Session sess) 
			throws IOException, DropConnectionException
	{
		if (!sess.getServer().getRequireTLS() || sess.isTLSStarted())
			wrapped.execute(commandString, sess);
		else
			sess.sendResponse("530 Must issue a STARTTLS command first");
	}

	@Override
    public HelpMessage getHelp() throws CommandException
	{
		return wrapped.getHelp();
	}

	@Override
    public String getName()
	{
		return wrapped.getName();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy