| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | * @throws InitializationException If a problem occurred while attempting to |
| | | * initialize the Access Control Handler. |
| | | */ |
| | | private AccessControlHandler<? extends AccessControlHandlerCfg> |
| | | private <T extends AccessControlHandlerCfg> AccessControlHandler<T> |
| | | loadHandler(String className, |
| | | AccessControlHandlerCfg configuration, |
| | | T configuration, |
| | | boolean initialize) |
| | | throws InitializationException |
| | | { |
| | |
| | | definition.getJavaClassPropertyDefinition(); |
| | | Class<? extends AccessControlHandler> providerClass = |
| | | propertyDefinition.loadClass(className, AccessControlHandler.class); |
| | | AccessControlHandler<? extends AccessControlHandlerCfg> provider = |
| | | providerClass.newInstance(); |
| | | AccessControlHandler<T> provider = providerClass.newInstance(); |
| | | |
| | | if (configuration != null) |
| | | { |
| | | Method method = provider.getClass().getMethod( |
| | | "initializeAccessControlHandler", |
| | | configuration.configurationClass()); |
| | | if(initialize) { |
| | | method.invoke(provider, configuration); |
| | | provider.initializeAccessControlHandler(configuration); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | provider.getClass().getMethod("isConfigurationAcceptable", |
| | | AccessControlHandlerCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(provider, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!provider.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | // Bug: we are in a section where configuration is null |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of account |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | AccountStatusNotificationHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | AccountStatusNotificationHandlerCfg configuration |
| | | ) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | AccountStatusNotificationHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | AccountStatusNotificationHandlerCfg configuration |
| | | ) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | AccountStatusNotificationHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | AccountStatusNotificationHandlerCfg configuration |
| | | ) |
| | |
| | | * @throws InitializationException If a problem occurred while attempting |
| | | * to initialize the notification handler. |
| | | */ |
| | | private |
| | | AccountStatusNotificationHandler |
| | | <? extends AccountStatusNotificationHandlerCfg> |
| | | loadNotificationHandler( |
| | | String className, |
| | | AccountStatusNotificationHandlerCfg configuration, |
| | | boolean initialize) |
| | | throws InitializationException |
| | | private <T extends AccountStatusNotificationHandlerCfg> |
| | | AccountStatusNotificationHandler<T> loadNotificationHandler( |
| | | String className, T configuration, boolean initialize) |
| | | throws InitializationException |
| | | { |
| | | try |
| | | { |
| | | AccountStatusNotificationHandlerCfgDefn definition; |
| | | ClassPropertyDefinition propertyDefinition; |
| | | Class<? extends AccountStatusNotificationHandler> handlerClass; |
| | | AccountStatusNotificationHandler |
| | | <? extends AccountStatusNotificationHandlerCfg> notificationHandler; |
| | | |
| | | definition = AccountStatusNotificationHandlerCfgDefn.getInstance(); |
| | | propertyDefinition = |
| | | final AccountStatusNotificationHandlerCfgDefn definition = |
| | | AccountStatusNotificationHandlerCfgDefn.getInstance(); |
| | | final ClassPropertyDefinition propertyDefinition = |
| | | definition.getJavaClassPropertyDefinition(); |
| | | handlerClass = propertyDefinition.loadClass( |
| | | className, |
| | | AccountStatusNotificationHandler.class |
| | | ); |
| | | notificationHandler = |
| | | (AccountStatusNotificationHandler |
| | | <? extends AccountStatusNotificationHandlerCfg>) |
| | | handlerClass.newInstance(); |
| | | final Class<? extends AccountStatusNotificationHandler> handlerClass = |
| | | propertyDefinition.loadClass(className, |
| | | AccountStatusNotificationHandler.class); |
| | | final AccountStatusNotificationHandler<T> notificationHandler = |
| | | handlerClass.newInstance(); |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = notificationHandler.getClass().getMethod( |
| | | "initializeStatusNotificationHandler", |
| | | configuration.configurationClass()); |
| | | method.invoke(notificationHandler, configuration); |
| | | notificationHandler.initializeStatusNotificationHandler(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | notificationHandler.getClass().getMethod( |
| | | "isConfigurationAcceptable", |
| | | AccountStatusNotificationHandlerCfg.class, List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(notificationHandler, |
| | | configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!notificationHandler.isConfigurationAcceptable(configuration, |
| | | unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.meta.AlertHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.AlertHandlerCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.api.AlertHandler; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(AlertHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(AlertHandlerCfg configuration) |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | AlertHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | AlertHandlerCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(AlertHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | AlertHandlerCfg configuration) |
| | | { |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = handler.getClass().getMethod("initializeAlertHandler", |
| | | configuration.configurationClass()); |
| | | method.invoke(handler, configuration); |
| | | handler.initializeAlertHandler(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | handler.getClass().getMethod("isConfigurationAcceptable", |
| | | AlertHandlerCfg.class, List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(handler, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!handler.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = syntax.getClass().getMethod("initializeSyntax", |
| | | configuration.configurationClass()); |
| | | method.invoke(syntax, configuration); |
| | | syntax.initializeSyntax(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = syntax.getClass().getMethod("isConfigurationAcceptable", |
| | | AttributeSyntaxCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(syntax, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!syntax.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = |
| | | mapper.getClass().getMethod("initializeCertificateMapper", |
| | | configuration.configurationClass()); |
| | | method.invoke(mapper, configuration); |
| | | mapper.initializeCertificateMapper(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = mapper.getClass().getMethod("isConfigurationAcceptable", |
| | | CertificateMapperCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(mapper, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!mapper.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.AdministrationConnector; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.meta.*; |
| | | import org.opends.server.admin.std.meta.ConnectionHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.AdministrationConnectorCfg; |
| | | import org.opends.server.admin.std.server.ConnectionHandlerCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | ConnectionHandlerCfg configuration) { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | ConnectionHandlerCfg configuration) { |
| | | // Attempt to get the existing connection handler. This will only |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | ConnectionHandlerCfg configuration) { |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | ConnectionHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | ConnectionHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | ConnectionHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | |
| | | |
| | | |
| | | // Load and initialize the connection handler named in the config. |
| | | private ConnectionHandler<? extends ConnectionHandlerCfg> |
| | | getConnectionHandler(ConnectionHandlerCfg config) |
| | | throws ConfigException |
| | | private <T extends ConnectionHandlerCfg> ConnectionHandler<T> getConnectionHandler( |
| | | T config) throws ConfigException |
| | | { |
| | | String className = config.getJavaClass(); |
| | | ConnectionHandlerCfgDefn d = |
| | | ConnectionHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d |
| | | .getJavaClassPropertyDefinition(); |
| | | |
| | | // Load the class and cast it to a connection handler. |
| | | @SuppressWarnings("rawtypes") |
| | | Class<? extends ConnectionHandler> theClass; |
| | | ConnectionHandler<?> connectionHandler; |
| | | ConnectionHandlerCfgDefn d = ConnectionHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | |
| | | try { |
| | | theClass = pd.loadClass(className, ConnectionHandler.class); |
| | | connectionHandler = theClass.newInstance(); |
| | | @SuppressWarnings("rawtypes") |
| | | Class<? extends ConnectionHandler> theClass = |
| | | pd.loadClass(className, ConnectionHandler.class); |
| | | ConnectionHandler<T> connectionHandler = theClass.newInstance(); |
| | | |
| | | connectionHandler.initializeConnectionHandler(config); |
| | | |
| | | return connectionHandler; |
| | | } catch (Exception e) { |
| | | logger.traceException(e); |
| | | |
| | |
| | | className, config.dn(), stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // Perform the necessary initialization for the connection |
| | | // handler. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeConnectionHandler", config |
| | | .configurationClass()); |
| | | |
| | | method.invoke(connectionHandler, config); |
| | | } catch (Exception e) { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = ERR_CONFIG_CONNHANDLER_CANNOT_INITIALIZE.get( |
| | | className, config.dn(), stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // The connection handler has been successfully initialized. |
| | | return connectionHandler; |
| | | } |
| | | |
| | | |
| | |
| | | ConnectionHandlerCfg config, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | String className = config.getJavaClass(); |
| | | ConnectionHandlerCfgDefn d = |
| | | ConnectionHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d |
| | | .getJavaClassPropertyDefinition(); |
| | | ConnectionHandlerCfgDefn d = ConnectionHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | |
| | | // Load the class and cast it to a connection handler. |
| | | ConnectionHandler<?> connectionHandler = null; |
| | | @SuppressWarnings("rawtypes") |
| | | Class<? extends ConnectionHandler> theClass; |
| | | try { |
| | | connectionHandler = connectionHandlers.get(config.dn()); |
| | | theClass = pd.loadClass(className, ConnectionHandler.class); |
| | | ConnectionHandler<?> connectionHandler = connectionHandlers.get(config.dn()); |
| | | if (connectionHandler == null) { |
| | | @SuppressWarnings("rawtypes") |
| | | Class<? extends ConnectionHandler> theClass = |
| | | pd.loadClass(className, ConnectionHandler.class); |
| | | connectionHandler = theClass.newInstance(); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.traceException(e); |
| | | |
| | | unacceptableReasons.add( |
| | | ERR_CONFIG_CONNHANDLER_CANNOT_INITIALIZE.get( |
| | | className, config.dn(), stackTraceToSingleLineString(e))); |
| | | return false; |
| | | } |
| | | |
| | | // Perform the necessary initialization for the connection |
| | | // handler. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("isConfigurationAcceptable", |
| | | ConnectionHandlerCfg.class, |
| | | List.class); |
| | | Boolean acceptable = (Boolean) method.invoke(connectionHandler, config, |
| | | unacceptableReasons); |
| | | |
| | | if (! acceptable) |
| | | { |
| | | return false; |
| | | } |
| | | return connectionHandler.isConfigurationAcceptable(config, unacceptableReasons); |
| | | } catch (Exception e) { |
| | | logger.traceException(e); |
| | | |
| | |
| | | className, config.dn(), stackTraceToSingleLineString(e))); |
| | | return false; |
| | | } |
| | | |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | // The default entry cache. |
| | | private DefaultEntryCache _defaultEntryCache = null; |
| | | private DefaultEntryCache _defaultEntryCache; |
| | | |
| | | // The entry cache order map sorted by the cache level. |
| | | private SortedMap<Integer, EntryCache<? extends |
| | | EntryCacheCfg>> cacheOrderMap = new TreeMap<Integer, |
| | | EntryCache<? extends EntryCacheCfg>>(); |
| | | @SuppressWarnings("rawtypes") |
| | | private SortedMap<Integer, EntryCache> cacheOrderMap = |
| | | new TreeMap<Integer, EntryCache>(); |
| | | |
| | | // The entry cache name to level map. |
| | | private HashMap<String, Integer> |
| | |
| | | |
| | | // Default entry cache should be already installed with |
| | | // <CODE>initializeDefaultEntryCache()</CODE> method so |
| | | // that there will be one even if we encounter a problem |
| | | // later. |
| | | // that there will be one even if we encounter a problem later. |
| | | |
| | | // Register as an add and delete listener with the root configuration so we |
| | | // can be notified if any entry cache entry is added or removed. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | EntryCacheCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | EntryCacheCfg configuration |
| | | ) |
| | |
| | | } |
| | | |
| | | // Push any changes made to the cache order map. |
| | | _defaultEntryCache.setCacheOrder(cacheOrderMap); |
| | | setCacheOrder(cacheOrderMap); |
| | | |
| | | // At this point, new configuration is enabled... |
| | | // If the current entry cache is already enabled then we don't do |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | EntryCacheCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | EntryCacheCfg configuration |
| | | ) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | EntryCacheCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | EntryCacheCfg configuration |
| | | ) |
| | |
| | | cacheNameToLevelMap.remove(configuration.dn().toNormalizedString()); |
| | | |
| | | // Push any changes made to the cache order map. |
| | | _defaultEntryCache.setCacheOrder(cacheOrderMap); |
| | | setCacheOrder(cacheOrderMap); |
| | | |
| | | entryCache = null; |
| | | } |
| | |
| | | configuration.getCacheLevel()); |
| | | |
| | | // Push any changes made to the cache order map. |
| | | _defaultEntryCache.setCacheOrder(cacheOrderMap); |
| | | setCacheOrder(cacheOrderMap); |
| | | |
| | | // Install and register the monitor for this cache. |
| | | EntryCacheMonitorProvider monitor = |
| | |
| | | DirectoryServer.registerMonitorProvider(monitor); |
| | | } |
| | | |
| | | @SuppressWarnings({ "rawtypes", "unchecked" }) |
| | | private void setCacheOrder(SortedMap<Integer, EntryCache> cacheOrderMap) |
| | | { |
| | | _defaultEntryCache.setCacheOrder((SortedMap) cacheOrderMap); |
| | | } |
| | | |
| | | /** |
| | | * Loads the specified class, instantiates it as an entry cache, and |
| | |
| | | * @throws InitializationException If a problem occurred while attempting |
| | | * to initialize the entry cache. |
| | | */ |
| | | private EntryCache<? extends EntryCacheCfg> loadEntryCache( |
| | | private <T extends EntryCacheCfg> EntryCache<T> loadEntryCache( |
| | | String className, |
| | | EntryCacheCfg configuration, |
| | | T configuration, |
| | | boolean initialize |
| | | ) |
| | | throws InitializationException |
| | | { |
| | | EntryCache<?> entryCache = null; |
| | | |
| | | // If we this entry cache is already installed and active it |
| | | // should be present in the current cache order map, use it. |
| | | EntryCache<T> entryCache = null; |
| | | if (!cacheOrderMap.isEmpty()) { |
| | | entryCache = cacheOrderMap.get(configuration.getCacheLevel()); |
| | | } |
| | |
| | | ClassPropertyDefinition propertyDefinition = definition |
| | | .getJavaClassPropertyDefinition(); |
| | | @SuppressWarnings("unchecked") |
| | | Class<? extends EntryCache<?>> cacheClass = |
| | | (Class<? extends EntryCache<?>>) propertyDefinition |
| | | Class<? extends EntryCache<T>> cacheClass = |
| | | (Class<? extends EntryCache<T>>) propertyDefinition |
| | | .loadClass(className, EntryCache.class); |
| | | |
| | | // If there is some entry cache instance already initialized work with |
| | | // it instead of creating a new one unless explicit init is requested. |
| | | EntryCache<? extends EntryCacheCfg> cache; |
| | | EntryCache<T> cache; |
| | | if (initialize || (entryCache == null)) { |
| | | cache = cacheClass.newInstance(); |
| | | } else { |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = cache.getClass().getMethod("initializeEntryCache", |
| | | configuration.configurationClass()); |
| | | method.invoke(cache, configuration); |
| | | cache.initializeEntryCache(configuration); |
| | | } |
| | | // This will check if configuration is acceptable on disabled |
| | | // and uninitialized cache instance that has no "acceptable" |
| | | // change listener registered to invoke and verify on its own. |
| | | else if (!configuration.isEnabled()) |
| | | { |
| | | Method method = cache.getClass().getMethod("isConfigurationAcceptable", |
| | | EntryCacheCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(cache, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!cache.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String buffer = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.lang.reflect.Method; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.meta.ExtendedOperationHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.std.meta.ExtendedOperationHandlerCfgDefn; |
| | | import org.opends.server.api.ExtendedOperationHandler; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of extended |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | ExtendedOperationHandlerCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | ExtendedOperationHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | ExtendedOperationHandlerCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | ExtendedOperationHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | ExtendedOperationHandlerCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | ExtendedOperationHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | { |
| | | String className = config.getJavaClass(); |
| | | ExtendedOperationHandlerCfgDefn d = |
| | | ExtendedOperationHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d |
| | | .getJavaClassPropertyDefinition(); |
| | | |
| | | // Load the class and cast it to an extended operation handler. |
| | | Class<? extends ExtendedOperationHandler> theClass; |
| | | ExtendedOperationHandler extendedOperationHandler; |
| | | ExtendedOperationHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | |
| | | try |
| | | { |
| | | theClass = pd.loadClass(className, ExtendedOperationHandler.class); |
| | | extendedOperationHandler = theClass.newInstance(); |
| | | Class<? extends ExtendedOperationHandler> theClass = |
| | | pd.loadClass(className, ExtendedOperationHandler.class); |
| | | ExtendedOperationHandler extendedOperationHandler = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeExtendedOperationHandler", |
| | | config.configurationClass()); |
| | | extendedOperationHandler.initializeExtendedOperationHandler(config); |
| | | |
| | | method.invoke(extendedOperationHandler, config); |
| | | return extendedOperationHandler; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | throw new ConfigException(ERR_CONFIG_EXTOP_INVALID_CLASS.get(className, config.dn(), e), e); |
| | | } |
| | | |
| | | // The handler has been successfully initialized. |
| | | return extendedOperationHandler; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | String className = config.getJavaClass(); |
| | | ExtendedOperationHandlerCfgDefn d = |
| | | ExtendedOperationHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d |
| | | .getJavaClassPropertyDefinition(); |
| | | ExtendedOperationHandlerCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | |
| | | // Load the class and cast it to an extended operation handler. |
| | | Class<? extends ExtendedOperationHandler> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, ExtendedOperationHandler.class); |
| | | Class<? extends ExtendedOperationHandler> theClass = |
| | | pd.loadClass(className, ExtendedOperationHandler.class); |
| | | ExtendedOperationHandler extOpHandler = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("isConfigurationAcceptable", |
| | | ExtendedOperationHandlerCfg.class, |
| | | List.class); |
| | | Boolean acceptable = (Boolean) method.invoke(extOpHandler, config, |
| | | unacceptableReasons); |
| | | |
| | | if (! acceptable) |
| | | { |
| | | return false; |
| | | } |
| | | return extOpHandler.isConfigurationAcceptable(config, unacceptableReasons); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | unacceptableReasons.add(ERR_CONFIG_EXTOP_INVALID_CLASS.get(className, config.dn(), e)); |
| | | return false; |
| | | } |
| | | |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = extension.getClass().getMethod( |
| | | "initializeExtension", configuration.configurationClass()); |
| | | method.invoke(extension, configuration); |
| | | extension.initializeExtension(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | extension.getClass().getMethod("isConfigurationAcceptable", |
| | | ExtensionCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(extension, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!extension.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.locks.ReentrantReadWriteLock; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = group.getClass().getMethod( |
| | | "initializeGroupImplementation", configuration.configurationClass()); |
| | | method.invoke(group, configuration); |
| | | group.initializeGroupImplementation(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = group.getClass().getMethod("isConfigurationAcceptable", |
| | | GroupImplementationCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(group, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!group.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reason = Utils.joinAsString(". ", unacceptableReasons); |
| | | LocalizableMessage message = ERR_CONFIG_GROUP_CONFIG_NOT_ACCEPTABLE.get( |
| | | configuration.dn(), reason); |
| | | throw new InitializationException(message); |
| | | throw new InitializationException(ERR_CONFIG_GROUP_CONFIG_NOT_ACCEPTABLE.get( |
| | | configuration.dn(), reason)); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = mapper.getClass().getMethod("initializeIdentityMapper", |
| | | configuration.configurationClass()); |
| | | method.invoke(mapper, configuration); |
| | | mapper.initializeIdentityMapper(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = mapper.getClass().getMethod("isConfigurationAcceptable", |
| | | IdentityMapperCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(mapper, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!mapper.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = provider.getClass().getMethod( |
| | | "initializeKeyManagerProvider", configuration.configurationClass()); |
| | | method.invoke(provider, configuration); |
| | | provider.initializeKeyManagerProvider(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | provider.getClass().getMethod("isConfigurationAcceptable", |
| | | KeyManagerProviderCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(provider, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!provider.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.admin.std.server.LogRetentionPolicyCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.std.meta.LogRetentionPolicyCfgDefn; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.loggers.RetentionPolicy; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of |
| | | * log retention policies used in the Directory Server. It will perform the |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | LogRetentionPolicyCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | LogRetentionPolicyCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(LogRetentionPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | LogRetentionPolicyCfg config) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | LogRetentionPolicyCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | LogRetentionPolicyCfg configuration) |
| | | { |
| | |
| | | { |
| | | String className = config.getJavaClass(); |
| | | LogRetentionPolicyCfgDefn d = LogRetentionPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a RetentionPolicy. |
| | | Class<? extends RetentionPolicy> theClass; |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | try { |
| | | theClass = pd.loadClass(className, RetentionPolicy.class); |
| | | theClass.newInstance(); |
| | | Class<? extends RetentionPolicy> theClass = |
| | | pd.loadClass(className, RetentionPolicy.class); |
| | | // Explicitly cast to check that implementation implements the correct interface. |
| | | RetentionPolicy retentionPolicy = theClass.newInstance(); |
| | | // next line is here to ensure that eclipse does not remove the cast in the line above |
| | | retentionPolicy.hashCode(); |
| | | return true; |
| | | } catch (Exception e) { |
| | | unacceptableReasons.add( |
| | | ERR_CONFIG_RETENTION_POLICY_INVALID_CLASS.get(className, config.dn(), e)); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | theClass.getMethod("initializeLogRetentionPolicy", config |
| | | .configurationClass()); |
| | | } catch (Exception e) { |
| | | unacceptableReasons.add( |
| | | ERR_CONFIG_RETENTION_POLICY_INVALID_CLASS.get(className, config.dn(), e)); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private RetentionPolicy getRetentionPolicy(LogRetentionPolicyCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaClass(); |
| | | LogRetentionPolicyCfgDefn d = LogRetentionPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a RetentionPolicy. |
| | | Class<? extends RetentionPolicy> theClass; |
| | | RetentionPolicy RetentionPolicy; |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | try { |
| | | theClass = pd.loadClass(className, RetentionPolicy.class); |
| | | RetentionPolicy = theClass.newInstance(); |
| | | Class<? extends RetentionPolicy> theClass = |
| | | pd.loadClass(className, RetentionPolicy.class); |
| | | RetentionPolicy retentionPolicy = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeLogRetentionPolicy", config |
| | | .configurationClass()); |
| | | method.invoke(RetentionPolicy, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | LocalizableMessage message = ERR_CONFIG_RETENTION_POLICY_INVALID_CLASS.get( |
| | | className, config.dn(), stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(message, e); |
| | | retentionPolicy.initializeLogRetentionPolicy(config); |
| | | |
| | | return retentionPolicy; |
| | | } catch (Exception e) { |
| | | LocalizableMessage message = ERR_CONFIG_RETENTION_POLICY_INVALID_CLASS.get( |
| | | className, config.dn(), e); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // The connection handler has been successfully initialized. |
| | | return RetentionPolicy; |
| | | } |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.loggers.RotationPolicy; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of |
| | | * log rotation policies used in the Directory Server. It will perform the |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | LogRotationPolicyCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | LogRotationPolicyCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(LogRotationPolicyCfg config) |
| | | { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | LogRotationPolicyCfg config) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | LogRotationPolicyCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | LogRotationPolicyCfg configuration) |
| | | { |
| | |
| | | { |
| | | String className = config.getJavaClass(); |
| | | LogRotationPolicyCfgDefn d = LogRotationPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a RotationPolicy. |
| | | Class<? extends RotationPolicy> theClass; |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | try { |
| | | theClass = pd.loadClass(className, RotationPolicy.class); |
| | | theClass.newInstance(); |
| | | Class<? extends RotationPolicy> theClass = |
| | | pd.loadClass(className, RotationPolicy.class); |
| | | // Explicitly cast to check that implementation implements the correct interface. |
| | | RotationPolicy retentionPolicy = theClass.newInstance(); |
| | | // next line is here to ensure that eclipse does not remove the cast in the line above |
| | | retentionPolicy.hashCode(); |
| | | return true; |
| | | } catch (Exception e) { |
| | | unacceptableReasons.add( |
| | | ERR_CONFIG_ROTATION_POLICY_INVALID_CLASS.get(className, config.dn(), e)); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | theClass.getMethod("initializeLogRotationPolicy", config |
| | | .configurationClass()); |
| | | } catch (Exception e) { |
| | | unacceptableReasons.add( |
| | | ERR_CONFIG_ROTATION_POLICY_INVALID_CLASS.get(className, config.dn(), e)); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private RotationPolicy getRotationPolicy(LogRotationPolicyCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaClass(); |
| | | LogRotationPolicyCfgDefn d = LogRotationPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a RotationPolicy. |
| | | Class<? extends RotationPolicy> theClass; |
| | | RotationPolicy rotationPolicy; |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | try { |
| | | theClass = pd.loadClass(className, RotationPolicy.class); |
| | | rotationPolicy = theClass.newInstance(); |
| | | Class<? extends RotationPolicy> theClass = |
| | | pd.loadClass(className, RotationPolicy.class); |
| | | RotationPolicy rotationPolicy = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeLogRotationPolicy", config |
| | | .configurationClass()); |
| | | method.invoke(rotationPolicy, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | LocalizableMessage message = ERR_CONFIG_ROTATION_POLICY_INVALID_CLASS.get( |
| | | className, config.dn(), stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(message, e); |
| | | rotationPolicy.initializeLogRotationPolicy(config); |
| | | |
| | | return rotationPolicy; |
| | | } catch (Exception e) { |
| | | LocalizableMessage message = ERR_CONFIG_ROTATION_POLICY_INVALID_CLASS.get( |
| | | className, config.dn(), e); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // The connection handler has been successfully initialized. |
| | | return rotationPolicy; |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = factory.getClass().getMethod( |
| | | "initializeMatchingRule", configuration.configurationClass()); |
| | | method.invoke(factory, configuration); |
| | | factory.initializeMatchingRule(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | factory.getClass().getMethod("isConfigurationAcceptable", |
| | | MatchingRuleCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(factory, |
| | | configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!factory.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | * @throws InitializationException If a problem occurred while attempting to |
| | | * initialize the monitor provider. |
| | | */ |
| | | private MonitorProvider<? extends MonitorProviderCfg> |
| | | loadMonitor(String className, MonitorProviderCfg configuration) |
| | | private <T extends MonitorProviderCfg> MonitorProvider<T> |
| | | loadMonitor(String className, T configuration) |
| | | throws InitializationException |
| | | { |
| | | try |
| | | { |
| | | MonitorProviderCfgDefn definition = |
| | | MonitorProviderCfgDefn.getInstance(); |
| | | MonitorProviderCfgDefn definition = MonitorProviderCfgDefn.getInstance(); |
| | | ClassPropertyDefinition propertyDefinition = |
| | | definition.getJavaClassPropertyDefinition(); |
| | | @SuppressWarnings("unchecked") |
| | | Class<? extends MonitorProvider<?>> providerClass = |
| | | (Class<? extends MonitorProvider<?>>) propertyDefinition |
| | | Class<? extends MonitorProvider<T>> providerClass = |
| | | (Class<? extends MonitorProvider<T>>) propertyDefinition |
| | | .loadClass(className, MonitorProvider.class); |
| | | MonitorProvider<?> monitor = providerClass.newInstance(); |
| | | MonitorProvider<T> monitor = providerClass.newInstance(); |
| | | |
| | | if (configuration != null) |
| | | { |
| | | Method method = monitor.getClass().getMethod( |
| | | "initializeMonitorProvider", configuration.configurationClass()); |
| | | method.invoke(monitor, configuration); |
| | | monitor.initializeMonitorProvider(configuration); |
| | | } |
| | | |
| | | return (MonitorProvider<? extends MonitorProviderCfg>) monitor; |
| | | return monitor; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | * @throws InitializationException If a problem occurred while attempting to |
| | | * initialize the password generator. |
| | | */ |
| | | private PasswordGenerator<? extends PasswordGeneratorCfg> |
| | | private <T extends PasswordGeneratorCfg> PasswordGenerator<T> |
| | | loadGenerator(String className, |
| | | PasswordGeneratorCfg configuration, |
| | | T configuration, |
| | | boolean initialize) |
| | | throws InitializationException |
| | | { |
| | |
| | | definition.getJavaClassPropertyDefinition(); |
| | | Class<? extends PasswordGenerator> generatorClass = |
| | | propertyDefinition.loadClass(className, PasswordGenerator.class); |
| | | PasswordGenerator<? extends PasswordGeneratorCfg> generator = |
| | | (PasswordGenerator<? extends PasswordGeneratorCfg>) |
| | | generatorClass.newInstance(); |
| | | PasswordGenerator<T> generator = generatorClass.newInstance(); |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = generator.getClass().getMethod( |
| | | "initializePasswordGenerator", configuration.configurationClass()); |
| | | method.invoke(generator, configuration); |
| | | generator.initializePasswordGenerator(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | generator.getClass().getMethod("isConfigurationAcceptable", |
| | | PasswordGeneratorCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(generator, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!generator.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | |
| | | import org.opends.server.api.AuthenticationPolicyFactory; |
| | | import org.opends.server.api.SubentryChangeListener; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of password |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | AuthenticationPolicyCfg configuration, List<LocalizableMessage> unacceptableReason) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | AuthenticationPolicyCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | AuthenticationPolicyCfg configuration, List<LocalizableMessage> unacceptableReason) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | AuthenticationPolicyCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void checkSubentryAddAcceptable(Entry entry) throws DirectoryException |
| | | { |
| | | if (entry.isPasswordPolicySubentry()) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void checkSubentryDeleteAcceptable(Entry entry) |
| | | throws DirectoryException |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void checkSubentryModifyAcceptable(Entry oldEntry, Entry newEntry) |
| | | throws DirectoryException |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void checkSubentryModifyDNAcceptable(Entry oldEntry, Entry newEntry) |
| | | throws DirectoryException |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void handleSubentryAdd(Entry entry) |
| | | { |
| | | if (entry.isPasswordPolicySubentry()) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void handleSubentryDelete(Entry entry) |
| | | { |
| | | if (entry.isPasswordPolicySubentry()) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void handleSubentryModify(Entry oldEntry, Entry newEntry) |
| | | { |
| | | if (oldEntry.isPasswordPolicySubentry()) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void handleSubentryModifyDN(Entry oldEntry, Entry newEntry) |
| | | { |
| | | if (oldEntry.isPasswordPolicySubentry()) |
| | |
| | | |
| | | // Creates and registers the provided authentication policy |
| | | // configuration. |
| | | private void createAuthenticationPolicy( |
| | | AuthenticationPolicyCfg policyConfiguration) throws ConfigException, |
| | | InitializationException |
| | | private <T extends AuthenticationPolicyCfg> void createAuthenticationPolicy( |
| | | T policyConfiguration) throws ConfigException, InitializationException |
| | | { |
| | | // If this is going to be the default password policy then check the type is |
| | | // correct. |
| | |
| | | AuthenticationPolicyCfgDefn d = AuthenticationPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | |
| | | // Load the class and cast it to an authentication policy. |
| | | Class<?> theClass; |
| | | AuthenticationPolicyFactory<?> factory; |
| | | |
| | | try |
| | | { |
| | | theClass = pd.loadClass(className, AuthenticationPolicyFactory.class); |
| | | factory = (AuthenticationPolicyFactory<?>) theClass.newInstance(); |
| | | Class<AuthenticationPolicyFactory<T>> theClass = |
| | | (Class<AuthenticationPolicyFactory<T>>) pd.loadClass(className, |
| | | AuthenticationPolicyFactory.class); |
| | | AuthenticationPolicyFactory<T> factory = theClass.newInstance(); |
| | | factory.setServerContext(serverContext); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = ERR_CONFIG_PWPOLICY_INVALID_POLICY_CONFIG.get( |
| | | policyConfiguration.dn(), stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | AuthenticationPolicy policy = factory.createAuthenticationPolicy(policyConfiguration); |
| | | |
| | | // Perform the necessary initialization for the authentication policy. |
| | | AuthenticationPolicy policy; |
| | | try |
| | | { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("createAuthenticationPolicy", |
| | | policyConfiguration.configurationClass()); |
| | | |
| | | policy = (AuthenticationPolicy) method.invoke(factory, |
| | | policyConfiguration); |
| | | DirectoryServer.registerAuthenticationPolicy(policyConfiguration.dn(), policy); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | policyConfiguration.dn(), stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | |
| | | DirectoryServer.registerAuthenticationPolicy(policyConfiguration.dn(), policy); |
| | | } |
| | | |
| | | |
| | | |
| | | // Determines whether or not the new authentication policy configuration's |
| | | // implementation class is acceptable. |
| | | private boolean isAuthenticationPolicyConfigurationAcceptable( |
| | | AuthenticationPolicyCfg policyConfiguration, |
| | | private <T extends AuthenticationPolicyCfg> boolean isAuthenticationPolicyConfigurationAcceptable( |
| | | T policyConfiguration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | // If this is going to be the default password policy then check the type is |
| | |
| | | // Validate the configuration. |
| | | try |
| | | { |
| | | // Load the class and cast it to a authentication policy factory. |
| | | Class<?> theClass; |
| | | AuthenticationPolicyFactory<?> factory; |
| | | |
| | | theClass = pd.loadClass(className, AuthenticationPolicyFactory.class); |
| | | factory = (AuthenticationPolicyFactory<?>) theClass.newInstance(); |
| | | Class<?> theClass = |
| | | pd.loadClass(className, AuthenticationPolicyFactory.class); |
| | | AuthenticationPolicyFactory<T> factory = |
| | | (AuthenticationPolicyFactory<T>) theClass.newInstance(); |
| | | factory.setServerContext(serverContext); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("isConfigurationAcceptable", |
| | | AuthenticationPolicyCfg.class, List.class); |
| | | return (Boolean) method.invoke(factory, policyConfiguration, |
| | | unacceptableReasons); |
| | | return factory.isConfigurationAcceptable(policyConfiguration, unacceptableReasons); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | * @throws InitializationException If a problem occurred while attempting |
| | | * to initialize the class. |
| | | */ |
| | | private PasswordStorageScheme <? extends PasswordStorageSchemeCfg> |
| | | private <T extends PasswordStorageSchemeCfg> PasswordStorageScheme<T> |
| | | loadPasswordStorageScheme( |
| | | String className, |
| | | PasswordStorageSchemeCfg configuration, |
| | | T configuration, |
| | | boolean initialize) |
| | | throws InitializationException |
| | | { |
| | | try |
| | | { |
| | | PasswordStorageSchemeCfgDefn definition; |
| | | ClassPropertyDefinition propertyDefinition; |
| | | Class<? extends PasswordStorageScheme> schemeClass; |
| | | PasswordStorageScheme<? extends PasswordStorageSchemeCfg> |
| | | passwordStorageScheme; |
| | | |
| | | definition = PasswordStorageSchemeCfgDefn.getInstance(); |
| | | PasswordStorageSchemeCfgDefn definition = PasswordStorageSchemeCfgDefn.getInstance(); |
| | | propertyDefinition = definition.getJavaClassPropertyDefinition(); |
| | | schemeClass = propertyDefinition.loadClass( |
| | | className, |
| | | PasswordStorageScheme.class |
| | | ); |
| | | passwordStorageScheme = |
| | | (PasswordStorageScheme<? extends PasswordStorageSchemeCfg>) |
| | | schemeClass.newInstance(); |
| | | schemeClass = propertyDefinition.loadClass(className, PasswordStorageScheme.class); |
| | | PasswordStorageScheme<T> passwordStorageScheme = schemeClass.newInstance(); |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = passwordStorageScheme.getClass().getMethod( |
| | | "initializePasswordStorageScheme", |
| | | configuration.configurationClass()); |
| | | method.invoke(passwordStorageScheme, configuration); |
| | | passwordStorageScheme.initializePasswordStorageScheme(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = passwordStorageScheme.getClass().getMethod( |
| | | "isConfigurationAcceptable", |
| | | PasswordStorageSchemeCfg.class, List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(passwordStorageScheme, |
| | | configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!passwordStorageScheme.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | * @throws InitializationException If a problem occurred while attempting to |
| | | * initialize the password validator. |
| | | */ |
| | | private PasswordValidator<? extends PasswordValidatorCfg> |
| | | private <T extends PasswordValidatorCfg> PasswordValidator<T> |
| | | loadValidator(String className, |
| | | PasswordValidatorCfg configuration, |
| | | T configuration, |
| | | boolean initialize) |
| | | throws InitializationException |
| | | { |
| | |
| | | definition.getJavaClassPropertyDefinition(); |
| | | Class<? extends PasswordValidator> validatorClass = |
| | | propertyDefinition.loadClass(className, PasswordValidator.class); |
| | | PasswordValidator<? extends PasswordValidatorCfg> validator = |
| | | (PasswordValidator<? extends PasswordValidatorCfg>) |
| | | validatorClass.newInstance(); |
| | | PasswordValidator<T> validator = validatorClass.newInstance(); |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = validator.getClass().getMethod( |
| | | "initializePasswordValidator", configuration.configurationClass()); |
| | | method.invoke(validator, configuration); |
| | | validator.initializePasswordValidator(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | validator.getClass().getMethod("isConfigurationAcceptable", |
| | | PasswordValidatorCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(validator, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!validator.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | |
| | | * @throws InitializationException If a problem occurred while attempting to |
| | | * initialize the plugin. |
| | | */ |
| | | private DirectoryServerPlugin<? extends PluginCfg> |
| | | private <T extends PluginCfg> DirectoryServerPlugin<T> |
| | | loadPlugin(String className, Set<PluginType> pluginTypes, |
| | | PluginCfg configuration, boolean initialize) |
| | | T configuration, boolean initialize) |
| | | throws InitializationException |
| | | { |
| | | try |
| | |
| | | definition.getJavaClassPropertyDefinition(); |
| | | Class<? extends DirectoryServerPlugin> pluginClass = |
| | | propertyDefinition.loadClass(className, DirectoryServerPlugin.class); |
| | | DirectoryServerPlugin<? extends PluginCfg> plugin = |
| | | pluginClass.newInstance(); |
| | | DirectoryServerPlugin<T> plugin = pluginClass.newInstance(); |
| | | |
| | | if (initialize) |
| | | { |
| | | plugin.initializeInternal(configuration.dn(), pluginTypes, |
| | | configuration.isInvokeForInternalOperations()); |
| | | |
| | | Method method = |
| | | plugin.getClass().getMethod("initializePlugin", Set.class, |
| | | configuration.configurationClass()); |
| | | method.invoke(plugin, pluginTypes, configuration); |
| | | plugin.initializePlugin(pluginTypes, configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = plugin.getClass().getMethod("isConfigurationAcceptable", |
| | | PluginCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(plugin, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!plugin.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String buffer = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = handler.getClass().getMethod( |
| | | "initializeSASLMechanismHandler", |
| | | configuration.configurationClass()); |
| | | method.invoke(handler, configuration); |
| | | handler.initializeSASLMechanismHandler(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | handler.getClass().getMethod("isConfigurationAcceptable", |
| | | SASLMechanismHandlerCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(handler, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!handler.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the configuration |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SynchronizationProviderCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SynchronizationProviderCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | SynchronizationProviderCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | SynchronizationProviderCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | String className = configuration.getJavaClass(); |
| | | SynchronizationProviderCfgDefn d = |
| | | SynchronizationProviderCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | |
| | | // Load the class and cast it to a synchronizationProvider. |
| | | SynchronizationProvider provider = null; |
| | | Class<? extends SynchronizationProvider> theClass; |
| | | try |
| | | { |
| | | theClass = pd.loadClass(className, SynchronizationProvider.class); |
| | | provider = theClass.newInstance(); |
| | | } catch (Exception e) |
| | | { |
| | | // Handle the exception: put a message in the unacceptable reasons. |
| | | LocalizableMessage message = ERR_CONFIG_SYNCH_UNABLE_TO_LOAD_PROVIDER_CLASS.get( |
| | | className, configuration.dn(), stackTraceToSingleLineString(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try |
| | | { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("isConfigurationAcceptable", |
| | | SynchronizationProviderCfg.class, |
| | | List.class); |
| | | Boolean acceptable = (Boolean) method.invoke(provider, configuration, |
| | | unacceptableReasons); |
| | | Class<? extends SynchronizationProvider> theClass = |
| | | pd.loadClass(className, SynchronizationProvider.class); |
| | | SynchronizationProvider provider = theClass.newInstance(); |
| | | |
| | | if (! acceptable) |
| | | { |
| | | return false; |
| | | } |
| | | return provider.isConfigurationAcceptable(configuration, |
| | | unacceptableReasons); |
| | | } catch (Exception e) |
| | | { |
| | | // Handle the exception: put a message in the unacceptable reasons. |
| | |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | SynchronizationProviderCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | SynchronizationProviderCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | * @throws InitializationException If a problem occurred while attempting to |
| | | * initialize the trust manager provider. |
| | | */ |
| | | private TrustManagerProvider loadProvider( |
| | | private <T extends TrustManagerProviderCfg> TrustManagerProvider<T> loadProvider( |
| | | String className, |
| | | TrustManagerProviderCfg configuration, |
| | | T configuration, |
| | | boolean initialize) |
| | | throws InitializationException |
| | | { |
| | |
| | | definition.getJavaClassPropertyDefinition(); |
| | | Class<? extends TrustManagerProvider> providerClass = |
| | | propertyDefinition.loadClass(className, TrustManagerProvider.class); |
| | | TrustManagerProvider provider = providerClass.newInstance(); |
| | | TrustManagerProvider<T> provider = providerClass.newInstance(); |
| | | |
| | | if (initialize) |
| | | { |
| | | Method method = provider.getClass().getMethod( |
| | | "initializeTrustManagerProvider", |
| | | configuration.configurationClass()); |
| | | method.invoke(provider, configuration); |
| | | provider.initializeTrustManagerProvider(configuration); |
| | | } |
| | | else |
| | | { |
| | | Method method = |
| | | provider.getClass().getMethod("isConfigurationAcceptable", |
| | | TrustManagerProviderCfg.class, |
| | | List.class); |
| | | |
| | | List<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | Boolean acceptable = (Boolean) method.invoke(provider, configuration, |
| | | unacceptableReasons); |
| | | if (! acceptable) |
| | | if (!provider.isConfigurationAcceptable(configuration, unacceptableReasons)) |
| | | { |
| | | String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | throw new InitializationException( |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.WorkQueueCfgDefn; |
| | | import org.opends.server.admin.std.server.WorkQueueCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.meta.WorkQueueCfgDefn; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.admin.std.server.WorkQueueCfg; |
| | | import org.opends.server.api.WorkQueue; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | { |
| | | WorkQueue workQueue = workQueueClass.newInstance(); |
| | | |
| | | Method method = workQueue.getClass().getMethod("initializeWorkQueue", |
| | | workQueueConfig.configurationClass()); |
| | | method.invoke(workQueue, workQueueConfig); |
| | | workQueue.initializeWorkQueue(workQueueConfig); |
| | | |
| | | return workQueue; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(WorkQueueCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(WorkQueueCfg configuration) |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | |
| | | */ |
| | | package org.opends.server.core.networkgroups; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.HashSet; |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.core.Workflow; |
| | | import org.opends.server.core.WorkflowImpl; |
| | | import org.opends.server.core.WorkflowTopologyNode; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.types.AuthenticationType; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.operation.PreParseOperation; |
| | | import org.opends.server.workflowelement.WorkflowElement; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the network group. A network group is used to |
| | | * categorize client connections. A network group is defined by a set of |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | NetworkGroupCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | NetworkGroupCfg configuration, List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd( |
| | | QOSPolicyCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | QOSPolicyCfg configuration) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | QOSPolicyCfg configuration, List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | QOSPolicyCfg configuration, List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | |
| | | // Validate the configuration. |
| | | try |
| | | { |
| | | // Load the class and cast it to a network group policy factory. |
| | | Class<? extends QOSPolicyFactory> theClass; |
| | | QOSPolicyFactory factory; |
| | | Class<? extends QOSPolicyFactory> theClass = |
| | | pd.loadClass(className, QOSPolicyFactory.class); |
| | | QOSPolicyFactory factory = theClass.newInstance(); |
| | | |
| | | theClass = pd.loadClass(className, QOSPolicyFactory.class); |
| | | factory = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = |
| | | theClass.getMethod("isConfigurationAcceptable", |
| | | QOSPolicyCfg.class, List.class); |
| | | Boolean acceptable = |
| | | (Boolean) method.invoke(factory, policyConfiguration, |
| | | unacceptableReasons); |
| | | |
| | | if (!acceptable) |
| | | { |
| | | return false; |
| | | } |
| | | return factory.isConfigurationAcceptable(policyConfiguration, unacceptableReasons); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | className, policyConfiguration.dn(), stackTraceToSingleLineString(e))); |
| | | return false; |
| | | } |
| | | |
| | | // The configuration is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | QOSPolicyCfgDefn d = QOSPolicyCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = d.getJavaClassPropertyDefinition(); |
| | | |
| | | // Load the class and cast it to a network group policy. |
| | | Class<? extends QOSPolicyFactory> theClass; |
| | | QOSPolicyFactory factory; |
| | | |
| | | try |
| | | { |
| | | theClass = pd.loadClass(className, QOSPolicyFactory.class); |
| | | factory = theClass.newInstance(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = ERR_CONFIG_NETWORK_GROUP_POLICY_CANNOT_INITIALIZE.get( |
| | | className, policyConfiguration.dn(), stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | | |
| | | // Perform the necessary initialization for the network group |
| | | // policy. |
| | | QOSPolicy policy; |
| | | |
| | | try |
| | | { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = |
| | | theClass.getMethod("createQOSPolicy", policyConfiguration |
| | | .configurationClass()); |
| | | Class<? extends QOSPolicyFactory> theClass = |
| | | pd.loadClass(className, QOSPolicyFactory.class); |
| | | QOSPolicyFactory factory = theClass.newInstance(); |
| | | |
| | | policy = (QOSPolicy) method.invoke(factory, policyConfiguration); |
| | | policy = factory.createQOSPolicy(policyConfiguration); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | throw new InitializationException(message, e); |
| | | } |
| | | |
| | | // The network group has been successfully initialized - so register |
| | | // it. |
| | | // The network group has been successfully initialized - so register it. |
| | | QOSPolicy oldPolicy = |
| | | policies.put(policyConfiguration.dn(), policy); |
| | | |
| | |
| | | String className = config.getJavaClass(); |
| | | ClassPropertyDefinition pd = getJavaClassPropertyDefinition(); |
| | | try { |
| | | // Load the class and cast it to a LogPublisher. |
| | | P publisher = pd.loadClass(className, logPublisherClass).newInstance(); |
| | | // The class is valid as far as we can tell. |
| | | return publisher.isConfigurationAcceptable(config, unacceptableReasons); |
| | | } catch (Exception e) { |
| | | unacceptableReasons.add(invalidLoggerClassErrorMessage.get(className, config.dn(), e)); |
| | |
| | | String className = config.getJavaClass(); |
| | | ClassPropertyDefinition pd = getJavaClassPropertyDefinition(); |
| | | try { |
| | | // Load the class and cast it to a LogPublisher. |
| | | P logPublisher = pd.loadClass(className, logPublisherClass).newInstance(); |
| | | logPublisher.initializeLogPublisher(config, serverContext); |
| | | // The log publisher has been successfully initialized. |
| | | return logPublisher; |
| | | } |
| | | catch (Exception e) |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.tools.tasks; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import org.opends.server.backends.task.FailedDependencyAction; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.backends.task.FailedDependencyAction; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DN; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.util.Map; |
| | | import java.util.HashMap; |
| | |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | /** |
| | | * Processes information from a task entry from the directory and |
| | | * provides accessors for attribute information. In some cases the |
| | |
| | | if (type == null) { |
| | | Task task = getTask(); |
| | | if (task != null) { |
| | | try { |
| | | Method m = Task.class.getMethod("getDisplayName"); |
| | | Object oName = m.invoke(task); |
| | | if (oName instanceof LocalizableMessage) { |
| | | mapClassToTypeName.put(className, (LocalizableMessage) oName); |
| | | type = (LocalizableMessage) oName; |
| | | } |
| | | } catch (Exception e) { |
| | | // ignore; this is best effort |
| | | } |
| | | LocalizableMessage message = task.getDisplayName(); |
| | | mapClassToTypeName.put(className, message); |
| | | type = message; |
| | | } |
| | | } |
| | | |
| | |
| | | URLClassLoader sysloader = |
| | | (URLClassLoader)ClassLoader.getSystemClassLoader(); |
| | | Class sysclass = URLClassLoader.class; |
| | | Method method = |
| | | sysclass.getDeclaredMethod("addURL",new Class[]{URL.class}); |
| | | Method method = sysclass.getDeclaredMethod("addURL", URL.class); |
| | | method.setAccessible(true); |
| | | method.invoke(sysloader,new Object[]{ u }); |
| | | method.invoke(sysloader, u); |
| | | } |
| | | catch (Throwable t) { |
| | | } |