org.bibalex.daf.handlers.ldaphandler
Class LDAPHandler

java.lang.Object
  extended by org.bibalex.daf.handlers.ldaphandler.LDAPHandler

public class LDAPHandler
extends java.lang.Object

LDAPHandler is a class manipulates Directory access-related processes like: -Define the domain controller -Authenticate user through LDAP -List all valid users

Author:
Mohammed.Abuouda

Field Summary
private  java.lang.String adminName
          authenticated user who can explore the system users
private  java.lang.String adminPassword
          tha admin user password
private  java.lang.String bindBase
          simply it's string that defines the domain controller
private  javax.naming.directory.DirContext ctx
           
private  java.lang.String domainIP
          domin IP
private  java.lang.String domainName
          define the domain name, necessary with active directories
private  java.lang.String INITIAL_CONTEXT_FACTORY
          JNDI Factory
private  boolean isActiveDirectory
          boolean to distinguish between Active Directory AD and Linux LDAP
private  java.lang.String LDAPort
          the connection port, default value = 389
private  java.lang.String LDAPUrl
           
private  java.lang.String searchBase
          defines the way to search
private  java.lang.String searchFilter
          defines the filter to search
 
Constructor Summary
LDAPHandler()
          Constructor
 
Method Summary
 boolean closeConnection()
          close the connection
 boolean connectLDAP()
          the connection steps
 void FilterByFirstName(java.lang.String FilterValue)
          Filter by FirstName, get all FirstName which starts with FilterValue
 void FilterByLastName(java.lang.String FilterValue)
          Filter by LastName, get all LastName which starts with FilterValue
 void FilterByMail(java.lang.String FilterValue)
          Filter by mail, get all mail which starts with FilterValue
 javax.naming.NamingEnumeration getUsers()
          return list of users according to the search filter
private  void prepareUser(java.lang.String userName, java.lang.String userPassword)
          prepare user form to connect well
 void setAdminName(java.lang.String AdminNameValue)
          set userName
 void setAdminPassword(java.lang.String AdminPasswordValue)
          set userPassword
 void setBindBase(java.lang.String BindBaseValue)
          define Bind base, your domain controller hierarchy.
 void setDomainIP(java.lang.String domainIPValue)
          define domain IP
 void setDomainName(java.lang.String domainNameValue)
          define domain name
 void setIsActiveDirectory(boolean IsActiveDirectoryValue)
          if the system uses ActiveDirectory then the argument will be true, else it will be false
 void setLDAPort(java.lang.String LDAPortValue)
          define LDAP prot
private  void setLDAPUrl()
          concatenate values to form the url
 void setSearchBase(java.lang.String SearchBaseValue)
          define search base, ex.(dc=local,dc=bibalex,dc=dom)
 boolean validateUser(java.lang.String userName, java.lang.String userPassword)
          if the user is valid the function will return true, else return false
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

domainName

private java.lang.String domainName
define the domain name, necessary with active directories


domainIP

private java.lang.String domainIP
domin IP


LDAPort

private java.lang.String LDAPort
the connection port, default value = 389


bindBase

private java.lang.String bindBase
simply it's string that defines the domain controller


searchBase

private java.lang.String searchBase
defines the way to search


searchFilter

private java.lang.String searchFilter
defines the filter to search


adminName

private java.lang.String adminName
authenticated user who can explore the system users


adminPassword

private java.lang.String adminPassword
tha admin user password


isActiveDirectory

private boolean isActiveDirectory
boolean to distinguish between Active Directory AD and Linux LDAP


INITIAL_CONTEXT_FACTORY

private java.lang.String INITIAL_CONTEXT_FACTORY
JNDI Factory


LDAPUrl

private java.lang.String LDAPUrl

ctx

private javax.naming.directory.DirContext ctx
Constructor Detail

LDAPHandler

public LDAPHandler()
Constructor

Method Detail

setDomainName

public void setDomainName(java.lang.String domainNameValue)
define domain name


setDomainIP

public void setDomainIP(java.lang.String domainIPValue)
define domain IP


setLDAPort

public void setLDAPort(java.lang.String LDAPortValue)
define LDAP prot


setBindBase

public void setBindBase(java.lang.String BindBaseValue)
define Bind base, your domain controller hierarchy. ex.(dc=local,dc=bibalex,dc=dom)


setSearchBase

public void setSearchBase(java.lang.String SearchBaseValue)
define search base, ex.(dc=local,dc=bibalex,dc=dom)


FilterByMail

public void FilterByMail(java.lang.String FilterValue)
Filter by mail, get all mail which starts with FilterValue


FilterByFirstName

public void FilterByFirstName(java.lang.String FilterValue)
Filter by FirstName, get all FirstName which starts with FilterValue


FilterByLastName

public void FilterByLastName(java.lang.String FilterValue)
Filter by LastName, get all LastName which starts with FilterValue


setAdminName

public void setAdminName(java.lang.String AdminNameValue)
set userName


setAdminPassword

public void setAdminPassword(java.lang.String AdminPasswordValue)
set userPassword


setIsActiveDirectory

public void setIsActiveDirectory(boolean IsActiveDirectoryValue)
if the system uses ActiveDirectory then the argument will be true, else it will be false


setLDAPUrl

private void setLDAPUrl()
concatenate values to form the url


prepareUser

private void prepareUser(java.lang.String userName,
                         java.lang.String userPassword)
prepare user form to connect well


validateUser

public boolean validateUser(java.lang.String userName,
                            java.lang.String userPassword)
if the user is valid the function will return true, else return false


connectLDAP

public boolean connectLDAP()
the connection steps


closeConnection

public boolean closeConnection()
close the connection


getUsers

public javax.naming.NamingEnumeration getUsers()
return list of users according to the search filter