Package org.opends.server.extensions
Class UserTemplateVirtualAttributeProvider
java.lang.Object
org.opends.server.api.VirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
org.opends.server.extensions.UserTemplateVirtualAttributeProvider
- All Implemented Interfaces:
ConfigurationChangeListener<UserTemplateVirtualAttributeCfg>
public final class UserTemplateVirtualAttributeProvider
extends VirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
implements ConfigurationChangeListener<UserTemplateVirtualAttributeCfg>
This class implements a virtual attribute provider that allows administrators to define their own virtual attribute
with template that will be evaluated by taking the data from the attributes only for the entry that matches the
criteria defined in the virtual attribute rule.
Note: We will not allow searches based only on user template virtual attributes.
Valid templates:
- With no placeholders:
"No placeholders in template!"
- With placeholders pointing to other entry attributes:
"{uid}@{domain}" : "bjensen@example.com"
- With expression defining default value: "{uid}@{domain|domain.com}"
(if {domain}="example.com") : "bjensen@example.com"
(if no {domain} attribute) : "bjensen@domain.com"
- With reference pointing to a multi-valued attribute :
"This is {cn}" :
cn = 1 : "This is 1"
cn = 2 : "This is 2"
cn = 3 : "This is 3"
- With escaping brace:
"This is \{uid}" : "This is {uid}"
"This is \{uid\}" : "This is {uid\}"
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyConfigurationChange(UserTemplateVirtualAttributeCfg configuration) Applies the configuration changes to this change listener.voidPerforms any finalization that may be necessary whenever this virtual attribute provider is taken out of service.getAttribute(Entry entry, AttributeDescription attributeDescription) Generates an unmodifiable attribute with the values for the provided entry.voidInitializes this virtual attribute based on the information in the provided configuration entry.booleanisConfigurationAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons) Indicates whether the provided configuration is acceptable for this virtual attribute provider.booleanisConfigurationChangeAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons) Indicates whether the proposed change to the configuration is acceptable to this change listener.booleanIndicates whether this virtual attribute provider may generate multiple values.Methods inherited from class org.opends.server.api.VirtualAttributeProvider
getServerContext, initializeVirtualAttributeProvider, tryProcessSearch
-
Constructor Details
-
UserTemplateVirtualAttributeProvider
public UserTemplateVirtualAttributeProvider()
-
-
Method Details
-
initializeVirtualAttributeProvider
public void initializeVirtualAttributeProvider(UserTemplateVirtualAttributeCfg configuration) throws ConfigException Description copied from class:VirtualAttributeProviderInitializes this virtual attribute based on the information in the provided configuration entry.- Overrides:
initializeVirtualAttributeProviderin classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>- Parameters:
configuration- The configuration to use to initialize this virtual attribute provider.- Throws:
ConfigException- If an unrecoverable problem arises in the process of performing the initialization.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons) Description copied from class:VirtualAttributeProviderIndicates whether the provided configuration is acceptable for this virtual attribute provider. It should be possible to call this method on an uninitialized virtual attribute provider instance in order to determine whether the virtual attribute provider would be able to use the provided configuration.- Overrides:
isConfigurationAcceptablein classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>- Parameters:
configuration- The virtual attribute provider configuration for which to make the determination.unacceptableReasons- A list that may be used to hold the reasons that the provided configuration is not acceptable.- Returns:
trueif the provided configuration is acceptable for this virtual attribute provider, orfalseif not.
-
finalizeVirtualAttributeProvider
public void finalizeVirtualAttributeProvider()Description copied from class:VirtualAttributeProviderPerforms any finalization that may be necessary whenever this virtual attribute provider is taken out of service.- Overrides:
finalizeVirtualAttributeProviderin classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
-
getAttribute
Description copied from class:VirtualAttributeProviderGenerates an unmodifiable attribute with the values for the provided entry.- Specified by:
getAttributein classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>- Parameters:
entry- The entry for which the values are to be generated.attributeDescription- the attribute description corresponding to this virtual attribute- Returns:
- The unmodifiable attribute with the values generated for the provided entry. It may be empty, but it must
not be
null.
-
isMultiValued
public boolean isMultiValued()Description copied from class:VirtualAttributeProviderIndicates whether this virtual attribute provider may generate multiple values.- Specified by:
isMultiValuedin classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>- Returns:
trueif this virtual attribute provider may generate multiple values, orfalseif not.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons) Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<UserTemplateVirtualAttributeCfg>- Parameters:
configuration- The new configuration containing the changes.unacceptableReasons- A list that can be used to hold messages about why the provided configuration is not acceptable.- Returns:
- Returns
trueif the proposed change is acceptable, orfalseif it is not.
-
applyConfigurationChange
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<UserTemplateVirtualAttributeCfg>- Parameters:
configuration- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-