Instance of the ESAPI's authenticator Class can be created as:
Authenticator instance = ESAPI.authenticator();
If you plan on using the default Access Controller, you may need one or more of the following:
You do not need users.txt. ESAPI will create this file when your application requests to create its first user.
Use main() from FileBasedAuthenticator to generate users.txt for the first time. To do this:
java -Dorg.owasp.esapi.resources="/path/resources" -classpath esapi.jar org.owasp.esapi.Authenticator username password role
ESAPI.authenticator.createUser(username, password, password)
ESAPI.authenticator().getUser(username).enable();
ESAPI.authenticator().getUser(username).unlock();
To authenticate a user, call:
User user = ESAPI.authenticator().login(HTTPServletRequest, HTTPServletResponse);
User user = ESAPI.authenticator().logout;
ESAPI's User Interface provides support to store lot of information that an application must store for each user in order to enforce security properly.
A user account can be in one of several states. When first created, a User should be disabled, not expired, and unlocked. To start using the account, an administrator should enable the account. The account can be locked for a number of reasons, most commonly because they have failed login for too many times. Finally, the account can expire after the expiration date has been reached. The User must be enabled, not expired, and unlocked in order to pass authentication.