/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2007-2009 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* This class defines a utility that will be used to manage the set of
* virtual attribute providers defined in the Directory Server. It will
* initialize the providers when the server starts, and then will manage any
* additions, removals, or modifications to any virtual attribute providers
* while the server is running.
*/
public class VirtualAttributeConfigManager
implements ConfigurationChangeListener<VirtualAttributeCfg>,
{
/**
* A mapping between the DNs of the config entries and the associated virtual
* attribute rules.
*/
/**
* Creates a new instance of this virtual attribute config manager.
*
* @param serverContext
* The server context.
*/
{
this.serverContext = serverContext;
}
/**
* Initializes all virtual attribute providers currently defined in the
* Directory Server configuration. This should only be called at Directory
* Server startup.
*
* @throws ConfigException
* If a configuration problem causes the virtual attribute provider
* initialization process to fail.
* @throws InitializationException
* If a problem occurs while initializing the virtual attribute
* providers that is not related to the server configuration.
*/
public void initializeVirtualAttributes()
{
// Get the root configuration object.
// Register as an add and delete listener with the root configuration so we
// can be notified if any virtual attribute provider entries are added or
// removed.
//Initialize the existing virtual attribute providers.
{
cfg.addChangeListener(this);
{
try
{
new LinkedHashMap<>();
{
}
{
if (provider.isMultiValued())
{
throw new ConfigException(message);
}
else if (cfg.getConflictBehavior() ==
{
throw new ConfigException(message);
}
}
}
catch (InitializationException ie)
{
continue;
}
}
}
}
{
cfg.getGroupDN(),
}
/** {@inheritDoc} */
public boolean isConfigurationAddAcceptable(
{
if (configuration.isEnabled())
{
// Get the name of the class and make sure we can instantiate it as a
// virtual attribute provider.
try
{
}
catch (InitializationException ie)
{
return false;
}
}
// If there were any search filters provided, then make sure they are all
// valid.
}
{
{
try
{
}
catch (DirectoryException de)
{
}
}
return filters;
}
/** {@inheritDoc} */
{
configuration.addChangeListener(this);
if (! configuration.isEnabled())
{
return ccr;
}
// Make sure that we can parse all of the search filters.
new LinkedHashMap<>();
{
}
// Get the name of the class and make sure we can instantiate it as a
// certificate mapper.
{
try
{
}
catch (InitializationException ie)
{
}
}
{
}
return ccr;
}
/** {@inheritDoc} */
public boolean isConfigurationDeleteAcceptable(
{
// We will always allow getting rid of a virtual attribute rule.
return true;
}
/** {@inheritDoc} */
{
{
}
return ccr;
}
/** {@inheritDoc} */
public boolean isConfigurationChangeAcceptable(
{
if (configuration.isEnabled())
{
// Get the name of the class and make sure we can instantiate it as a
// virtual attribute provider.
try
{
}
catch (InitializationException ie)
{
return false;
}
}
// If there were any search filters provided, then make sure they are all
// valid.
}
{
new LinkedHashMap<>();
{
return false;
}
return true;
}
/** {@inheritDoc} */
{
// Get the existing rule if it's already enabled.
// If the new configuration has the rule disabled, then disable it if it
// is enabled, or do nothing if it's already disabled.
if (! configuration.isEnabled())
{
if (existingRule != null)
{
}
return ccr;
}
// Make sure that we can parse all of the search filters.
new LinkedHashMap<>();
{
}
// Get the name of the class and make sure we can instantiate it as a
// certificate mapper.
{
try
{
}
catch (InitializationException ie)
{
}
}
{
if (existingRule != null)
{
}
}
return ccr;
}
/**
* Loads the specified class, instantiates it as a certificate mapper, and
* optionally initializes that instance.
*
* @param className The fully-qualified name of the certificate mapper
* class to load, instantiate, and initialize.
* @param cfg The configuration to use to initialize the
* virtual attribute provider. It must not be
* {@code null}.
* @param initialize Indicates whether the virtual attribute provider
* instance should be initialized.
*
* @return The possibly initialized certificate mapper.
*
* @throws InitializationException If a problem occurred while attempting to
* initialize the certificate mapper.
*/
private VirtualAttributeProvider<? extends VirtualAttributeCfg>
boolean initialize)
throws InitializationException
{
try
{
VirtualAttributeProvider.class);
if (initialize)
{
}
else
{
{
throw new InitializationException(message);
}
}
return provider;
}
catch (Exception e)
{
throw new InitializationException(message, e);
}
}
/**
* Retrieves the collection of registered virtual attribute rules.
*
* @return The collection of registered virtual attribute rules.
*/
{
}
/**
* Registers the provided virtual attribute rule.
*
* @param rule
* The virtual attribute rule to be registered.
*/
{
}
/**
* Deregisters the provided virtual attribute rule.
*
* @param rule
* The virtual attribute rule to be deregistered.
*/
{
}
{
try
{
}
catch (DirectoryException e)
{
// should never happen
throw new RuntimeException(e);
}
}
}