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 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 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. 025 AccountStatusNotificationHandlerCfg; 026import org.forgerock.opendj.config.server.ConfigException; 027import org.opends.server.types.AccountStatusNotification; 028import org.opends.server.types.InitializationException; 029 030 031 032/** 033 * This class defines the set of methods that must be implemented for 034 * an account status notification handler. This handler will be 035 * invoked whenever certain types of events occur that could change 036 * the status of a user account. The account status notification 037 * handler may be used to notify the user and/or administrators of the 038 * change. 039 * 040 * @param <T> The type of configuration handled by this notification 041 * handler. 042 */ 043@org.opends.server.types.PublicAPI( 044 stability=org.opends.server.types.StabilityLevel.VOLATILE, 045 mayInstantiate=false, 046 mayExtend=true, 047 mayInvoke=false) 048public abstract class 049 AccountStatusNotificationHandler 050 <T extends AccountStatusNotificationHandlerCfg> 051{ 052 /** 053 * Initializes this account status notification handler based on the 054 * information in the provided configuration entry. 055 * 056 * @param configuration The configuration entry that contains the 057 * information to use to initialize this 058 * account status notification handler. 059 * 060 * @throws ConfigException If the provided entry does not contain 061 * a valid configuration for this account 062 * status notification handler. 063 * 064 * @throws InitializationException If a problem occurs during 065 * initialization that is not 066 * related to the server 067 * configuration. 068 */ 069 public abstract void initializeStatusNotificationHandler( 070 T configuration) 071 throws ConfigException, InitializationException; 072 073 074 075 /** 076 * Indicates whether the provided configuration is acceptable for 077 * this account status notification handler. It should be possible 078 * to call this method on an uninitialized account status 079 * notification handler instance in order to determine whether the 080 * handler would be able to use the provided configuration. 081 * <BR><BR> 082 * Note that implementations which use a subclass of the provided 083 * configuration class will likely need to cast the configuration 084 * to the appropriate subclass type. 085 * 086 * @param configuration The account status notification 087 * handler configuration for which to 088 * make the determination. 089 * @param unacceptableReasons A list that may be used to hold the 090 * reasons that the provided 091 * configuration is not acceptable. 092 * 093 * @return {@code true} if the provided configuration is acceptable 094 * for this account status notification handler, or 095 * {@code false} if not. 096 */ 097 public boolean isConfigurationAcceptable( 098 AccountStatusNotificationHandlerCfg 099 configuration, 100 List<LocalizableMessage> unacceptableReasons) 101 { 102 // This default implementation does not perform any special 103 // validation. It should be overridden by account status 104 // notification implementations that wish to perform more detailed 105 // validation. 106 return true; 107 } 108 109 110 111 /** 112 * Performs any finalization that may be necessary when this status 113 * notification handler is taken out of service. 114 */ 115 public void finalizeStatusNotificationHandler() 116 { 117 // No action is required by default. 118 } 119 120 121 122 /** 123 * Performs any processing that may be necessary in conjunction with 124 * the provided account status notification. 125 * 126 * @param notification The account status notification to be 127 * processed. 128 */ 129 public abstract void handleStatusNotification( 130 AccountStatusNotification notification); 131} 132