com.wewebu.ow.server.util.ldap
Class OwLdapConnection

java.lang.Object
  extended by com.wewebu.ow.server.util.ldap.OwLdapConnection

public class OwLdapConnection
extends Object

A LDAP connection contains the directory connection Properties (see InitialDirContext.InitialDirContext(java.util.Hashtable) and standard directory operations needed by the Alfresco Workdesk connector and its schema interpreters.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com

Since:
3.1.0.0

Constructor Summary
OwLdapConnection(Properties ldapProperties_p, int recursionLevel_p)
          Constructor
 
Method Summary
 InitialLdapContext createInitialDirContext()
           
 Object getAttributeValue(String distinguishedName_p, String attributeName_p)
          Get the attribute value for given attribute name.
 String getAttributeValue(String distinguishedName_p, String attributeName_p, boolean trimmCommonName_p)
           
 Properties getProperties()
           
 String getProperty(String propertyName_p, String defaultValue_p)
           
 int getRecursionLevel()
           
 Object getUserAttributeValue(String attributeName_p)
           
 String getUserAttributeValue(String attributeName_p, boolean trimmCommonName_p)
           
 String getUserDistinguishedName()
           
 NamingEnumeration<SearchResult> search(String searchBase_p, String[][] attributeValues_p, String[] returnIds_p)
          Searches the LDAP repository for records matching the given pattern.
 Collection<String> searchAttributeValues(String searchBase_p, String[][] matchAttrs_p, String attribute_p)
           
 OwObjectCollection searchValuesByFilter(String searchBase, String filter, String returningAttibute, String sortKey)
          Search for objects with attributes matching a given pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OwLdapConnection

public OwLdapConnection(Properties ldapProperties_p,
                        int recursionLevel_p)
Constructor

Parameters:
ldapProperties_p - this connection properties
recursionLevel_p - the configured recursion level
Method Detail

createInitialDirContext

public InitialLdapContext createInitialDirContext()
                                           throws OwConfigurationException
Returns:
a new InitialDirContext based on this connection properties
Throws:
OwConfigurationException - if the context creation fails

getProperty

public String getProperty(String propertyName_p,
                          String defaultValue_p)
Parameters:
propertyName_p -
defaultValue_p -
Returns:
value of the given property or the given default value if the property is not defined

getRecursionLevel

public int getRecursionLevel()
Returns:
the configured recursion level. This attribute is used to resolve Groups in Groups relationship.
Ex. LDAP tree:
  • workdesk(objectClass: posixGroup )
  • hr(objectClass: posixGroup, memberOf: workdesk)
  • cr(objectClass: posixGroup, memberOf: workdesk)

If recursionlevel = 0 then groups hr and cr will not be looked up.
If recursionlevel >= 1 then groups hr and cr will be looked up.

This configuration parameter has nothing to do with LDAP nested records.


getProperties

public Properties getProperties()
Returns:
the properties of this connection

getUserDistinguishedName

public String getUserDistinguishedName()
                                throws OwAuthenticationException
Returns:
the distinguished name of the current authenticated user
Throws:
OwAuthenticationException - if no user was authenticated (the OwLdapConnector.USER_DN_PROPERTY is not defined in the properties of this connection)

getUserAttributeValue

public String getUserAttributeValue(String attributeName_p,
                                    boolean trimmCommonName_p)
                             throws OwAuthenticationException,
                                    OwConfigurationException,
                                    OwInvalidOperationException
Parameters:
attributeName_p -
trimmCommonName_p - if true common name prefixed values will be stripped of their common name prefixes (egg. "cn: alice" will be returned as "alice")
Returns:
the string value of the given attribute value as found in the current users directory entry
Throws:
OwAuthenticationException
OwConfigurationException
OwInvalidOperationException

getUserAttributeValue

public Object getUserAttributeValue(String attributeName_p)
                             throws OwAuthenticationException,
                                    OwConfigurationException,
                                    OwInvalidOperationException
Parameters:
attributeName_p -
Returns:
the Object value of the given attribute value as found in the current users directory entry
Throws:
OwAuthenticationException
OwConfigurationException
OwInvalidOperationException

getAttributeValue

public String getAttributeValue(String distinguishedName_p,
                                String attributeName_p,
                                boolean trimmCommonName_p)
                         throws OwAuthenticationException,
                                OwConfigurationException,
                                OwInvalidOperationException
Parameters:
distinguishedName_p -
attributeName_p -
trimmCommonName_p - if true common name prefixed values will be stripped of their common name prefixes (egg. "cn: alice" will be returned as "alice")
Returns:
the string value of the given attribute value as found in the directory entry pointed by the given distinguishedName_p
Throws:
OwAuthenticationException
OwConfigurationException
OwInvalidOperationException

getAttributeValue

public Object getAttributeValue(String distinguishedName_p,
                                String attributeName_p)
                         throws OwAuthenticationException,
                                OwConfigurationException,
                                OwInvalidOperationException
Get the attribute value for given attribute name.

Parameters:
distinguishedName_p - - the attribute name
Returns:
- a String object containing the value for the given attribute, or a null value, in case the requested attribute is not found in LDAP
Throws:
OwAuthenticationException - thrown when the user is not authenticated.
OwInvalidOperationException - thrown when the given attribute cannot be resolved.
OwConfigurationException

searchAttributeValues

public Collection<String> searchAttributeValues(String searchBase_p,
                                                String[][] matchAttrs_p,
                                                String attribute_p)
                                         throws OwAuthenticationException,
                                                OwConfigurationException,
                                                OwInvalidOperationException
Parameters:
searchBase_p -
matchAttrs_p - array of String pairs of attribute name value that will be used in matching the targeted entries example : new String[]{{"objectClass","groupOfNames"},{"cn","administrators"}}
attribute_p - name of the attribute whose values will be returned
Returns:
a collection of String attribute values as found in all entries located in the searchBase_p directory entry that match the given match attributes values
Throws:
OwAuthenticationException
OwConfigurationException
OwInvalidOperationException

search

public NamingEnumeration<SearchResult> search(String searchBase_p,
                                              String[][] attributeValues_p,
                                              String[] returnIds_p)
                                       throws OwConfigurationException,
                                              OwInvalidOperationException
Searches the LDAP repository for records matching the given pattern.

Parameters:
searchBase_p -
attributeValues_p -
returnIds_p -
Returns:
the result of the search
Throws:
OwConfigurationException
OwInvalidOperationException
Since:
4.1.1.0

searchValuesByFilter

public OwObjectCollection searchValuesByFilter(String searchBase,
                                               String filter,
                                               String returningAttibute,
                                               String sortKey)
                                        throws OwException
Search for objects with attributes matching a given pattern.

Parameters:
searchBase -
filter -
returningAttibute -
sortKey - if null no sorting will be performed
Returns:
a list of matching objects.
Throws:
OwException


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.