gov.bnl.gums.persistence
Class LDAPPersistenceFactory

java.lang.Object
  extended by gov.bnl.gums.persistence.PersistenceFactory
      extended by gov.bnl.gums.persistence.LDAPPersistenceFactory

public class LDAPPersistenceFactory
extends PersistenceFactory

Author:
Gabriele Carcassi, Jay Packard

Constructor Summary
LDAPPersistenceFactory()
          Create a new ldap persistence factory.
LDAPPersistenceFactory(Configuration configuration)
          Create a new ldap persistence factory with a configuration.
LDAPPersistenceFactory(Configuration configuration, String name)
          Create a new ldap persistence factory with a configuration and a name.
 
Method Summary
 void addMapEntry(String userDN, String account, String mapName, String mapDN)
          Adds a userDN -> account mapping entry in the "map=mapName" LDAP map.
 void addToSecondaryGroup(String account, String groupname)
          Adds the account to the given secondary group.
 void addUserGroupEntry(String userDN, String groupName, String groupDN)
          Adds a certificate DN to the group "group=groupName".
 void changeEmail(String account, String email)
          Changes the email for the given account.
 void changeGroupID(String account, String groupname)
          Changes the primary gid for the given account.
 PersistenceFactory clone(Configuration configuration)
          Create a clone of itself
 void createAccountInMap(String account, String mapName, String mapDN)
          Creates an account in the map "map=mapName", without having a userDN: this is useful for pools of accounts.
protected  DirContext createGroupContext()
           
protected  DirContext createGumsContext()
          Create a new LDAP DirContext based on the configuration.
 void createMap(String mapName, String mapDN)
          Creates a new "map=mapName" entry in the LDAP GUMS tree.
protected  DirContext createPeopleContext()
           
 void createUserGroup(String groupName, String groupDN)
          Creates a new "group=groupName" entry in the LDAP GUMS tree.
 boolean destroyAccountInMap(String account, String mapName, String mapDN)
          Deletes the account in map.
 void destroyMap(String mapName, String mapDN)
          Deletes the "map=mapName" map in the LDAP GUMS tree.
 String getAccountField()
           
 String getCaCertFile()
           
 String getEmailField()
           
 String getGidNumberField()
           
 String getGroupCnField()
           
 String getGroupField()
           
 String getGroupIdField()
           
 String getGroupTree()
           
 String getGumsObject()
           
 String getGumsTree()
           
 String getMemberAccountField()
           
 String getMemberUidField()
           
 String getPeopleTree()
           
 String getTrustStorePassword()
           
 String getType()
           
static String getTypeStatic()
           
 String getUidField()
           
 boolean isSynch()
          This property forces the update for account pools at every access.
 boolean isSynchGroups()
           
 void releaseContext(DirContext context)
          Returns the LDAP DirContext to the pool, so that it can be reused.
 boolean removeMapEntry(String userDN, String mapName, String mapDN)
          Removes a userDN -> acount mapping entry in the "map=mapName LDAP map.
 void removeUserGroupEntry(String userDN, String groupName, String groupDN)
          Removes a certificate DN to the group "group=groupName".
 AccountPoolMapperDB retrieveAccountPoolMapperDB(String nameAndGroups)
           
 ConfigurationDB retrieveConfigurationDB()
           
 String retrieveEmail(String uid)
           
 DirContext retrieveGroupContext()
           
 DirContext retrieveGumsDirContext()
           
 ManualAccountMapperDB retrieveManualAccountMapperDB(String name)
           
 ManualUserGroupDB retrieveManualUserGroupDB(String name)
           
 DirContext retrievePeopleContext()
           
 UserGroupDB retrieveUserGroupDB(String name)
           
 void setAccountField(String accountField)
           
 void setCaCertFile(String caCertFile)
           
 void setEmailField(String emailField)
           
 void setGidNumberField(String gidNumberField)
           
 void setGroupCnField(String groupCnField)
           
 void setGroupField(String groupField)
           
 void setGroupIdField(String groupIdField)
           
 void setGroupTree(String groupTree)
           
 void setGumsTree(String gumsTree)
           
 void setMemberAccountField(String memberAccountField)
           
 void setMemberUidField(String memberUidField)
           
 void setPeopleTree(String peopleTree)
           
 void setProperties(Properties properties)
          Sets the list of properties to be used to connect to LDAP, that is to create the JNDI context.
 void setSynch(boolean synch)
          This property forces the update for account pools at every access.
 void setSynchGroups(boolean synchGroups)
           
 void setTrustStorePassword(String trustStorePassword)
           
 void setUidField(String uidField)
           
 String toXML()
          Get XML representation of this object for writing to gums.config
 
Methods inherited from class gov.bnl.gums.persistence.PersistenceFactory
getConfiguration, getDescription, getName, getProperties, getStoreConfig, setConfiguration, setDescription, setName, setStoreConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDAPPersistenceFactory

public LDAPPersistenceFactory()
Create a new ldap persistence factory. This empty constructor is needed by the XML Digester.


LDAPPersistenceFactory

public LDAPPersistenceFactory(Configuration configuration)
Create a new ldap persistence factory with a configuration.

Parameters:
configuration -

LDAPPersistenceFactory

public LDAPPersistenceFactory(Configuration configuration,
                              String name)
Create a new ldap persistence factory with a configuration and a name.

Parameters:
configuration -
name -
Method Detail

getTypeStatic

public static String getTypeStatic()

addMapEntry

public void addMapEntry(String userDN,
                        String account,
                        String mapName,
                        String mapDN)
Adds a userDN -> account mapping entry in the "map=mapName" LDAP map.

Parameters:
userDN - the certificate DN of the user (i.e. "/DC=org/DC=doegrids/OU=People/CN=John Smith")
account - the account to whith to map the DN (i.e. "carcassi")
mapName - the name of the map (i.e. "usatlasSpecialMap")
mapDN - the map DN (i.e. "map=usatlasSpecialMap, ou=GUMS")

addToSecondaryGroup

public void addToSecondaryGroup(String account,
                                String groupname)
Adds the account to the given secondary group.

Parameters:
account - the account to add to the secondary group (i.e. "carcassi")
groupname - the secondary group name (i.e. "usatlas")

addUserGroupEntry

public void addUserGroupEntry(String userDN,
                              String groupName,
                              String groupDN)
Adds a certificate DN to the group "group=groupName".

Parameters:
userDN - the certificate DN of the user (i.e. "/DC=org/DC=doegrids/OU=People/CN=John Smith")
groupName - the name of the group (i.e. "usatlas")
groupDN - the group DN (i.e. "group=usatlas, ou=GUMS")

changeEmail

public void changeEmail(String account,
                        String email)
Changes the email for the given account.

Parameters:
account - the account to change the primary group (i.e. "carcassi")
email -

changeGroupID

public void changeGroupID(String account,
                          String groupname)
Changes the primary gid for the given account.

Parameters:
account - the account to change the primary group (i.e. "carcassi")
groupname - the primary group name (i.e. "usatlas")

clone

public PersistenceFactory clone(Configuration configuration)
Description copied from class: PersistenceFactory
Create a clone of itself

Specified by:
clone in class PersistenceFactory
Returns:

createAccountInMap

public void createAccountInMap(String account,
                               String mapName,
                               String mapDN)
Creates an account in the map "map=mapName", without having a userDN: this is useful for pools of accounts.

Parameters:
account - the account to whith to map the DN (i.e. "grid0001")
mapName - the name of the map (i.e. "usatlasSpecialMap")
mapDN - the map DN (i.e. "map=usatlasSpecialMap, ou=GUMS")

createMap

public void createMap(String mapName,
                      String mapDN)
Creates a new "map=mapName" entry in the LDAP GUMS tree.

Parameters:
mapName - the name of the map (i.e. "usatlasSpecialMap")
mapDN - the map DN (i.e. "map=usatlasSpecialMap, ou=GUMS")

createUserGroup

public void createUserGroup(String groupName,
                            String groupDN)
Creates a new "group=groupName" entry in the LDAP GUMS tree.

Parameters:
groupName - the name of the group (i.e. "usatlas")
groupDN - the group DN (i.e. "group=usatlas, ou=GUMS")

destroyAccountInMap

public boolean destroyAccountInMap(String account,
                                   String mapName,
                                   String mapDN)
Deletes the account in map.

Parameters:
mapName - the name of the map (i.e. "usatlasSpecialMap")
mapDN - the map DN (i.e. "map=usatlasSpecialMap, ou=GUMS")

destroyMap

public void destroyMap(String mapName,
                       String mapDN)
Deletes the "map=mapName" map in the LDAP GUMS tree. Will completely delete the map.

Parameters:
mapName - the name of the map (i.e. "usatlasSpecialMap")
mapDN - the map DN (i.e. "map=usatlasSpecialMap, ou=GUMS")

getAccountField

public String getAccountField()

getCaCertFile

public String getCaCertFile()

getEmailField

public String getEmailField()

getGidNumberField

public String getGidNumberField()

getGroupCnField

public String getGroupCnField()

getGroupField

public String getGroupField()

getGroupIdField

public String getGroupIdField()

getGroupTree

public String getGroupTree()

getGumsObject

public String getGumsObject()

getGumsTree

public String getGumsTree()

getMemberAccountField

public String getMemberAccountField()

getMemberUidField

public String getMemberUidField()

getPeopleTree

public String getPeopleTree()

getTrustStorePassword

public String getTrustStorePassword()

getType

public String getType()
Overrides:
getType in class PersistenceFactory
Returns:
string representation of type of persistence factory

getUidField

public String getUidField()

isSynch

public boolean isSynch()
This property forces the update for account pools at every access. It's handy for when gid and email gets out of synch.

Returns:
if true information is updated every time accounts from the pool are returned.

isSynchGroups

public boolean isSynchGroups()

releaseContext

public void releaseContext(DirContext context)
Returns the LDAP DirContext to the pool, so that it can be reused.

Parameters:
context - the LDAP context to be returned

removeMapEntry

public boolean removeMapEntry(String userDN,
                              String mapName,
                              String mapDN)
Removes a userDN -> acount mapping entry in the "map=mapName LDAP map. It will only remove the user entry, while leaving the account entry.

Parameters:
userDN - the certificate DN of the user (i.e. "/DC=org/DC=doegrids/OU=People/CN=Gabriele Carcassi 12345")
mapName - the name of the map (i.e. "usatlasSpecialMap")
mapDN - the map DN (i.e. "map=usatlasSpecialMap")
Returns:
false if no mapping was removed

removeUserGroupEntry

public void removeUserGroupEntry(String userDN,
                                 String groupName,
                                 String groupDN)
Removes a certificate DN to the group "group=groupName".

Parameters:
userDN - the certificate DN of the user (i.e. "/DC=org/DC=doegrids/OU=People/CN=Gabriele Carcassi 12345")
groupName - the name of the group (i.e. "usatlas")
groupDN - the group DN (i.e. "group=usatlas")

retrieveAccountPoolMapperDB

public AccountPoolMapperDB retrieveAccountPoolMapperDB(String nameAndGroups)
Specified by:
retrieveAccountPoolMapperDB in class PersistenceFactory

retrieveConfigurationDB

public ConfigurationDB retrieveConfigurationDB()
Specified by:
retrieveConfigurationDB in class PersistenceFactory

retrieveEmail

public String retrieveEmail(String uid)

retrieveGroupContext

public DirContext retrieveGroupContext()

retrieveGumsDirContext

public DirContext retrieveGumsDirContext()

retrieveManualAccountMapperDB

public ManualAccountMapperDB retrieveManualAccountMapperDB(String name)
Specified by:
retrieveManualAccountMapperDB in class PersistenceFactory

retrieveManualUserGroupDB

public ManualUserGroupDB retrieveManualUserGroupDB(String name)
Specified by:
retrieveManualUserGroupDB in class PersistenceFactory

retrievePeopleContext

public DirContext retrievePeopleContext()

retrieveUserGroupDB

public UserGroupDB retrieveUserGroupDB(String name)
Specified by:
retrieveUserGroupDB in class PersistenceFactory

setAccountField

public void setAccountField(String accountField)

setCaCertFile

public void setCaCertFile(String caCertFile)

setEmailField

public void setEmailField(String emailField)

setGidNumberField

public void setGidNumberField(String gidNumberField)

setGroupCnField

public void setGroupCnField(String groupCnField)

setGroupField

public void setGroupField(String groupField)

setGroupIdField

public void setGroupIdField(String groupIdField)

setGroupTree

public void setGroupTree(String groupTree)

setGumsTree

public void setGumsTree(String gumsTree)

setMemberAccountField

public void setMemberAccountField(String memberAccountField)

setMemberUidField

public void setMemberUidField(String memberUidField)

setPeopleTree

public void setPeopleTree(String peopleTree)

setProperties

public void setProperties(Properties properties)
Sets the list of properties to be used to connect to LDAP, that is to create the JNDI context.

Overrides:
setProperties in class PersistenceFactory
Parameters:
properties - a set of JNDI properties

setSynch

public void setSynch(boolean synch)
This property forces the update for account pools at every access. It's handy for when gid or email gets out of synch.

Parameters:
synchGroups - if information is updated every time accounts from the pool are returned.

setSynchGroups

public void setSynchGroups(boolean synchGroups)

setTrustStorePassword

public void setTrustStorePassword(String trustStorePassword)

setUidField

public void setUidField(String uidField)

toXML

public String toXML()
Description copied from class: PersistenceFactory
Get XML representation of this object for writing to gums.config

Specified by:
toXML in class PersistenceFactory
Returns:
xml as string

createGroupContext

protected DirContext createGroupContext()

createGumsContext

protected DirContext createGumsContext()
Create a new LDAP DirContext based on the configuration.

Returns:
a new LDAP DirContext

createPeopleContext

protected DirContext createPeopleContext()


Copyright © 2004-2009. All Rights Reserved.