Package com.iplanet.ums
Class DataLayer
- java.lang.Object
-
- com.iplanet.ums.DataLayer
-
- All Implemented Interfaces:
Serializable
public class DataLayer extends Object implements Serializable
DataLayer (A PACKAGE SCOPE CLASS) to access LDAP or other database TODO: 1. Needs to subclass and isolate the current implementation of DataLayer as DSLayer for ldap specific operations 2. Improvements needed for _ldapPool: destroy(), initial bind user, tunning for MIN and MAX initial settings etc 3. May choose to extend implementation of _ldapPool from LDAPConnectionPool so that there is load balance between connections. Also _ldapPool may be implemented with a HashTable of (host,port) for mulitple pools of connections for mulitple (host,port) to DS servers instead of single host and port.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttributeValue(Principal principal, Guid guid, String name, String value)Adds value for an attribute and saves the change in the database.voidaddEntry(Principal principal, Guid guid, AttrSet attrSet)Adds entry to the server.voidchangePassword(Guid guid, String attrName, String oldPassword, String newPassword)Changes user password.voiddeleteEntry(Principal principal, Guid guid)Delete entry from the serverAttrgetAttribute(Principal principal, Guid guid, String attrName)ReturnsAttrfrom the given attribute name.Collection<Attr>getAttributes(Principal principal, Guid guid, Collection<String> attrNames)Returns attributes for the given attribute names.String[]getAttributeString(Principal principal, Guid guid, String attrName)Returns String values of the attribute.org.forgerock.opendj.ldap.ConnectiongetConnection(Principal principal)Get connection from pool.static intgetConnNumRetry()static intgetConnRetryInterval()static DataLayergetInstance()Create the singleton DataLayer object if it doesn't exist already.static DataLayergetInstance(ServerInstance serverCfg)Create the singleton DataLayer object if it doesn't exist already.static Set<org.forgerock.opendj.ldap.ResultCode>getRetryErrorCodes()org.forgerock.opendj.ldap.schema.SchemagetSchema(Principal principal)Fetches the schema from the LDAP directory server.static voidinitConnectionParams()voidmodify(Principal principal, Guid guid, Collection<org.forgerock.opendj.ldap.Modification> modifications)Modifies an ldap entry.AttrSetread(Principal principal, Guid guid)Read an ldap entryAttrSetread(Principal principal, Guid guid, String[] attrNames)Reads an ldap entry.org.forgerock.opendj.ldif.ConnectionEntryReaderreadLDAPEntry(Principal principal, org.forgerock.opendj.ldap.requests.SearchRequest request)org.forgerock.opendj.ldap.EntryreadLDAPEntry(org.forgerock.opendj.ldap.Connection ld, String dn, String[] attrnames)voidremoveAttributeValue(Principal principal, Guid guid, String name, String value)Removes value for an attribute and saves the change in the database.voidrename(Principal principal, Guid guid, String newName, boolean deleteOldName)SearchResultssearch(Principal principal, Guid guid, int scope, String searchFilter, String[] attrNames, boolean attrOnly, SearchControl searchControl)Performs synchronous search based on specified ldap filter.SearchResultssearchIDs(Principal principal, Guid guid, int scope, String searchFilter, SearchControl searchControl)Perform synchronous search based on specified ldap filter.
-
-
-
Method Detail
-
initConnectionParams
public static void initConnectionParams()
-
getInstance
public static DataLayer getInstance(ServerInstance serverCfg) throws UMSException
Create the singleton DataLayer object if it doesn't exist already.- Throws:
UMSException
-
getInstance
public static DataLayer getInstance() throws UMSException
Create the singleton DataLayer object if it doesn't exist already. Assumes the server instance for "LDAPUser.Type.AUTH_PROXY".- Throws:
UMSException
-
getConnection
public org.forgerock.opendj.ldap.Connection getConnection(Principal principal) throws org.forgerock.opendj.ldap.LdapException
Get connection from pool. Reauthenticate if necessary- Returns:
- connection that is available to use.
- Throws:
org.forgerock.opendj.ldap.LdapException
-
getAttributeString
public String[] getAttributeString(Principal principal, Guid guid, String attrName)
Returns String values of the attribute.- Parameters:
principal- Authentication Principal.guid- distinguished name.attrName- attribute name.
-
getAttribute
public Attr getAttribute(Principal principal, Guid guid, String attrName)
ReturnsAttrfrom the given attribute name.- Parameters:
principal- Authentication Principal.guid- Distinguished name.attrName- Attribute name.
-
getAttributes
public Collection<Attr> getAttributes(Principal principal, Guid guid, Collection<String> attrNames)
Returns attributes for the given attribute names.- Parameters:
principal- Authentication Principal.guid- Distinguished name.attrNames- Attribute names.- Returns:
- collection of Attr.
-
addEntry
public void addEntry(Principal principal, Guid guid, AttrSet attrSet) throws UMSException
Adds entry to the server.- Parameters:
principal- Authenticated Principal.guid- Distinguished name.attrSet- attribute set containing name/value pairs.- Throws:
AccessRightsException- if insufficient access>EntryAlreadyExistsException- if the entry already exists.UMSException- if fail to add entry.
-
deleteEntry
public void deleteEntry(Principal principal, Guid guid) throws UMSException
Delete entry from the server- Parameters:
guid- globally unique identifier for the entry- Throws:
AccessRightsException- insufficient accessEntryNotFoundException- if the entry is not foundUMSException- Fail to delete the entry
-
read
public AttrSet read(Principal principal, Guid guid) throws UMSException
Read an ldap entry- Parameters:
guid- globally unique identifier for the entry- Returns:
- an attribute set representing the entry in ldap, all non operational attributes are read
- Throws:
EntryNotFoundException- if the entry is not foundUMSException- Fail to read the entry
-
read
public AttrSet read(Principal principal, Guid guid, String[] attrNames) throws UMSException
Reads an ldap entry.- Parameters:
principal- Authentication Principal.guid- Globally unique identifier for the entry.attrNames- Attributes to read.- Returns:
- an attribute set representing the entry in LDAP.
- Throws:
EntryNotFoundException- if the entry is not found.UMSException- if fail to read the entry.
-
rename
public void rename(Principal principal, Guid guid, String newName, boolean deleteOldName) throws UMSException
- Throws:
UMSException
-
modify
public void modify(Principal principal, Guid guid, Collection<org.forgerock.opendj.ldap.Modification> modifications) throws UMSException
Modifies an ldap entry.- Parameters:
principal- Authentication Principal.guid- globally unique identifier for the entry.modifications- Set of modifications for the entry.- Throws:
AccessRightsException- if insufficient accessEntryNotFoundException- if the entry is not found.UMSException- if failure
-
changePassword
public void changePassword(Guid guid, String attrName, String oldPassword, String newPassword) throws UMSException
Changes user password.- Parameters:
guid- globally unique identifier for the entry.attrName- password attribute nameoldPassword- old passwordnewPassword- new password- Throws:
AccessRightsException- if insufficient accessEntryNotFoundException- if the entry is not found.UMSException- if failure
-
addAttributeValue
public void addAttributeValue(Principal principal, Guid guid, String name, String value) throws UMSException
Adds value for an attribute and saves the change in the database.- Parameters:
principal- Authenticated Principal.guid- ID of the entry to which to add the attribute value.name- name of the attribute to which value is being added.value- Value to be added to the attribute.- Throws:
UMSException- if there is any error while adding the value.
-
removeAttributeValue
public void removeAttributeValue(Principal principal, Guid guid, String name, String value) throws UMSException
Removes value for an attribute and saves the change in the database.- Parameters:
principal- Authenticated Principal.guid- the id of the entry from which to remove the attribute value.name- Name of the attribute from which value is being removedvalue- Value to be removed from the attribute.- Throws:
UMSException- if there is any error while removing the value.
-
search
public SearchResults search(Principal principal, Guid guid, int scope, String searchFilter, String[] attrNames, boolean attrOnly, SearchControl searchControl) throws UMSException
Performs synchronous search based on specified ldap filter. This is low level API which assumes caller knows how to construct a data store filer.- Parameters:
principal- Authenticated Principal.guid- Unique identifier for the entry.scope- Scope can be eitherSCOPE_ONE,SCOPE_SUBorSCOPE_BASE.searchFilter- Search filter for this search.attrNames- Attribute name for retrieving.attrOnly- if true, returns the names but not the values of the attributes found.searchControl- Search Control.- Throws:
UMSException- if failure.InvalidSearchFilterException- if failure
-
searchIDs
public SearchResults searchIDs(Principal principal, Guid guid, int scope, String searchFilter, SearchControl searchControl) throws InvalidSearchFilterException, UMSException
Perform synchronous search based on specified ldap filter. This is low level API which assumes caller knows how to construct a data store filer.- Parameters:
principal- Authenticated Principal.guid- Unique identifier for the entryscope- Scope can be eitherSCOPE_ONE,SCOPE_SUB,SCOBE_BASEsearchFilter- Search filter for this search.searchControl- Search Control.- Throws:
UMSException- if failure.InvalidSearchFilterException- if failure.
-
getSchema
public org.forgerock.opendj.ldap.schema.Schema getSchema(Principal principal) throws UMSException
Fetches the schema from the LDAP directory server. Retrieve the entire schema from the root of a Directory Server.- Returns:
- the schema in the LDAP directory server
- Throws:
AccessRightsException- insufficient accessUMSException- Fail to fetch the schema.org.forgerock.opendj.ldap.LdapException- Error with LDAP connection.
-
readLDAPEntry
public org.forgerock.opendj.ldap.Entry readLDAPEntry(org.forgerock.opendj.ldap.Connection ld, String dn, String[] attrnames) throws org.forgerock.opendj.ldap.LdapException- Throws:
org.forgerock.opendj.ldap.LdapException
-
readLDAPEntry
public org.forgerock.opendj.ldif.ConnectionEntryReader readLDAPEntry(Principal principal, org.forgerock.opendj.ldap.requests.SearchRequest request) throws UMSException
- Throws:
UMSException
-
getConnNumRetry
public static int getConnNumRetry()
-
getConnRetryInterval
public static int getConnRetryInterval()
-
getRetryErrorCodes
public static Set<org.forgerock.opendj.ldap.ResultCode> getRetryErrorCodes()
-
-