| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.admin.std.server.VirtualAttributeCfg; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.MemberVirtualAttributeCfg; |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.config.ConfigException; |
| | |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.ConditionResult; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * uniqueMember attribute. |
| | | */ |
| | | public class MemberVirtualAttributeProvider |
| | | extends VirtualAttributeProvider<VirtualAttributeCfg> |
| | | extends VirtualAttributeProvider<MemberVirtualAttributeCfg> |
| | | implements ConfigurationChangeListener<MemberVirtualAttributeCfg> |
| | | { |
| | | // The attribute type used to indicate which target group should be used to |
| | | // obtain the member list. |
| | | private AttributeType targetGroupType; |
| | | |
| | | // The current configuration for this member virtual attribute. |
| | | private MemberVirtualAttributeCfg currentConfig; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override() |
| | | public void initializeVirtualAttributeProvider( |
| | | VirtualAttributeCfg configuration) |
| | | MemberVirtualAttributeCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | configuration.addMemberChangeListener(this); |
| | | currentConfig = configuration; |
| | | |
| | | targetGroupType = |
| | | DirectoryServer.getAttributeType(ATTR_TARGET_GROUP_DN, true); |
| | | } |
| | |
| | | public LinkedHashSet<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | { |
| | | if (! currentConfig.isAllowRetrievingMembership()) |
| | | { |
| | | return new LinkedHashSet<AttributeValue>(0); |
| | | } |
| | | |
| | | Group g = DirectoryServer.getGroupManager().getGroupInstance(entry.getDN()); |
| | | if (g == null) |
| | | { |
| | |
| | | searchOperation.setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | MemberVirtualAttributeCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | // The new configuration should always be acceptable. |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | MemberVirtualAttributeCfg configuration) |
| | | { |
| | | // Just accept the new configuration as-is. |
| | | currentConfig = configuration; |
| | | |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | } |
| | | } |
| | | |