The jvm should be started with the following parameter:
-Djava.security.auth.login.config=etc/ldap-loginModule.confand an example of the ldap-loginModule.conf would be:
ldaploginmodule {
org.eclipse.jetty.server.server.plus.jaas.spi.LdapLoginModule required
debug="true"
useLdaps="false"
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 | Class and Description |
|---|---|
| public class | |
| public class |
| 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 boolean | _useLdaps
When true changes the protocol to ldaps |
| 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 |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | abort()
Overrides org. Implements javax. Method to abort the authentication process (phase 2). |
| private static String | |
| public boolean | Returns: true alwaysthe user name username, Object the password password)binding authentication check This method of authentication works only if the user branch of the DIT (ldap tree) has an ACI (access 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. Method to commit the authentication process (phase 2). |
| public static String | |
| protected boolean | Returns: true if authenticatedthe web credential webCredential)password supplied authentication check |
| protected String | |
| private SearchResult | |
| private SearchResult | |
| public Hashtable | |
| private String | |
| public AbstractLoginModule. | Returns: the userinfo for the usernamethe user name username)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 |
| private Attributes | Returns: theAttributes from the userattempts to get the users LDAP attributes from the users context Note this is not an user authenticated operation |
| private String | |
| private List | getUserRoles(DirContext dirContext, String username, Attributes attributes)
attempts to get the users roles from the root context Note this is not an user authenticated operation |
| private List | |
| private static String | |
| public void | initialize(Subject
the subect subject, CallbackHandler the callback handler callbackHandler, Map<String, ?> the shared state map sharedState, Map<String, ?> the option map options)Overrides org. Implements javax. Init LoginModule. |
| public boolean | Returns: true if authenticated, false otherwiseOverrides 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 |
| _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 | |
| _useLdaps | back to summary |
|---|---|
| private boolean _useLdaps When true changes the protocol to ldaps | |
| _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 | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| 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
| |
| base64ToHex | back to summary |
|---|---|
| private static String base64ToHex(String src) | |
| bindingLogin | back to summary |
|---|---|
| public boolean bindingLogin(String username, Object password) throws LoginException binding authentication check This method of authentication works only if the user branch of the DIT (ldap tree) has an ACI (access 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
| |
| 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 LoginException | |
| findUser | back to summary |
|---|---|
| private SearchResult findUser(DirContext dirContext, String filter, Object[] filterArguments) throws LoginException | |
| getEnvironment | back to summary |
|---|---|
| public Hashtable get the context for connection | |
| getOption | back to summary |
|---|---|
| private String getOption(Map<String, ?> options, String key, String defaultValue) | |
| getUser | back to summary |
|---|---|
| public AbstractLoginModule. 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
| |
| getUserAttributes | back to summary |
|---|---|
| private Attributes getUserAttributes(String username) throws LoginException attempts to get the users LDAP attributes from the users context Note this is not an user authenticated operation
| |
| getUserCredentials | back to summary |
|---|---|
| private String getUserCredentials(Attributes attributes) throws LoginException | |
| 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 | |
| hexToBase64 | back to summary |
|---|---|
| private static String hexToBase64(String src) | |
| initialize | back to summary |
|---|---|
| public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> 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
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv DirContext | |
| pack-priv String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public List | doFetchRoles()
Implements abstract org.
|
| _context | back to summary |
|---|---|
| pack-priv DirContext _context | |
| _userDn | back to summary |
|---|---|
| pack-priv String _userDn | |
| LDAPBindingUser | back to summary |
|---|---|
| public LDAPBindingUser(UserPrincipal user, DirContext context, String userDn) | |
| doFetchRoles | back to summary |
|---|---|
| public List Implements abstract org.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Attributes |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public List | doFetchRoles()
Implements abstract org.
|
| attributes | back to summary |
|---|---|
| pack-priv Attributes attributes | |
| LDAPUser | back to summary |
|---|---|
| public LDAPUser(UserPrincipal user, Attributes attributes) | |
| doFetchRoles | back to summary |
|---|---|
| public List Implements abstract org.
| |