The jvm should be started with the following parameter:
-Djava.security.auth.login.config=etc/ldap-loginModule.conf
and an example of the ldap-loginModule.conf would be:
ldaploginmodule {
org.mortbay.jetty.plus.jaas.spi.LdapLoginModule required
debug="true"
contextFactory="com.sun.jndi.ldap.LdapCtxFactory"
hostname="ldap.example.com"
port="389"
bindDn="cn=Directory Manager"
bindPassword="directory"
authenticationMethod="simple"
forceBindingLogin="false"
userBaseDn="ou=people,dc=alcatel"
userRdnAttribute="uid"
userIdAttribute="uid"
userPasswordAttribute="userPassword"
userObjectClass="inetOrgPerson"
roleBaseDn="ou=groups,dc=example,dc=com"
roleNameAttribute="cn"
roleMemberAttribute="uniqueMember"
roleObjectClass="groupOfUniqueNames";
};
| Modifier and Type | Field and Description |
|---|---|
| private String | _authenticationMethod
Context.SECURITY_AUTHENTICATION |
| private String | _bindDn
root DN used to connect to |
| private String | _bindPassword
password used to connect to the root ldap context |
| private String | _contextFactory
Context.INITIAL_CONTEXT_FACTORY |
| private boolean | |
| private boolean | _forceBindingLogin
if the getUserInfo can pull a password off of the user then password comparison is an option for authn, to force binding login checks, set this to true |
| private String | _hostname
hostname of the ldap server |
| private int | _port
port of the ldap server |
| private String | _roleBaseDn
base DN where role membership is to be searched from |
| private String | _roleMemberAttribute
name of the attribute that a username would be under a role class |
| private String | _roleNameAttribute
the name of the attribute that a role would be stored under |
| private String | _roleObjectClass
object class of roles |
| private DirContext | |
| private String | _userBaseDn
base DN where users are to be searched from |
| private String | _userIdAttribute
attribute that the principal is located |
| private String | _userObjectClass
object class of a user |
| private String | _userPasswordAttribute
name of the attribute that a users password is stored under Note not always accessible, see force binding login |
| private String | _userRdnAttribute
attribute that the principal is located |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | abort()
Overrides org. Implements javax. |
| protected boolean | bindingLogin(String username, Object password)
binding authentication check This methode of authentication works only if the user branch of the DIT (ldap tree) has an ACI (acces control instruction) that allow the access to any user or at least for the user that logs in. |
| public boolean | commit()
Overrides org. Implements javax. |
| public static String | |
| public static String | |
| protected boolean | |
| protected String | |
| private SearchResult | |
| public Hashtable | |
| private String | |
| private String | getUserCredentials(String username)
attempts to get the users credentials from the users context Note this is not an user authenticated operation |
| public UserInfo | getUserInfo(String username)
Implements abstract org. for this LoginModule, the credential can be null which will result in a binding ldap authentication scenario roles are also an optional concept if required |
| private List | getUserRoles(DirContext dirContext, String username)
attempts to get the users roles from the root context Note this is not an user authenticated operation |
| private List | |
| public void | initialize(Subject subject, CallbackHandler callbackHandler, Map<K, V> sharedState, Map<K, V> options)
Overrides org. Implements javax. |
| public boolean | login()
Overrides org. Implements javax. if credentials are not available from the users context or if we are forcing the binding check then we try a binding authentication check, otherwise if we have the users encoded password then we can try authentication via that mechanic |
| _authenticationMethod | back to summary |
|---|---|
| private String _authenticationMethod Context.SECURITY_AUTHENTICATION | |
| _bindDn | back to summary |
|---|---|
| private String _bindDn root DN used to connect to | |
| _bindPassword | back to summary |
|---|---|
| private String _bindPassword password used to connect to the root ldap context | |
| _contextFactory | back to summary |
|---|---|
| private String _contextFactory Context.INITIAL_CONTEXT_FACTORY | |
| _debug | back to summary |
|---|---|
| private boolean _debug | |
| _forceBindingLogin | back to summary |
|---|---|
| private boolean _forceBindingLogin if the getUserInfo can pull a password off of the user then password comparison is an option for authn, to force binding login checks, set this to true | |
| _hostname | back to summary |
|---|---|
| private String _hostname hostname of the ldap server | |
| _port | back to summary |
|---|---|
| private int _port port of the ldap server | |
| _roleBaseDn | back to summary |
|---|---|
| private String _roleBaseDn base DN where role membership is to be searched from | |
| _roleMemberAttribute | back to summary |
|---|---|
| private String _roleMemberAttribute name of the attribute that a username would be under a role class | |
| _roleNameAttribute | back to summary |
|---|---|
| private String _roleNameAttribute the name of the attribute that a role would be stored under | |
| _roleObjectClass | back to summary |
|---|---|
| private String _roleObjectClass object class of roles | |
| _rootContext | back to summary |
|---|---|
| private DirContext _rootContext | |
| _userBaseDn | back to summary |
|---|---|
| private String _userBaseDn base DN where users are to be searched from | |
| _userIdAttribute | back to summary |
|---|---|
| private String _userIdAttribute attribute that the principal is located | |
| _userObjectClass | back to summary |
|---|---|
| private String _userObjectClass object class of a user | |
| _userPasswordAttribute | back to summary |
|---|---|
| private String _userPasswordAttribute name of the attribute that a users password is stored under Note not always accessible, see force binding login | |
| _userRdnAttribute | back to summary |
|---|---|
| private String _userRdnAttribute attribute that the principal is located | |
| LdapLoginModule | back to summary |
|---|---|
| public LdapLoginModule() | |
| abort | back to summary |
|---|---|
| public boolean abort() throws LoginException Overrides org. Implements javax. Doc from javax. Method to abort the authentication process (phase 2). This method is called if the LoginContext's overall authentication failed. (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did not succeed). If this LoginModule's own authentication attempt
succeeded (checked by retrieving the private state saved by the
| |
| bindingLogin | back to summary |
|---|---|
| protected boolean bindingLogin(String username, Object password) throws LoginException, NamingException binding authentication check This methode of authentication works only if the user branch of the DIT (ldap tree) has an ACI (acces control instruction) that allow the access to any user or at least for the user that logs in. | |
| commit | back to summary |
|---|---|
| public boolean commit() throws LoginException Overrides org. Implements javax. Doc from javax. Method to commit the authentication process (phase 2). This method is called if the LoginContext's overall authentication succeeded (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules succeeded). If this LoginModule's own authentication attempt
succeeded (checked by retrieving the private state saved by the
| |
| convertCredentialJettyToLdap | back to summary |
|---|---|
| public static String convertCredentialJettyToLdap(String encryptedPassword) | |
| convertCredentialLdapToJetty | back to summary |
|---|---|
| public static String convertCredentialLdapToJetty(String encryptedPassword) | |
| credentialLogin | back to summary |
|---|---|
| protected boolean credentialLogin(Object webCredential) throws LoginException password supplied authentication check | |
| doRFC2254Encoding | back to summary |
|---|---|
| protected String doRFC2254Encoding(String inputString) | |
| findUser | back to summary |
|---|---|
| private SearchResult findUser(String username) throws NamingException, LoginException | |
| getEnvironment | back to summary |
|---|---|
| public Hashtable get the context for connection | |
| getOption | back to summary |
|---|---|
| private String getOption(Map<K, V> options, String key, String defaultValue) | |
| getUserCredentials | back to summary |
|---|---|
| private String getUserCredentials(String username) throws LoginException attempts to get the users credentials from the users context Note this is not an user authenticated operation | |
| getUserInfo | back to summary |
|---|---|
| public UserInfo getUserInfo(String username) throws Exception Implements abstract org. get the available information about the user for this LoginModule, the credential can be null which will result in a binding ldap authentication scenario roles are also an optional concept if required | |
| getUserRoles | back to summary |
|---|---|
| private List attempts to get the users roles from the root context Note this is not an user authenticated operation | |
| getUserRolesByDn | back to summary |
|---|---|
| private List | |
| initialize | back to summary |
|---|---|
| public void initialize(Subject subject, CallbackHandler callbackHandler, Map<K, V> sharedState, Map<K, V> options) Overrides org. Implements javax. Init LoginModule. Called once by JAAS after new instance is created. | |
| login | back to summary |
|---|---|
| public boolean login() throws LoginException Overrides org. Implements javax. since ldap uses a context bind for valid authentication checking, we override login() if credentials are not available from the users context or if we are forcing the binding check then we try a binding authentication check, otherwise if we have the users encoded password then we can try authentication via that mechanic
| |