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, java.lang.String name)
          Create a new ldap persistence factory with a configuration and a name.
 
Method Summary
 void addMapEntry(java.lang.String userDN, java.lang.String account, java.lang.String mapName, java.lang.String mapDN)
          Adds a userDN -> account mapping entry in the "map=mapName" LDAP map.
 void addToSecondaryGroup(java.lang.String account, java.lang.String groupname)
          Adds the account to the given secondary group.
 void addUserGroupEntry(java.lang.String userDN, java.lang.String groupName, java.lang.String groupDN)
          Adds a certificate DN to the group "group=groupName".
 void changeGroupID(java.lang.String account, java.lang.String groupname)
          Changes the primary gid for the given account.
 PersistenceFactory clone(Configuration configuration)
          Create a clone of itself
 void createAccountInMap(java.lang.String account, java.lang.String mapName, java.lang.String mapDN)
          Creates an account in the map "map=mapName", without having a userDN: this is useful for pools of accounts.
protected  javax.naming.directory.DirContext createLDAPContext()
          Create a new LDAP DirContext based on the configuration.
 void createMap(java.lang.String mapName, java.lang.String mapDN)
          Creates a new "map=mapName" entry in the LDAP GUMS tree.
 void createUserGroup(java.lang.String groupName, java.lang.String groupDN)
          Creates a new "group=groupName" entry in the LDAP GUMS tree.
 boolean destroyAccountInMap(java.lang.String account, java.lang.String mapName, java.lang.String mapDN)
          Deletes the account in map.
 void destroyMap(java.lang.String mapName, java.lang.String mapDN)
          Deletes the "map=mapName" map in the LDAP GUMS tree.
 java.lang.String getAccountField()
           
 java.lang.String getCaCertFile()
           
 java.lang.String getGroupIdField()
           
 java.lang.String getGumsOU()
           
 javax.naming.directory.DirContext getLDAPContext()
          Returns a Context ready to be used (taken from the pool).
 java.lang.String getMemberAccountField()
           
 java.lang.String getTrustStorePassword()
           
 java.lang.String getType()
           
static java.lang.String getTypeStatic()
           
 boolean isSynchGroups()
          This property forces the gid update for account pools at every access.
 void releaseContext(javax.naming.directory.DirContext context)
          Returns the LDAP DirContext to the pool, so that it can be reused.
 boolean removeMapEntry(java.lang.String userDN, java.lang.String mapName, java.lang.String mapDN)
          Removes a userDN -> acount mapping entry in the "map=mapName LDAP map.
 void removeUserGroupEntry(java.lang.String userDN, java.lang.String groupName, java.lang.String groupDN)
          Removes a certificate DN to the group "group=groupName".
 AccountPoolMapperDB retrieveAccountPoolMapperDB(java.lang.String nameAndGroups)
           
 javax.naming.directory.DirContext retrieveContext()
          Retrieves an LDAP DirContext from the pool, if available and still valid, or creates a new DirContext if none are found.
 ManualAccountMapperDB retrieveManualAccountMapperDB(java.lang.String name)
           
 ManualUserGroupDB retrieveManualUserGroupDB(java.lang.String name)
           
 UserGroupDB retrieveUserGroupDB(java.lang.String name)
           
 void setAccountField(java.lang.String accountField)
           
 void setCaCertFile(java.lang.String caCertFile)
           
 void setGroupIdField(java.lang.String groupIdField)
           
 void setMemberAccountField(java.lang.String memberAccountField)
           
 void setProperties(java.util.Properties properties)
          Sets the list of properties to be used to connect to LDAP, that is to create the JNDI context.
 void setSynchGroups(boolean synchGroups)
          This property forces the gid update for account pools at every access.
 void setTrustStorePassword(java.lang.String trustStorePassword)
           
 java.lang.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, setConfiguration, setDescription, setName
 
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,
                              java.lang.String name)
Create a new ldap persistence factory with a configuration and a name.

Parameters:
configuration -
name -
Method Detail

getTypeStatic

public static java.lang.String getTypeStatic()

addMapEntry

public void addMapEntry(java.lang.String userDN,
                        java.lang.String account,
                        java.lang.String mapName,
                        java.lang.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(java.lang.String account,
                                java.lang.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(java.lang.String userDN,
                              java.lang.String groupName,
                              java.lang.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")

changeGroupID

public void changeGroupID(java.lang.String account,
                          java.lang.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(java.lang.String account,
                               java.lang.String mapName,
                               java.lang.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(java.lang.String mapName,
                      java.lang.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(java.lang.String groupName,
                            java.lang.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(java.lang.String account,
                                   java.lang.String mapName,
                                   java.lang.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(java.lang.String mapName,
                       java.lang.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 java.lang.String getAccountField()

getCaCertFile

public java.lang.String getCaCertFile()

getGumsOU

public java.lang.String getGumsOU()

getGroupIdField

public java.lang.String getGroupIdField()

getLDAPContext

public javax.naming.directory.DirContext getLDAPContext()
Returns a Context ready to be used (taken from the pool). This is the entry point for the pool, and it can be used by test cases to prepare the LDAP server.

Returns:
an LDAP context

getMemberAccountField

public java.lang.String getMemberAccountField()

getTrustStorePassword

public java.lang.String getTrustStorePassword()

getType

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

isSynchGroups

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

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

releaseContext

public void releaseContext(javax.naming.directory.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(java.lang.String userDN,
                              java.lang.String mapName,
                              java.lang.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(java.lang.String userDN,
                                 java.lang.String groupName,
                                 java.lang.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(java.lang.String nameAndGroups)
Specified by:
retrieveAccountPoolMapperDB in class PersistenceFactory

retrieveContext

public javax.naming.directory.DirContext retrieveContext()
Retrieves an LDAP DirContext from the pool, if available and still valid, or creates a new DirContext if none are found.

Returns:
an LDAP DirContext

retrieveManualAccountMapperDB

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

retrieveManualUserGroupDB

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

retrieveUserGroupDB

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

setAccountField

public void setAccountField(java.lang.String accountField)

setCaCertFile

public void setCaCertFile(java.lang.String caCertFile)

setGroupIdField

public void setGroupIdField(java.lang.String groupIdField)

setMemberAccountField

public void setMemberAccountField(java.lang.String memberAccountField)

setProperties

public void setProperties(java.util.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

setSynchGroups

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

Parameters:
synchGroups - if true gids are updated every time accounts from the pool are returned.

setTrustStorePassword

public void setTrustStorePassword(java.lang.String trustStorePassword)

toXML

public java.lang.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

createLDAPContext

protected javax.naming.directory.DirContext createLDAPContext()
Create a new LDAP DirContext based on the configuration.

Returns:
a new LDAP DirContext


Copyright © 2004-2008. All Rights Reserved.