BEA Systems, Inc.

com.beasys.commerce.bridge.ldap
Class LdapHelper

java.lang.Object
  |
  +--com.beasys.commerce.bridge.ldap.LdapHelper

public class LdapHelper
extends java.lang.Object
implements LDAPBridgeConstants

Single place to make LDAP calls.


Fields inherited from interface com.beasys.commerce.bridge.ldap.LDAPBridgeConstants
LDAP_CONFIG, LDAP_ENABLED_ATTRIBUTE, LDAP_GROUP_ATTRIBUTE, LDAP_USER_ATTRIBUTE
 
Constructor Summary
LdapHelper()
           
 
Method Summary
 boolean authenticate(java.lang.String username, java.lang.String password)
          Authenticates a username and password against an LDAP directory.
 java.util.Iterator findUsernamesThatStartWith(java.lang.String start)
          Returns an iterator containing the names of all the users that start with a certain set of characters.
 java.lang.String formatDN(java.lang.String dnInfo)
          Given whatever is in the WebLogic LDAP Realm's properties file, formats a value correctly for use as a DN by reversing the order.
 java.util.Iterator getAllGroupNames()
          Returns all of the groups that this configuration is set up to use.
 java.util.ArrayList getAllGroupNamesAsArrayList()
          Returns all of the groups that this configuration is set up to use.
 java.lang.String getGroupDN(java.lang.String groupName)
          Given a unique group name returns the group's DN (distinguished name).
 java.util.Iterator getGroupNamesForUser(java.lang.String username)
          Returns the names of the groups of which a user is a member.
 java.util.Map getGroupProperties(java.lang.String groupName)
          Returns properties for a group from LDAP.
 java.lang.Object getService(java.lang.String aLookupName)
           
 java.lang.String getUserDN(java.lang.String username)
          Given a unique username returns the user's DN (distinguished name).
 java.util.Iterator getUsernames(java.lang.String searchExpression, int limit)
          Returns the usernames in LDAP that match the search expression.
 java.util.Iterator getUsernamesForGroup(java.lang.String groupName)
          Returns the usernames for the users in a group.
 java.util.Iterator getUsernamesForGroup(java.lang.String groupName, java.lang.String searchExpression, int limit)
          Returns a group's list of members in the form of users' names
 java.util.Map getUserProperties(java.lang.String username)
          Returns properties for a user from LDAP.
 boolean groupExists(java.lang.String groupName)
          Returns true if a group by this name exists.
 java.util.Iterator realGetUsernamesForGroup(java.lang.String groupName, java.lang.String searchExpression, int limit)
           
 boolean userExists(java.lang.String username)
          Determines if a user exists in an LDAP directory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LdapHelper

public LdapHelper()
Method Detail

userExists

public boolean userExists(java.lang.String username)
                   throws java.lang.Exception
Determines if a user exists in an LDAP directory.
Parameters:
username - the unique username of a person in the directory
Returns:
true if the user exists in the LDAP directory
Throws:
java.lang.Exception - if a system error occurs

authenticate

public boolean authenticate(java.lang.String username,
                            java.lang.String password)
                     throws java.lang.Exception
Authenticates a username and password against an LDAP directory.
Parameters:
username - the username of the user
password - the user's password
Returns:
true if the authentication was successful, otherwise false
Throws:
java.lang.Exception - if a system error occurs

getUserProperties

public java.util.Map getUserProperties(java.lang.String username)
                                throws java.lang.Exception
Returns properties for a user from LDAP.
Parameters:
username - the user's username
Returns:
properties for a user from LDAP
Throws:
java.lang.Exception - if a system error occurs

getGroupProperties

public java.util.Map getGroupProperties(java.lang.String groupName)
                                 throws java.lang.Exception
Returns properties for a group from LDAP.
Parameters:
groupName - the group's unique display name
Returns:
properties for a group from LDAP
Throws:
java.lang.Exception - if a system error occurs

getAllGroupNames

public java.util.Iterator getAllGroupNames()
                                    throws java.lang.Exception
Returns all of the groups that this configuration is set up to use.
Returns:
all of the groups that this configuration is set up to use
Throws:
java.lang.Exception - if a system error occurs

getAllGroupNamesAsArrayList

public java.util.ArrayList getAllGroupNamesAsArrayList()
                                                throws java.lang.Exception
Returns all of the groups that this configuration is set up to use.
Returns:
all of the groups that this configuration is set up to use
Throws:
java.lang.Exception - if a system error occurs

groupExists

public boolean groupExists(java.lang.String groupName)
                    throws java.lang.Exception
Returns true if a group by this name exists.
Parameters:
groupName - the name of the group
Returns:
true if a group by this name exists
Throws:
java.lang.Exception - if a system error occurs

getUserDN

public java.lang.String getUserDN(java.lang.String username)
                           throws java.lang.Exception
Given a unique username returns the user's DN (distinguished name). Does not validate that the user exists.
Parameters:
username - the user's unique username
Returns:
the user's DN
Throws:
java.lang.Exception - if a system error occurs

getGroupDN

public java.lang.String getGroupDN(java.lang.String groupName)
                            throws java.lang.Exception
Given a unique group name returns the group's DN (distinguished name). Does not validate that the group exists.
Parameters:
groupName - the group's unique group name
Returns:
the group's DN
Throws:
java.lang.Exception - if a system error occurs

getUsernamesForGroup

public java.util.Iterator getUsernamesForGroup(java.lang.String groupName)
                                        throws java.lang.Exception
Returns the usernames for the users in a group.
Parameters:
groupName - the name of the group
Returns:
the usernames for the users in a group
Throws:
java.lang.Exception - if a system error occurs

getUsernames

public java.util.Iterator getUsernames(java.lang.String searchExpression,
                                       int limit)
                                throws java.lang.Exception
Returns the usernames in LDAP that match the search expression. The only special character supported is the wildcard character ("*").
Parameters:
searchExpression - a search expression such as "J* Smith" where wildcards ("*") are the only supported special character
limit - a limit of results to return (0 returns the maximum)
Returns:
the usernames for the users in a group
Throws:
java.lang.Exception - if a system error occurs

getUsernamesForGroup

public java.util.Iterator getUsernamesForGroup(java.lang.String groupName,
                                               java.lang.String searchExpression,
                                               int limit)
                                        throws java.lang.Exception
Returns a group's list of members in the form of users' names
Parameters:
groupName - the name of the group
searchExpression - a search expression such as "J* Smith" where wildcards ("*") are the only supported special character
limit - a limit of results to return (0 returns the maximum)
Throws:
java.lang.Exception - if a system error occurs

realGetUsernamesForGroup

public java.util.Iterator realGetUsernamesForGroup(java.lang.String groupName,
                                                   java.lang.String searchExpression,
                                                   int limit)
                                            throws java.lang.Exception

getGroupNamesForUser

public java.util.Iterator getGroupNamesForUser(java.lang.String username)
                                        throws java.lang.Exception
Returns the names of the groups of which a user is a member.
Parameters:
username - the name of the user
Returns:
the names of the groups of which a user is a member
Throws:
java.lang.Exception - if a system error occurs

findUsernamesThatStartWith

public java.util.Iterator findUsernamesThatStartWith(java.lang.String start)
                                              throws java.lang.Exception
Returns an iterator containing the names of all the users that start with a certain set of characters.

formatDN

public java.lang.String formatDN(java.lang.String dnInfo)
                          throws java.lang.Exception
Given whatever is in the WebLogic LDAP Realm's properties file, formats a value correctly for use as a DN by reversing the order. For example, if a DN in the WebLogic ldaprealm.properties is

o=Acme,ou=North America,ou=People

Then this method would format the DN to be

ou=People,ou=North America,o=Acme

This formatted DN is in the order in which LDAP servers want to see it. Note: you do not need to format a DN that is already in the correct order, if you do it's order will be reversed and it will no longer work.

Parameters:
dnInfo - an LDAP DN in reverse order (as it would be in ldaprealm.properties)
Returns:
the DN in reverse order - correct for LDAP queries

getService

public java.lang.Object getService(java.lang.String aLookupName)

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved