Explain the following Authentication Files:SimpleAuth.java SimpleJAAS.config SimpleCallbackHandler.java SimpleLoginModule.java SimplePrincipal.java
SimpleAuth.java: This file has main() method. The main() method creates a LoginContext object. A LoginModule configuration id and an instance of the CallbackHandler interface are passed while creating a LoginContext object. By looking for the configuration Id, the LoginContext reads a configuration file.
Once the match is found, the specified LoginModules are instantiated. A Subject, a CallbackHandler, shared LoginModule state, and LoginModule-specific options are used while initializing each LoginModule. And finally, the login process is returned by login() method on the LoginContext object.
SimpleJAAS.config: The association of configuration Ids with LoginModules and optional properties is performed by this file.
SimpleCallbackHandler.java: The callback events which are passed by the security service components, are handled while implementing the CallbackHandler interface.
SimpleLoginModule.java: LoginModule interface implementation and other interfaces between the user and the CallbackHandler to authenticate the user is performed by this file. To maintain the set of possible usernames and passwords , it uses two arrays. The comparison of passwords is done by passing a PasswordCallback instance to the SimpleCallbackHandler by utilizing the readPassword() method which is available in the SimpleCallbackHandler class.
SimplePrincipal.java: This file implements the Principal interface.
Explain the Authentication FilesAuthentication Files
1. SimpleAuth.java Contains the main() method. Creates a LoginContext object by passing in a LoginModule configuration id ("JAAS_Module") and an instance of the CallbackHandler interface. The LoginContext reads a configuration file, looking for the configuration ID. Instantiates the specified LoginModules, after finding a match. Each LoginModule is initialized with a Subject, a CallbackHandler, shared LoginModule state, and LoginModule-specific options. Finally, the login process is kicked off by calling the login() method on the LoginContext object.
2. SimpleJAAS.config This file associates configuration IDs with LoginModules and optional properties.
3. SimpleCallbackHandler.java This file implements the CallbackHandler interface and handles the callback events passed by the security service components.
4. SimpleLoginModule.java This file implements the LoginModule interface and interfaces between the user and the CallbackHandler to authenticate the user. It uses two arrays to maintain the set of possible usernames and passwords. The passwords are then compared by passing a PasswordCallback instance to the SimpleCallbackHandler and using the readPassword() method defined in the SimpleCallbackHandler class.
5. SimplePrincipal.java This file provides a bare-bones implementation of the Principal interface.
|