org.opends.server.extensions
Class VirtualStaticGroup

java.lang.Object
  extended by org.opends.server.api.Group<VirtualStaticGroupImplementationCfg>
      extended by org.opends.server.extensions.VirtualStaticGroup

public class VirtualStaticGroup
extends Group<VirtualStaticGroupImplementationCfg>

This class provides a virtual static group implementation, in which membership is based on membership of another group.


Constructor Summary
VirtualStaticGroup()
          Creates a new, uninitialized virtual static group instance.
VirtualStaticGroup(DN groupEntryDN, DN targetGroupDN)
          Creates a new virtual static group instance with the provided information.
 
Method Summary
 void addMember(Entry userEntry)
          Attempts to add the provided user as a member of this group.
 void addNestedGroup(DN nestedGroupDN)
          Attempts to add the provided group DN as a nested group within this group.
 SearchFilter getGroupDefinitionFilter()
          Retrieves a search filter that may be used to identify entries containing definitions for groups of this type in the Directory Server.
 DN getGroupDN()
          Retrieves the DN of the entry that contains the definition for this group.
 MemberList getMembers()
          Retrieves an iterator that may be used to cursor through the entries of the members contained in this group.
 MemberList getMembers(DN baseDN, SearchScope scope, SearchFilter filter)
          Retrieves an iterator that may be used to cursor through the entries of the members contained in this group.
 java.util.List<DN> getNestedGroupDNs()
          Retrieves a list of the DNs of any nested groups whose members should be considered members of this group.
 DN getTargetGroupDN()
          Retrieves the DN of the target group for this virtual static group.
 void initializeGroupImplementation(VirtualStaticGroupImplementationCfg configuration)
          Initializes a "shell" instance of this group implementation that may be used to identify and instantiate instances of this type of group in the directory data.
 boolean isGroupDefinition(Entry entry)
          Indicates whether the provided entry contains a valid definition for this type of group.
 boolean isMember(DN userDN, java.util.Set<DN> examinedGroups)
          Indicates whether the user with the specified DN is a member of this group.
 boolean isMember(Entry userEntry, java.util.Set<DN> examinedGroups)
          Indicates whether the user described by the provided user entry is a member of this group.
 boolean mayAlterMemberList()
          Indicates whether it is possible to alter the member list for this group (e.g., in order to add members to the group or remove members from it).
 VirtualStaticGroup newInstance(Entry groupEntry)
          Creates a new group of this type based on the definition contained in the provided entry.
 void removeMember(DN userDN)
          Attempts to remove the specified user as a member of this group.
 void removeNestedGroup(DN nestedGroupDN)
          Attempts to remove the provided group as a nested group within this group.
 boolean supportsNestedGroups()
          Indicates whether this group supports nesting other groups, such that the members of the nested groups will also be considered members of this group.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this group to the provided buffer.
 
Methods inherited from class org.opends.server.api.Group
finalizeGroupImplementation, isConfigurationAcceptable, isMember, isMember, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VirtualStaticGroup

public VirtualStaticGroup()
Creates a new, uninitialized virtual static group instance. This is intended for internal use only.


VirtualStaticGroup

public VirtualStaticGroup(DN groupEntryDN,
                          DN targetGroupDN)
Creates a new virtual static group instance with the provided information.

Parameters:
groupEntryDN - The DN of the entry that holds the definition for this group. It must not be null.
targetGroupDN - The DN of the target group that will provide membership information. It must not be null.
Method Detail

initializeGroupImplementation

public void initializeGroupImplementation(VirtualStaticGroupImplementationCfg configuration)
                                   throws ConfigException,
                                          InitializationException
Initializes a "shell" instance of this group implementation that may be used to identify and instantiate instances of this type of group in the directory data.

Specified by:
initializeGroupImplementation in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
configuration - The configuration for this group implementation.
Throws:
ConfigException - If there is a problem with the provided configuration entry.
InitializationException - If a problem occurs while attempting to initialize this group implementation that is not related to the server configuration.

newInstance

public VirtualStaticGroup newInstance(Entry groupEntry)
                               throws DirectoryException
Creates a new group of this type based on the definition contained in the provided entry. This method must be designed so that it may be invoked on the "shell" instance created using the default constructor and initialized with the initializeGroupImplementation method.

Specified by:
newInstance in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
groupEntry - The entry containing the definition for the group to be created.
Returns:
The group instance created from the definition in the provided entry.
Throws:
DirectoryException - If a problem occurs while trying to create the group instance.

getGroupDefinitionFilter

public SearchFilter getGroupDefinitionFilter()
                                      throws DirectoryException
Retrieves a search filter that may be used to identify entries containing definitions for groups of this type in the Directory Server. This method must be designed so that it may be invoked on the "shell" instance created using the default constructor and initialized with the initializeGroupImplementation method.

Specified by:
getGroupDefinitionFilter in class Group<VirtualStaticGroupImplementationCfg>
Returns:
A search filter that may be used to identify entries containing definitions for groups of this type in the Directory Server.
Throws:
DirectoryException - If a problem occurs while trying to locate all of the applicable group definition entries.

isGroupDefinition

public boolean isGroupDefinition(Entry entry)
Indicates whether the provided entry contains a valid definition for this type of group.

Specified by:
isGroupDefinition in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
entry - The entry for which to make the determination.
Returns:
true if the provided entry does contain a valid definition for this type of group, or false if it does not.

getGroupDN

public DN getGroupDN()
Retrieves the DN of the entry that contains the definition for this group.

Specified by:
getGroupDN in class Group<VirtualStaticGroupImplementationCfg>
Returns:
The DN of the entry that contains the definition for this group.

getTargetGroupDN

public DN getTargetGroupDN()
Retrieves the DN of the target group for this virtual static group.

Returns:
The DN of the target group for this virtual static group.

supportsNestedGroups

public boolean supportsNestedGroups()
Indicates whether this group supports nesting other groups, such that the members of the nested groups will also be considered members of this group.

Specified by:
supportsNestedGroups in class Group<VirtualStaticGroupImplementationCfg>
Returns:
true if this group supports nesting other groups, or false if it does not.

getNestedGroupDNs

public java.util.List<DN> getNestedGroupDNs()
Retrieves a list of the DNs of any nested groups whose members should be considered members of this group.

Specified by:
getNestedGroupDNs in class Group<VirtualStaticGroupImplementationCfg>
Returns:
A list of the DNs of any nested groups whose members should be considered members of this group.

addNestedGroup

public void addNestedGroup(DN nestedGroupDN)
                    throws java.lang.UnsupportedOperationException,
                           DirectoryException
Attempts to add the provided group DN as a nested group within this group. The change should be committed to persistent storage through an internal operation.

Specified by:
addNestedGroup in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
nestedGroupDN - The DN of the group that should be added to the set of nested groups for this group.
Throws:
java.lang.UnsupportedOperationException - If this group does not support nesting.
DirectoryException - If a problem occurs while attempting to nest the provided group DN.

removeNestedGroup

public void removeNestedGroup(DN nestedGroupDN)
                       throws java.lang.UnsupportedOperationException,
                              DirectoryException
Attempts to remove the provided group as a nested group within this group. The change should be committed to persistent storage through an internal operation.

Specified by:
removeNestedGroup in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
nestedGroupDN - The DN of the group that should be removed from the set of nested groups for this group.
Throws:
java.lang.UnsupportedOperationException - If this group does not support nesting.
DirectoryException - If a problem occurs while attempting to nest the provided group DN.

isMember

public boolean isMember(DN userDN,
                        java.util.Set<DN> examinedGroups)
                 throws DirectoryException
Indicates whether the user with the specified DN is a member of this group. Note that this is a point-in-time determination and the caller must not cache the result. Also note that group implementations that support nesting should use this version of the method ratehr than the version that does not take a set of DNs when attempting to determine whether a nested group includes the target member.

Specified by:
isMember in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
userDN - The DN of the user for which to make the determination.
examinedGroups - A set of groups that have already been examined in the process of making the determination. This provides a mechanism to prevent infinite recursion due to circular references (e.g., two groups include each other as nested groups). Each time a group instance is checked, its DN should be added to the list, and any DN already contained in the list should be skipped.
Returns:
true if the specified user is currently a member of this group, or false if not.
Throws:
DirectoryException - If a problem occurs while attempting to make the determination.

isMember

public boolean isMember(Entry userEntry,
                        java.util.Set<DN> examinedGroups)
                 throws DirectoryException
Indicates whether the user described by the provided user entry is a member of this group. Note that this is a point-in-time determination and the caller must not cache the result. Also note that group implementations that support nesting should use this version of the method ratehr than the version that does not take a set of DNs when attempting to determine whether a nested group includes the target member.

Specified by:
isMember in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
userEntry - The entry for the user for which to make the determination.
examinedGroups - A set of groups that have already been examined in the process of making the determination. This provides a mechanism to prevent infinite recursion due to circular references (e.g., two groups include each other as nested groups). Each time a group instance is checked, its DN should be added to the list, and any DN already contained in the list should be skipped.
Returns:
true if the specified user is currently a member of this group, or false if not.
Throws:
DirectoryException - If a problem occurs while attempting to make the determination.

getMembers

public MemberList getMembers()
                      throws DirectoryException
Retrieves an iterator that may be used to cursor through the entries of the members contained in this group. Note that this is a point-in-time determination, and the caller must not cache the result. Further, the determination should only include this group and not members from nested groups.

Overrides:
getMembers in class Group<VirtualStaticGroupImplementationCfg>
Returns:
An iterator that may be used to cursor through the entries of the members contained in this group.
Throws:
DirectoryException - If a problem occurs while attempting to retrieve the set of members.

getMembers

public MemberList getMembers(DN baseDN,
                             SearchScope scope,
                             SearchFilter filter)
                      throws DirectoryException
Retrieves an iterator that may be used to cursor through the entries of the members contained in this group. It may optionally retrieve a subset of the member entries based on a given set of criteria. Note that this is a point-in-time determination, and the caller must not cache the result.

Specified by:
getMembers in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
baseDN - The base DN that should be used when determining whether a given entry will be returned. If this is null, then all entries will be considered in the scope of the criteria.
scope - The scope that should be used when determining whether a given entry will be returned. It must not be null if the provided base DN is not null. The scope will be ignored if no base DN is provided.
filter - The filter that should be used when determining whether a given entry will be returned. If this is null, then any entry in the scope of the criteria will be included in the results.
Returns:
An iterator that may be used to cursor through the entries of the members contained in this group.
Throws:
DirectoryException - If a problem occurs while attempting to retrieve the set of members.

mayAlterMemberList

public boolean mayAlterMemberList()
Indicates whether it is possible to alter the member list for this group (e.g., in order to add members to the group or remove members from it).

Specified by:
mayAlterMemberList in class Group<VirtualStaticGroupImplementationCfg>
Returns:
true if it is possible to add members to this group, or false if not.

addMember

public void addMember(Entry userEntry)
               throws java.lang.UnsupportedOperationException,
                      DirectoryException
Attempts to add the provided user as a member of this group. The change should be committed to persistent storage through an internal operation.

Specified by:
addMember in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
userEntry - The entry for the user to be added as a member of this group.
Throws:
java.lang.UnsupportedOperationException - If this group does not support altering the member list.
DirectoryException - If a problem occurs while attempting to add the provided user as a member of this group.

removeMember

public void removeMember(DN userDN)
                  throws java.lang.UnsupportedOperationException,
                         DirectoryException
Attempts to remove the specified user as a member of this group. The change should be committed to persistent storage through an internal operation.

Specified by:
removeMember in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
userDN - The DN of the user to remove as a member of this group.
Throws:
java.lang.UnsupportedOperationException - If this group does not support altering the member list.
DirectoryException - If a problem occurs while attempting to remove the provided user as a member of this group.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this group to the provided buffer.

Specified by:
toString in class Group<VirtualStaticGroupImplementationCfg>
Parameters:
buffer - The buffer to which the string representation should be appended.