issrg.dis
Class LDAPUtility

java.lang.Object
  extended by issrg.dis.LDAPUtility
All Implemented Interfaces:
DISCore.Repository

public class LDAPUtility
extends java.lang.Object
implements DISCore.Repository


Field Summary
static java.lang.String AC_attribute
          The variable, containing the name of the attribute the LDAPSavingUtility will retrieve and store.
 
Constructor Summary
LDAPUtility(java.lang.String LDAPServer, java.lang.String rootDN, java.lang.String rootPass, Level level)
          This is the constructor for the LDAPUtility object.
 
Method Summary
 boolean authenticate(java.lang.String key, java.lang.String user, java.lang.String pass)
          This method authenticates the user by his key.
 boolean authenticateUser(java.lang.String userDN, java.lang.String pass)
          This function is used to authenticate a pair user/password against information stored in LDAP
 void deleteAC(java.lang.String dn, int idx)
          Delete AC (Attribute Certificate) from the specified entry and index
 void deleteAllACs(java.lang.String dn)
          Delete all ACs (Attribute Certificate from the specified entry
 javax.naming.directory.DirContext[] getLdaps()
          This method returns the LDAPRepository
 javax.naming.directory.Attribute loadACs(java.lang.String dn)
          Load all ACs (Attribute Certificate) from the specified entry.
 void save(byte[] ac)
          This method saves an AC of a specific user to LDAP
 java.lang.String searchUser(java.lang.String key, java.lang.String user)
          This function is used to search one user in the current LDAP server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AC_attribute

public static java.lang.String AC_attribute
The variable, containing the name of the attribute the LDAPSavingUtility will retrieve and store. At the moment it is "2.5.4.58;binary". The OID of the attribute is 2.5.4.58.

Constructor Detail

LDAPUtility

public LDAPUtility(java.lang.String LDAPServer,
                   java.lang.String rootDN,
                   java.lang.String rootPass,
                   Level level)
This is the constructor for the LDAPUtility object.

Parameters:
LDAPServer - is the URL of the LDAP server
rootDN - is the DN of the administrator of that LDAP server
rootPass - is the password of the administrator of the LDAP server
level - is the debuging level
Method Detail

authenticateUser

public boolean authenticateUser(java.lang.String userDN,
                                java.lang.String pass)
This function is used to authenticate a pair user/password against information stored in LDAP

Parameters:
userDN - is the user's DN
pass - is the password of the above user
Returns:
boolean value indicates whether or not user is successfully authenticated in a specific LDAP server with the provided password.

Note that only simple authentication is supported at the moment.


authenticate

public boolean authenticate(java.lang.String key,
                            java.lang.String user,
                            java.lang.String pass)
This method authenticates the user by his key. The method searches for the DN of the user first, then uses that DN to authenticate.

Parameters:
user - - the user
key - is the key that used for seaching the user (uid as an example)
pass - - the password of the user
Returns:
a boolean value that indicates the authentication process. If it is false then the authentication process fails. If it is true then the authentication process pass

searchUser

public java.lang.String searchUser(java.lang.String key,
                                   java.lang.String user)
This function is used to search one user in the current LDAP server.

Parameters:
userUID - is the UID of the user in LDAP server
key - is a string that used to define the scope of the seach process
Returns:
DN of the user if user with that UID is present in LDAP server. Otherwise, return null.

getLdaps

public javax.naming.directory.DirContext[] getLdaps()
This method returns the LDAPRepository

Returns:
ldaps is the LDAP repository

save

public void save(byte[] ac)
          throws java.lang.Exception
This method saves an AC of a specific user to LDAP

Specified by:
save in interface DISCore.Repository
Parameters:
ac - is the AC of a user The method can throw an exception if it can not save the AC to user's entry in LDAP
Throws:
java.lang.Exception

loadACs

public javax.naming.directory.Attribute loadACs(java.lang.String dn)
                                         throws java.lang.Exception
Load all ACs (Attribute Certificate) from the specified entry.

Specified by:
loadACs in interface DISCore.Repository
Parameters:
dn - the specifed a holder's DN that you want to retrive ACs.
Returns:
the attribute certificates (inside the Attribute) of the holder
Throws:
java.lang.Exception

deleteAC

public void deleteAC(java.lang.String dn,
                     int idx)
              throws java.lang.Exception
Delete AC (Attribute Certificate) from the specified entry and index

Specified by:
deleteAC in interface DISCore.Repository
Parameters:
dn - the user's DN
idx - the specified index. The AC in this position will be deleted
Throws:
java.lang.Exception

deleteAllACs

public void deleteAllACs(java.lang.String dn)
                  throws java.lang.Exception
Delete all ACs (Attribute Certificate from the specified entry

Specified by:
deleteAllACs in interface DISCore.Repository
Parameters:
dn - is the specified entry. All ACs in this entry will be deleted
Throws:
java.lang.Exception