001    /****************************************************************
002     * Licensed to the Apache Software Foundation (ASF) under one   *
003     * or more contributor license agreements.  See the NOTICE file *
004     * distributed with this work for additional information        *
005     * regarding copyright ownership.  The ASF licenses this file   *
006     * to you under the Apache License, Version 2.0 (the            *
007     * "License"); you may not use this file except in compliance   *
008     * with the License.  You may obtain a copy of the License at   *
009     *                                                              *
010     *   http://www.apache.org/licenses/LICENSE-2.0                 *
011     *                                                              *
012     * Unless required by applicable law or agreed to in writing,   *
013     * software distributed under the License is distributed on an  *
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
015     * KIND, either express or implied.  See the License for the    *
016     * specific language governing permissions and limitations      *
017     * under the License.                                           *
018     ****************************************************************/
019    
020    package org.apache.james.protocols.smtp;
021    
022    import org.apache.james.protocols.api.ProtocolSession;
023    import org.apache.james.protocols.api.handler.LineHandler;
024    
025    /**
026     * All the handlers access this interface to communicate with
027     * SMTPHandler object
028     */
029    
030    public interface SMTPSession extends ProtocolSession{
031    
032        // Keys used to store/lookup data in the internal state hash map
033        /** Sender's email address */
034        final static String SENDER = "SENDER_ADDRESS";
035        /** The message recipients */
036        final static String RCPT_LIST = "RCPT_LIST";  
037        /** HELO or EHLO */
038        final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE";
039        final static String CURRENT_HELO_NAME = "CURRENT_HELO_NAME";
040    
041        /**
042         * Returns the service wide hello name
043         *
044         * @return the hello name
045         */
046        String getHelloName();
047        
048        /**
049         * Returns whether the remote server needs to send a HELO/EHLO
050         * of its senders.
051         *
052         * @return whether SMTP authentication is on
053         */
054        boolean useHeloEhloEnforcement();
055        
056        /**
057         * Return the SMTPGreeting which should used.
058         * 
059         * @return the SMTPGreeting
060         */
061        String getSMTPGreeting();
062        
063        /**
064         * Returns the service wide maximum message size in bytes.
065         *
066         * @return the maximum message size
067         */
068        long getMaxMessageSize();
069        
070        /**
071         * Return wheter the mailserver will accept addresses without brackets enclosed.
072         * 
073         * @return true or false
074         */
075        boolean useAddressBracketsEnforcement();
076        
077        /**
078         * Returns whether Relaying is allowed or not
079         *
080         * @return the relaying status
081         */
082        boolean isRelayingAllowed();
083        
084        /**
085         * Set if reallying is allowed
086         * 
087         * @param relayingAllowed
088         */
089        void setRelayingAllowed(boolean relayingAllowed);
090    
091        /**
092         * Returns whether Authentication is required or not
093         *
094         * @return authentication required or not
095         */
096        boolean isAuthSupported();
097    
098        
099        /**
100         * Returns the recipient count
101         * 
102         * @return recipient count
103         */
104        int getRcptCount();
105        
106        /**
107         * Put a new line handler in the chain
108         * @param overrideCommandHandler
109         */
110        void pushLineHandler(LineHandler<SMTPSession> overrideCommandHandler);
111        
112        /**
113         * Pop the last command handler 
114         */
115        void popLineHandler();
116        
117        /**
118         * Return the size of the pushed {@link LineHandler}
119         * @return size of the pushed line handler
120         */
121        int getPushedLineHandlerCount();
122        
123        
124    }
125