First, declare the CallbackHandler to use. It can be a simple command line prompt, a dialog, or even a login/password to use.
Example of CallbackHandler that can be used within JOnAS:
CallbackHandler handler1 = new LoginCallbackHandler(); CallbackHandler handler2 = new DialogCallbackHandler(); CallbackHandler handler3 = new NoInputCallbackHandler("jonas_user", "jonas_password"); |
Next, call the LoginContext method with the previously defined CallbackHandler and the entry to use from the JONAS_ROOT/conf/jaas.config file.
This example uses the dialog callbackhandler.
LoginContext loginContext = new LoginContext("jaasclient", handler2); |
Finally, call the login method on the LoginContext instance.
loginContext.login(); |
If there are no exceptions, the authentication is successful.
If the supplied password is incorrect, authentication can fail.