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.directory.server.ldap.handlers.bind;
021    
022    
023    import javax.security.sasl.SaslServer;
024    
025    import org.apache.directory.server.ldap.LdapSession;
026    import org.apache.directory.shared.ldap.message.internal.InternalBindRequest;
027    
028    
029    /**
030     * An interface for retrieving a {@link SaslServer} for a session.
031     * 
032     * @see javax.security.sasl.SaslServer
033     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034     * @version $Rev$, $Date$
035     */
036    public interface MechanismHandler
037    {
038        /**
039         * Implementors will use the session and message to determine what kind of
040         * {@link SaslServer} to create and what initialization parameters it will require.
041         *
042         * @param session
043         * @param bindRequest
044         * @return The {@link SaslServer} to use for the duration of the bound session.
045         * @throws Exception
046         */
047        public SaslServer handleMechanism( LdapSession session, InternalBindRequest bindRequest ) throws Exception;
048        
049        
050        /**
051         * Initialize the saslProperties with some mechanism's specific data
052         *
053         * @param ldapSession the Ldapsession instance
054         */
055        public void init( LdapSession ldapSession );
056        
057        
058        /**
059         * Clean the Sasl properties when the use has been authenticated
060         *
061         * @param ldapSession the Ldapsession instance
062         */
063        public void cleanup( LdapSession ldapSession );
064    }