Package mireka.filter.local

Source Code of mireka.filter.local.RefuseUnknownRecipient

package mireka.filter.local;

import mireka.destination.UnknownRecipientDestination;
import mireka.filter.FilterReply;
import mireka.filter.RecipientContext;
import mireka.filter.StatelessFilterType;
import mireka.smtp.RejectExceptionExt;
import mireka.smtp.UnknownUserException;

/**
* The RefuseUnknownRecipient filter rejects recipients whose destination has
* not been set (null) or whose destination is
* {@link UnknownRecipientDestination}. A destination must be assigned to the
* recipient before the {@link #verifyRecipient} method of this class is called.
*
* @see LookupDestinationFilter
*/
public class RefuseUnknownRecipient extends StatelessFilterType {

    @Override
    public FilterReply verifyRecipient(RecipientContext recipientContext)
            throws RejectExceptionExt {
        if (isKnown(recipientContext))
            return FilterReply.NEUTRAL;
        throw new UnknownUserException(recipientContext.recipient);
    }

    private boolean isKnown(RecipientContext recipientContext) {
        return recipientContext.isDestinationAssigned()
                && !(recipientContext.getDestination() instanceof UnknownRecipientDestination);
    }
}
TOP

Related Classes of mireka.filter.local.RefuseUnknownRecipient

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.