Package edu.vt.middleware.ldap.ed
Class EdServiceTemplate
- java.lang.Object
-
- edu.vt.middleware.ldap.ed.EdServiceTemplate
-
-
Constructor Summary
Constructors Constructor Description EdServiceTemplate()
Default constructor.EdServiceTemplate(DirectoryType directoryType, DirectoryEnv env)
This creates a new instance of an ED search client.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the connection pool used by the connection factory.Collection<org.ldaptive.LdapAttribute>
getAttributes(String dn, String... retAttrs)
Gets the requested attributes of the object whose distinguished name is given.org.ldaptive.ConnectionFactory
getConnectionFactory()
Gets the underlying connection factory.String
getDn(String authId)
Gets the LDAP distinguished name for the supplied user.DirectoryEnv
getEnvironment()
Gets the environment this client operates on.String[]
getGroupMembership(String uugidOrDn)
Gets the groups of which the given group is a member.String[]
getMemberOf(String authId)
Gets all the groups the supplied user is a member of.String[]
getMembers(String uugidOrDn)
Gets the members of the given group.DirectoryType
getType()
Gets the class of directory this client operates on.VirginiaTechGroup
getVirginiaTechGroup(String uugidOrDn)
This will query LDAP for the specified uugidOrDn for a VirginiaTechGroup entry and return theLdapEntry
mapped to aVirginiaTechGroup
bean.VirginiaTechPerson
getVirginiaTechPerson(String authId)
This will query LDAP for the specified authId for a VirginiaTechPerson entry and return theLdapEntry
mapped to aVirginiaTechPerson
bean.void
initialize()
Initialize this search client for use.org.ldaptive.SearchResponse
search(String filter, String... retAttrs)
Searches an ED with the supplied query and return attributes.protected void
setEnvironment(DirectoryEnv dirEnv)
Sets the directory environment this ED client is configured to operate on.protected void
setType(DirectoryType dirType)
Sets the directory type this ED client is configured to operate on.protected static String
toGroupUugid(String uugidOrDn)
Converts a group UUGID or DN to a group UUGID.protected static String
toUusidDn(String uusidOrDn)
Converts a uusid to include the base DN.
-
-
-
Field Detail
-
MAPPER
protected static final org.ldaptive.beans.reflect.DefaultLdapEntryMapper<Object> MAPPER
Ldap entry MAPPER for object conversion.
-
-
Constructor Detail
-
EdServiceTemplate
public EdServiceTemplate()
Default constructor.setType(DirectoryType)
andsetEnvironment(DirectoryEnv)
must be called to configure this search client.initialize()
must be called before this object can be used.
-
EdServiceTemplate
public EdServiceTemplate(DirectoryType directoryType, DirectoryEnv env)
This creates a new instance of an ED search client.initialize()
must be called before this object can be used.- Parameters:
directoryType
- directory typeenv
- directory env
-
-
Method Detail
-
getType
public DirectoryType getType()
Description copied from interface:EdOperation
Gets the class of directory this client operates on.- Specified by:
getType
in interfaceEdOperation
- Returns:
- Directory type.
-
setType
protected void setType(DirectoryType dirType)
Sets the directory type this ED client is configured to operate on.- Parameters:
dirType
- Directory class type.
-
getEnvironment
public DirectoryEnv getEnvironment()
Description copied from interface:EdOperation
Gets the environment this client operates on.- Specified by:
getEnvironment
in interfaceEdOperation
- Returns:
- Directory environment.
-
setEnvironment
protected void setEnvironment(DirectoryEnv dirEnv)
Sets the directory environment this ED client is configured to operate on.- Parameters:
dirEnv
- Directory environment.
-
initialize
public void initialize()
Initialize this search client for use.This method must be called after the directory type (
setType(DirectoryType)
) and environment (setEnvironment(DirectoryEnv)
) are set and before any LDAP operations are performed. If the directory type and/or environment are changed, the search client must be re-initialized for the changes to take effect on the next LDAP operation.
-
close
public void close()
Close the connection pool used by the connection factory.
-
search
public org.ldaptive.SearchResponse search(String filter, String... retAttrs) throws org.ldaptive.LdapException
Description copied from interface:EdService
Searches an ED with the supplied query and return attributes. SeeOperation.execute(org.ldaptive.Request)
.
-
getAttributes
public Collection<org.ldaptive.LdapAttribute> getAttributes(String dn, String... retAttrs) throws org.ldaptive.LdapException
Description copied from interface:EdService
Gets the requested attributes of the object whose distinguished name is given. SeeLdapEntry.getAttributes()
.- Specified by:
getAttributes
in interfaceEdService
- Parameters:
dn
- LDAP distinguished name of object whose attributes will be fetched.retAttrs
- attributes to return- Returns:
- ldap attributes
- Throws:
org.ldaptive.LdapException
- if the LDAP returns an error
-
getDn
public String getDn(String authId) throws org.ldaptive.LdapException
Description copied from interface:EdService
Gets the LDAP distinguished name for the supplied user.
-
getGroupMembership
public String[] getGroupMembership(String uugidOrDn) throws org.ldaptive.LdapException
Description copied from interface:EdService
Gets the groups of which the given group is a member.- Specified by:
getGroupMembership
in interfaceEdService
- Parameters:
uugidOrDn
- Group to search for parents; may be either UUGID or DN.- Returns:
- Array of groups of which the given group is a member. Returns an empty array if the given group has member suppression enabled.
- Throws:
org.ldaptive.LdapException
- if the LDAP returns an error
-
getMembers
public String[] getMembers(String uugidOrDn) throws org.ldaptive.LdapException
Description copied from interface:EdService
Gets the members of the given group.- Specified by:
getMembers
in interfaceEdService
- Parameters:
uugidOrDn
- UUGID or DN of group to search for members.- Returns:
- Array of group member names. Returns an empty array if the given group has member suppression enabled.
- Throws:
org.ldaptive.LdapException
- if the LDAP returns an error
-
getMemberOf
public String[] getMemberOf(String authId) throws org.ldaptive.LdapException
Description copied from interface:EdService
Gets all the groups the supplied user is a member of.- Specified by:
getMemberOf
in interfaceEdService
- Parameters:
authId
- ED authId attribute value of user.- Returns:
- Array of group UUGID identifiers of which the given user is a member.
- Throws:
org.ldaptive.LdapException
- if the LDAP returns an error
-
toGroupUugid
protected static String toGroupUugid(String uugidOrDn)
Converts a group UUGID or DN to a group UUGID. Since the method makes the determination of the type of input, if given a UUGID it simply returns it.- Parameters:
uugidOrDn
- Group UUGID or DN.- Returns:
- Group UUGID.
-
toUusidDn
protected static String toUusidDn(String uusidOrDn)
Converts a uusid to include the base DN.- Parameters:
uusidOrDn
- Service UUSID or DN.- Returns:
- uusid with the base DN, if uusidOrDn already includes the base DN then it simply returns it.
-
getVirginiaTechPerson
public VirginiaTechPerson getVirginiaTechPerson(String authId) throws org.ldaptive.LdapException
Description copied from interface:EdService
This will query LDAP for the specified authId for a VirginiaTechPerson entry and return theLdapEntry
mapped to aVirginiaTechPerson
bean.- Specified by:
getVirginiaTechPerson
in interfaceEdService
- Parameters:
authId
- ED authId attribute value of user.- Returns:
- VirginiaTechPerson POJO representation of Ldap result.
- Throws:
org.ldaptive.LdapException
- if the LDAP returns an error
-
getVirginiaTechGroup
public VirginiaTechGroup getVirginiaTechGroup(String uugidOrDn) throws org.ldaptive.LdapException
Description copied from interface:EdService
This will query LDAP for the specified uugidOrDn for a VirginiaTechGroup entry and return theLdapEntry
mapped to aVirginiaTechGroup
bean.- Specified by:
getVirginiaTechGroup
in interfaceEdService
- Parameters:
uugidOrDn
- Group to search for; may be either UUGID or DN.- Returns:
- VirginiaTechGroup POJO representation of Ldap result.
- Throws:
org.ldaptive.LdapException
- if the LDAP returns an error
-
getConnectionFactory
public org.ldaptive.ConnectionFactory getConnectionFactory()
Description copied from interface:EdOperation
Gets the underlying connection factory.- Specified by:
getConnectionFactory
in interfaceEdOperation
- Returns:
- Connection factory implementation.
-
-