001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2014 ForgeRock AS
026 */
027package org.opends.server.api;
028
029
030
031import java.util.List;
032
033import org.forgerock.i18n.LocalizableMessage;
034import org.opends.server.admin.std.server.
035       AccountStatusNotificationHandlerCfg;
036import org.forgerock.opendj.config.server.ConfigException;
037import org.opends.server.types.AccountStatusNotification;
038import org.opends.server.types.InitializationException;
039
040
041
042/**
043 * This class defines the set of methods that must be implemented for
044 * an account status notification handler.  This handler will be
045 * invoked whenever certain types of events occur that could change
046 * the status of a user account.  The account status notification
047 * handler may be used to notify the user and/or administrators of the
048 * change.
049 *
050 * @param  <T>  The type of configuration handled by this notification
051 *              handler.
052 */
053@org.opends.server.types.PublicAPI(
054     stability=org.opends.server.types.StabilityLevel.VOLATILE,
055     mayInstantiate=false,
056     mayExtend=true,
057     mayInvoke=false)
058public abstract class
059       AccountStatusNotificationHandler
060       <T extends AccountStatusNotificationHandlerCfg>
061{
062  /**
063   * Initializes this account status notification handler based on the
064   * information in the provided configuration entry.
065   *
066   * @param  configuration  The configuration entry that contains the
067   *                        information to use to initialize this
068   *                        account status notification handler.
069   *
070   * @throws  ConfigException  If the provided entry does not contain
071   *                           a valid configuration for this account
072   *                           status notification handler.
073   *
074   * @throws  InitializationException  If a problem occurs during
075   *                                   initialization that is not
076   *                                   related to the server
077   *                                   configuration.
078   */
079  public abstract void initializeStatusNotificationHandler(
080         T configuration)
081         throws ConfigException, InitializationException;
082
083
084
085  /**
086   * Indicates whether the provided configuration is acceptable for
087   * this account status notification handler.  It should be possible
088   * to call this method on an uninitialized account status
089   * notification handler instance in order to determine whether the
090   * handler would be able to use the provided configuration.
091   * <BR><BR>
092   * Note that implementations which use a subclass of the provided
093   * configuration class will likely need to cast the configuration
094   * to the appropriate subclass type.
095   *
096   * @param  configuration        The account status notification
097   *                              handler configuration for which to
098   *                              make the determination.
099   * @param  unacceptableReasons  A list that may be used to hold the
100   *                              reasons that the provided
101   *                              configuration is not acceptable.
102   *
103   * @return  {@code true} if the provided configuration is acceptable
104   *          for this account status notification handler, or
105   *          {@code false} if not.
106   */
107  public boolean isConfigurationAcceptable(
108                      AccountStatusNotificationHandlerCfg
109                           configuration,
110                      List<LocalizableMessage> unacceptableReasons)
111  {
112    // This default implementation does not perform any special
113    // validation.  It should be overridden by account status
114    // notification implementations that wish to perform more detailed
115    // validation.
116    return true;
117  }
118
119
120
121  /**
122   * Performs any finalization that may be necessary when this status
123   * notification handler is taken out of service.
124   */
125  public void finalizeStatusNotificationHandler()
126  {
127    // No action is required by default.
128  }
129
130
131
132  /**
133   * Performs any processing that may be necessary in conjunction with
134   * the provided account status notification.
135   *
136   * @param  notification  The account status notification to be
137   *                       processed.
138   */
139  public abstract void handleStatusNotification(
140                            AccountStatusNotification notification);
141}
142