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 */
020package org.apache.directory.server.ldap.handlers.sasl;
021
022
023import javax.security.sasl.SaslServer;
024
025import org.apache.directory.api.ldap.model.message.BindRequest;
026import org.apache.directory.server.ldap.LdapSession;
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 */
035public interface MechanismHandler
036{
037    /**
038     * Implementors will use the session and message to determine what kind of
039     * {@link SaslServer} to create and what initialization parameters it will require.
040     *
041     * @param session The LdapSession in use
042     * @param bindRequest The BindRequest
043     * @return The {@link SaslServer} to use for the duration of the bound session.
044     * @throws Exception If we can't find the SASL Mechanism
045     */
046    SaslServer handleMechanism( LdapSession session, BindRequest bindRequest ) throws Exception;
047
048
049    /**
050     * Initialize the saslProperties with some mechanism's specific data
051     *
052     * @param ldapSession the Ldapsession instance
053     */
054    void init( LdapSession ldapSession );
055
056
057    /**
058     * Clean the Sasl properties when the use has been authenticated
059     *
060     * @param ldapSession the Ldapsession instance
061     */
062    void cleanup( LdapSession ldapSession );
063}