|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.authentication.plugins.ldap.LdapGateway
public class LdapGateway
The constructor of this class connects to the specified LDAP server, thereafter you can check the password of a user.
Access of all accessible attributes for the specified login name (user) is possible as well (demo code). Configuration of the LDAP plugin in xmlBlaster.properties:ldap.serverUrl=ldap://localhost:389/o=xmlBlaster,c=ORG ldap.rootDN=cn=Manager,o=xmlBlaster,c=ORG ldap.rootPwd=secret ldap.loginFieldName=cnYou may set these settings on command line as well:
java -jar lib/xmlBlaster.jar \ -ldap.serverUrl "ldap://localhost:389/o=xmlBlaster,c=ORG" \ -ldap.rootDN "cn=Manager,o=xmlBlaster,c=ORG" \ -ldap.rootPwd "secret" \ -ldap.loginFieldName "cn"NOTE: Authorization for actions is not supported with this plugin, xmlBlaster logs warnings to notify you about this. If you want to implement authorization, please subclass
org.xmlBlaster.authentication.plugins.ldap.Sessionand implement the method:
public boolean isAuthorized(String actionKey, String key) { DirContext ctx = ldap.getRootContext(); // ... your LDAP queries to authorize the user action ... // return true if user may do this. }
Field Summary | |
---|---|
private java.lang.String |
CONTEXT_FACTORY
Specify the initial context implementation to use. |
private Global |
glob
|
private static java.util.logging.Logger |
log
|
private java.lang.String |
loginFieldName
The name in the LDAP server which represents the loginName, here we use 'cn' |
private static java.lang.String |
ME
|
private javax.naming.directory.DirContext |
rootCtx
|
private java.lang.String |
rootDN
The application xmlBlaster has sort of a super user, you may specify it in xmlBlaster.properties or on command line. |
private java.lang.String |
rootPwd
|
private java.lang.String |
serverUrl
|
Constructor Summary | |
---|---|
LdapGateway(Global glob,
java.lang.String serverUrl,
java.lang.String rootDN,
java.lang.String rootPwd,
java.lang.String loginFieldName)
Connects to the LDAP server. |
Method Summary | |
---|---|
boolean |
checkPassword(java.lang.String loginName,
java.lang.String userPassword)
Check password |
void |
close()
Clean up resources |
java.util.Hashtable |
getAllAttributes(java.lang.String loginName,
java.lang.String password,
java.lang.String lookupUserId)
Get all attributes of this 'Person' objectclass |
java.lang.String |
getBaseName()
Extract "o=xmlBlaster,c=ORG" from "ldap://localhost:389/o=xmlBlaster,c=ORG": |
java.lang.String |
getPassword(javax.naming.directory.Attributes result)
We assume that only one password is specified. |
javax.naming.directory.DirContext |
getRootContext()
|
java.lang.String |
getServerUrl()
|
private javax.naming.directory.DirContext |
getUserContext(java.lang.String loginName,
java.lang.String userPassword)
Please close the given Context after usage. |
private java.lang.String |
getUserDN(java.lang.String loginName)
Searches the loginName in LDAP and returns its distinguishable name DN, e.g. |
static void |
main(java.lang.String[] args)
For testing only java org.xmlBlaster.authentication.plugins.ldap.LdapGateway -loginName tim -userPassword tim -logging FINE |
private javax.naming.NamingEnumeration |
search(javax.naming.directory.DirContext ctx,
java.lang.String filter)
Do a ldap query. |
boolean |
userExists(java.lang.String loginName,
java.lang.String password,
java.lang.String loginNameToCheck)
Check if given user exists |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String ME
private static java.util.logging.Logger log
private Global glob
private final java.lang.String CONTEXT_FACTORY
private final java.lang.String rootDN
private final java.lang.String rootPwd
private javax.naming.directory.DirContext rootCtx
private java.lang.String loginFieldName
private final java.lang.String serverUrl
Constructor Detail |
---|
public LdapGateway(Global glob, java.lang.String serverUrl, java.lang.String rootDN, java.lang.String rootPwd, java.lang.String loginFieldName) throws XmlBlasterException
ldap://localhost:389/o=xmlBlaster,c=ORG??sub
serverUrl
- For example "ldap://localhost:389/o=xmlBlaster,c=ORG"rootDN
- The distinguishable name of the application super user e.g. "cn=Manager,o=xmlBlaster,c=ORG"rootPwd
- The password e.g. "topsecret"loginFieldName
- The fieldname where the loginName in LDAP lies (here 'cn') (used for later login as a normal user)
XmlBlasterException
Method Detail |
---|
public void close()
public javax.naming.directory.DirContext getRootContext() throws XmlBlasterException
rootDN
- "cn=Manager,o=xmlBlaster,c=ORG"rootPwd
- "secret"
XmlBlasterException
private java.lang.String getUserDN(java.lang.String loginName) throws XmlBlasterException
The
- cn (user identifier == xmlBlaster login name) to look forA
- valid DN for the given cn or an exception
XmlBlasterException
private javax.naming.directory.DirContext getUserContext(java.lang.String loginName, java.lang.String userPassword) throws XmlBlasterException
loginName
- the user uiduserPassword
- The users password
XmlBlasterException
public java.lang.String getBaseName()
public java.lang.String getServerUrl()
public java.util.Hashtable getAllAttributes(java.lang.String loginName, java.lang.String password, java.lang.String lookupUserId) throws XmlBlasterException
loginName
- The user who does the query (his login name)password
- His passwordpassword
- lookupUserId
- The user we want to examine (can be the same as userId)
XmlBlasterException
public java.lang.String getPassword(javax.naming.directory.Attributes result) throws XmlBlasterException
XmlBlasterException
public boolean userExists(java.lang.String loginName, java.lang.String password, java.lang.String loginNameToCheck) throws XmlBlasterException
loginName
- The user which wants to know this. password
- His passwordloginNameToCheck
- The user to check
XmlBlasterException
public boolean checkPassword(java.lang.String loginName, java.lang.String userPassword) throws XmlBlasterException
userPassword
- The clear text password
XmlBlasterException
private javax.naming.NamingEnumeration search(javax.naming.directory.DirContext ctx, java.lang.String filter) throws XmlBlasterException
ctx
- The connection to ldapfilter
- Filter to use when searching: "(objectclass=*)" -> finds all
XmlBlasterException
public static void main(java.lang.String[] args)
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |