org.olat.ldap
Class LDAPLoginManagerImpl

java.lang.Object
  extended by org.olat.ldap.LDAPLoginManager
      extended by org.olat.ldap.LDAPLoginManagerImpl

public class LDAPLoginManagerImpl
extends LDAPLoginManager

Description: This manager handles communication between LDAP and OLAT. LDAP access is done by JNDI.

LDAPLoginMangerImpl

Author:
Maurus Rohrer

Method Summary
 boolean acquireSyncLock()
          Acquire lock for administration jobs
 javax.naming.directory.InitialDirContext bindSystem()
          Connect to the LDAP server with System DN and Password Configuration: LDAP URL = olatextconfig.xml (property=ldapURL) System DN = olatextconfig.xml (property=ldapSystemDN) System PW = olatextconfig.xml (property=ldapSystemPW)
 javax.naming.directory.Attributes bindUser(java.lang.String uid, java.lang.String pwd, LDAPError errors)
          Connect to LDAP with the User-Name and Password given as parameters Configuration: LDAP URL = olatextconfig.xml (property=ldapURL) LDAP Base = olatextconfig.xml (property=ldapBase) LDAP Attributes Map = olatextconfig.xml (property=userAttrs)
 void changePassword(Identity identity, java.lang.String pwd, LDAPError errors)
          Change the password on the LDAP server.
 void createAndPersistUser(javax.naming.directory.Attributes userAttributes)
          Creates User in OLAT and ads user to LDAP securityGroup Required Attributes have to be checked before this method.
 void deletIdentities(java.util.List<Identity> identityList)
          Delete all Identities in List and removes them from LDAPSecurityGroup
 boolean doBatchSync(LDAPError errors)
          Execute Batch Sync.
 Identity findIdentyByLdapAuthentication(java.lang.String uid, LDAPError errors)
          Searches for Identity in OLAT.
 void freeSyncLock()
          Release lock for administration jobs
 java.util.List<Identity> getIdentitysDeletedInLdap(javax.naming.directory.InitialDirContext ctx)
          Creates list of all OLAT Users which have been deleted out of the LDAP directory but still exits in OLAT Configuration: Required Attributes = olatextconfig.xml (property=reqAttrs) LDAP Base = olatextconfig.xml (property=ldapBase)
 java.util.Date getLastSyncDate()
           
 java.util.List<javax.naming.directory.Attributes> getUserAttributesModifiedSince(java.util.Date syncTime, javax.naming.directory.InitialDirContext ctx)
          Creates list of all LDAP Users or changed Users since syncTime Configuration: userAttr = olatextconfig.xml (property=userAttrs) LDAP Base = olatextconfig.xml (property=ldapBase)
 java.util.Map<java.lang.String,java.lang.String> prepareUserPropertyForSync(javax.naming.directory.Attributes attributes, Identity identity)
          Checks if LDAP properties are different then OLAT properties of a User.
 void syncUser(java.util.Map<java.lang.String,java.lang.String> olatPropertyMap, Identity identity)
          Sync all OLATPropertys in Map of Identity
 
Methods inherited from class org.olat.ldap.LDAPLoginManager
getInstance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bindSystem

public javax.naming.directory.InitialDirContext bindSystem()
Connect to the LDAP server with System DN and Password Configuration: LDAP URL = olatextconfig.xml (property=ldapURL) System DN = olatextconfig.xml (property=ldapSystemDN) System PW = olatextconfig.xml (property=ldapSystemPW)

Specified by:
bindSystem in class LDAPLoginManager
Returns:
The LDAP connection (InitialDirContext) or NULL if connect fails
Throws:
javax.naming.NamingException

bindUser

public javax.naming.directory.Attributes bindUser(java.lang.String uid,
                                                  java.lang.String pwd,
                                                  LDAPError errors)
Connect to LDAP with the User-Name and Password given as parameters Configuration: LDAP URL = olatextconfig.xml (property=ldapURL) LDAP Base = olatextconfig.xml (property=ldapBase) LDAP Attributes Map = olatextconfig.xml (property=userAttrs)

Specified by:
bindUser in class LDAPLoginManager
Parameters:
uid - The users LDAP login name (can't be null)
pwd - The users LDAP password (can't be null)
Returns:
After succsessful bind Attributes otherwise NULL
Throws:
javax.naming.NamingException

changePassword

public void changePassword(Identity identity,
                           java.lang.String pwd,
                           LDAPError errors)
Change the password on the LDAP server.

Specified by:
changePassword in class LDAPLoginManager
See Also:
LDAPLoginManager.changePassword(org.olat.core.id.Identity, java.lang.String, org.olat.ldap.LDAPError)

getUserAttributesModifiedSince

public java.util.List<javax.naming.directory.Attributes> getUserAttributesModifiedSince(java.util.Date syncTime,
                                                                                        javax.naming.directory.InitialDirContext ctx)
Creates list of all LDAP Users or changed Users since syncTime Configuration: userAttr = olatextconfig.xml (property=userAttrs) LDAP Base = olatextconfig.xml (property=ldapBase)

Specified by:
getUserAttributesModifiedSince in class LDAPLoginManager
Parameters:
syncTime - The time to search in LDAP for changes since this time. SyncTime has to formatted: JJJJMMddHHmm
ctx - The LDAP system connection, if NULL or closed NamingExecpiton is thrown
Returns:
Returns list of Arguments of found users or empty list if search fails or nothing is changed
Throws:
javax.naming.NamingException

deletIdentities

public void deletIdentities(java.util.List<Identity> identityList)
Delete all Identities in List and removes them from LDAPSecurityGroup

Specified by:
deletIdentities in class LDAPLoginManager
Parameters:
identityList - List of Identities to delete

syncUser

public void syncUser(java.util.Map<java.lang.String,java.lang.String> olatPropertyMap,
                     Identity identity)
Sync all OLATPropertys in Map of Identity

Specified by:
syncUser in class LDAPLoginManager
Parameters:
olatPropertyMap - Map of changed OLAT properties (OLATProperty,LDAPValue)
identity - Identity to sync

createAndPersistUser

public void createAndPersistUser(javax.naming.directory.Attributes userAttributes)
Creates User in OLAT and ads user to LDAP securityGroup Required Attributes have to be checked before this method.

Specified by:
createAndPersistUser in class LDAPLoginManager
Parameters:
userAttributes - Set of LDAP Attribute of User to be created

prepareUserPropertyForSync

public java.util.Map<java.lang.String,java.lang.String> prepareUserPropertyForSync(javax.naming.directory.Attributes attributes,
                                                                                   Identity identity)
Checks if LDAP properties are different then OLAT properties of a User. If they are different a Map (OlatPropertyName,LDAPValue) is returned.

Specified by:
prepareUserPropertyForSync in class LDAPLoginManager
Parameters:
attributes - Set of LDAP Attribute of Identity
identity - Identity to compare
Returns:
Map(OlatPropertyName,LDAPValue) of properties Identity, where property has changed. NULL is returned it no attributes have to be synced

findIdentyByLdapAuthentication

public Identity findIdentyByLdapAuthentication(java.lang.String uid,
                                               LDAPError errors)
Searches for Identity in OLAT.

Specified by:
findIdentyByLdapAuthentication in class LDAPLoginManager
Parameters:
uid - Name of Identity
errors - LDAPError Object if user exits but not member of LDAPSecurityGroup
Returns:
Identity if it's found and member of LDAPSecurityGroup, null otherwise (if user exists but not managed by LDAP, error Object is modified)

getIdentitysDeletedInLdap

public java.util.List<Identity> getIdentitysDeletedInLdap(javax.naming.directory.InitialDirContext ctx)
Creates list of all OLAT Users which have been deleted out of the LDAP directory but still exits in OLAT Configuration: Required Attributes = olatextconfig.xml (property=reqAttrs) LDAP Base = olatextconfig.xml (property=ldapBase)

Specified by:
getIdentitysDeletedInLdap in class LDAPLoginManager
Parameters:
syncTime - The time to search in LDAP for changes since this time. SyncTime has to formatted: JJJJMMddHHmm
ctx - The LDAP system connection, if NULL or closed NamingExecpiton is thrown
Returns:
Returns list of Identity from the user which have been deleted in LDAP
Throws:
javax.naming.NamingException

doBatchSync

public boolean doBatchSync(LDAPError errors)
Execute Batch Sync. Will update all Attributes of LDAP users in OLAt, create new users and delete users in OLAT. Can be configured in olatextconfig.xml

Specified by:
doBatchSync in class LDAPLoginManager
Parameters:
LDAPError -

getLastSyncDate

public java.util.Date getLastSyncDate()
Specified by:
getLastSyncDate in class LDAPLoginManager
See Also:
LDAPLoginManager.getLastSyncDate()

acquireSyncLock

public boolean acquireSyncLock()
Acquire lock for administration jobs

Specified by:
acquireSyncLock in class LDAPLoginManager

freeSyncLock

public void freeSyncLock()
Release lock for administration jobs

Specified by:
freeSyncLock in class LDAPLoginManager