001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Portions Copyright 2011-2016 ForgeRock AS.
015 */
016
017package org.opends.server.api;
018
019
020
021import java.util.List;
022
023import org.forgerock.i18n.LocalizableMessage;
024import org.forgerock.opendj.server.config.server.AuthenticationPolicyCfg;
025import org.forgerock.opendj.config.server.ConfigException;
026import org.opends.server.core.ServerContext;
027import org.opends.server.types.InitializationException;
028
029
030
031/**
032 * A factory for creating configurable authentication policies.
033 * <p>
034 * All implementations must have a default constructor, i.e. one that does not
035 * require and arguments.
036 *
037 * @param <T>
038 *          The type of authentication policy configuration handled by this
039 *          factory.
040 */
041public interface AuthenticationPolicyFactory<T extends AuthenticationPolicyCfg>
042{
043  /**
044   * Creates a new authentication policy using the provided configuration.
045   *
046   * @param configuration
047   *          The configuration.
048   * @return The new authentication policy configured using the provided
049   *         configuration.
050   * @throws ConfigException
051   *           If an unrecoverable problem arises during initialization of the
052   *           authentication policy as a result of the server configuration.
053   * @throws InitializationException
054   *           If a problem occurs during initialization of the authentication
055   *           policy.
056   */
057  AuthenticationPolicy createAuthenticationPolicy(T configuration)
058      throws ConfigException, InitializationException;
059
060
061
062  /**
063   * Indicates whether the provided authentication policy configuration is
064   * acceptable.
065   *
066   * @param configuration
067   *          The authentication policy configuration.
068   * @param unacceptableReasons
069   *          A list that can be used to hold messages about why the provided
070   *          configuration is not acceptable.
071   * @return Returns <code>true</code> if the provided authentication policy
072   *         configuration is acceptable, or <code>false</code> if it is not.
073   */
074  boolean isConfigurationAcceptable(T configuration,
075      List<LocalizableMessage> unacceptableReasons);
076
077
078  /**
079   * Sets the server context.
080   *
081   * @param serverContext
082   *            The server context.
083   */
084  void setServerContext(ServerContext serverContext);
085
086}