public class OwLdapConnector extends Object
Utility class for connecting to an LDAP Server.
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
Modifier and Type | Field and Description |
---|---|
static String |
ELEMENT_SCHEMA_INTERPRETER
name of the configuration element changing the LDAP attribute storing the schema interpreter class name.
|
static String |
USER_DN_PROPERTY
Distinguished name property name
|
static String |
USERS_DIRECTORY_PROPERTY |
Constructor and Description |
---|
OwLdapConnector(Node configNode_p)
Construct LDAP connector from the XML config node of bootstrap.xml
|
OwLdapConnector(Properties props_p,
int recursionLevel_p)
Construct the LDAP Connector with given properties
|
Modifier and Type | Method and Description |
---|---|
void |
authenticate(String userName_p,
String password_p)
Authenticates a user using LDAP.
The user name and password are stored for further operations. |
OwLdapConnection |
createConnection(boolean adminConnection_p)
Create a Connection with properties depending on the given parameter.
|
String |
findDistinguishedNameAnonymously(String user_p)
Returns the full distinguished name for the login user to use for authentication later.
|
OwObjectCollection |
findGroupsMatching(String namePattern)
Find groups that match a given pattern.
|
OwUserInfo |
findUserByDNAnonymously(String strID_p)
Finds a user by its Distinguished Name.
|
OwUserInfo |
findUserByIdAnonymously(String strID_p)
Finds a user by its id.
|
OwUserInfo |
findUserByLoginAnonymously(String strID_p) |
OwObjectCollection |
findUserDNsMatching(String pattern) |
Collection |
getAllShortGroupNames()
Reads all groups from the LDAP (e.g.
|
Collection |
getAllShortGroupNames(boolean useAdminAccount_p)
Reads all groups from the LDAP (e.g.
|
Properties |
getProperties()
Returns the properties used to build up the LDAP context of the logged in user
|
protected Properties |
getProperties(boolean admin_p)
Get specific properties configuration of user or admin.
|
String |
getRecordId(String dname)
Retrieves the value of the attribute that should be used as OWD ID.
|
int |
getRecursionLevel()
Get the defined level of recursion.
|
Collection |
getShortGroupNames()
Returns the group names of the user.
|
Collection |
getShortGroupNames(boolean useAdminAccount_p)
Returns the group names of the user.
|
String |
getUserDisplayName()
Get the user display name, or a
null value. |
String |
getUserDisplayName(String dname)
Get the display name for the user with the given DN.
|
String |
getUserId()
Returns a unique ID of the user
|
String |
getUserLogin(String dname)
Retrieves the login for the user with the given DN.
|
String |
getUserLongName()
Gets the user's long name
|
String |
getUserShortName()
Get the user short name, or a
null value. |
protected void |
prepareForAuthentication(String userName_p,
String password_p)
Called before authentication method to prepare configuration for
|
String |
toString()
toString method: creates a String representation of the object
|
public static final String USERS_DIRECTORY_PROPERTY
public static final String ELEMENT_SCHEMA_INTERPRETER
public static final String USER_DN_PROPERTY
public OwLdapConnector(Properties props_p, int recursionLevel_p)
props_p
- properties used to build up the LDAP contextrecursionLevel_p
- Recursion level for getting the groups of a given userpublic OwLdapConnector(Node configNode_p)
configNode_p
- XML node of bootstrap.xmlpublic OwLdapConnection createConnection(boolean adminConnection_p)
adminConnection_p
- boolean flag to initialize with specific propertiesOwLdapConnection
based on the administrator properties if adminConnection_p is true or the
users properties if adminConnection_p is falsepublic Properties getProperties()
Properties
protected Properties getProperties(boolean admin_p)
admin_p
- booleanpublic void authenticate(String userName_p, String password_p) throws OwAuthenticationException, OwConfigurationException
userName_p
- (the samAccount)password_p
- OwAuthenticationException
- LDAP authorization ExceptionOwConfigurationException
- possible cause: the LDAP connector is not set up correctly in the bootstrap.xml (Authentication node)protected void prepareForAuthentication(String userName_p, String password_p) throws OwAuthenticationException, OwConfigurationException
userName_p
- password_p
- OwAuthenticationException
OwConfigurationException
public Collection getShortGroupNames() throws OwAuthenticationException, OwInvalidOperationException
OwAuthenticationException
- LDAP authorization ExceptionOwInvalidOperationException
- invalid LDAP operationpublic Collection getShortGroupNames(boolean useAdminAccount_p) throws OwAuthenticationException, OwInvalidOperationException
useAdminAccount_p
- if true the LDAP Connector uses the administrator account set
in the bootstrap.xml to retrieve the user group names of the logged in user, if false use the
user logged in user account to retrieve this informations.OwAuthenticationException
- LDAP authorization ExceptionOwInvalidOperationException
- invalid LDAP operationpublic Collection getAllShortGroupNames() throws OwAuthenticationException, OwInvalidOperationException
OwAuthenticationException
- LDAP authorization ExceptionOwInvalidOperationException
- invalid LDAP operationpublic Collection getAllShortGroupNames(boolean useAdminAccount_p) throws OwAuthenticationException, OwInvalidOperationException
useAdminAccount_p
- if true the LDAP Connector uses the administrator account set
in the bootstrap.xml to retrieve the user group names of the logged in user, if false use the
user logged in user account to retrieve this informations.OwAuthenticationException
- LDAP authorization ExceptionOwInvalidOperationException
- invalid LDAP operationpublic String getUserLongName() throws OwAuthenticationException, OwInvalidOperationException
String
OwAuthenticationException
- LDAP authorization ExceptionOwInvalidOperationException
- invalid LDAP operationpublic String getUserId() throws OwAuthenticationException, OwInvalidOperationException
String
OwAuthenticationException
- LDAP authorization ExceptionOwInvalidOperationException
- invalid LDAP operationpublic String findDistinguishedNameAnonymously(String user_p) throws OwAuthenticationException, OwConfigurationException
user_p
- representing the login name for the user being searchedOwAuthenticationException
- the user that wants to login is not available in the LDAPOwConfigurationException
- possible cause: the LDAP connector is not set up correctly in the bootstrap.xml (Authentication node)public OwObjectCollection findUserDNsMatching(String pattern) throws OwException
OwException
public String getUserShortName() throws OwAuthenticationException, OwInvalidOperationException
null
value.null
value.OwAuthenticationException
- thrown when the user is not authenticated.OwInvalidOperationException
- thrown when the "name" attribute cannot be resolved.public String getUserDisplayName() throws OwAuthenticationException, OwInvalidOperationException
null
value.null
value.OwAuthenticationException
- thrown when the user is not authenticated.OwInvalidOperationException
- thrown when the "displayName" attribute cannot be resolved.public String toString()
public OwUserInfo findUserByDNAnonymously(String strID_p) throws OwException
strID_p
- OwException
- Throws OwObjectNotFoundException if no user was found.public OwUserInfo findUserByIdAnonymously(String strID_p) throws OwException
strID_p
- OwException
- Throws OwObjectNotFoundException if no user was found.public String getUserDisplayName(String dname) throws OwException
dname
- The DN of the user.OwException
public String getUserLogin(String dname) throws OwException
dname
- OwException
public String getRecordId(String dname) throws OwException
dname
- The LDAP DN of the record (group, user)OwException
public int getRecursionLevel()
public OwUserInfo findUserByLoginAnonymously(String strID_p) throws OwException
strID_p
- OwException
public OwObjectCollection findGroupsMatching(String namePattern) throws OwException
namePattern
- pattern for the group name to search by.OwUserInfo
representing groups that match the pattern.OwException
Copyright © 2014 Alfresco Business Solutions. All Rights Reserved.