What is JAAS?
The Java Authentication and Authorization Service (JAAS) is a integrated package comes with Java 2 SDK. Basically JAAS is designed to achieve two things,Authentication - determine who is executing the code
Authorization - ensure user/code has access control right to perform an action
JAAS for Authentication
JAAS modules related to authentication are connected in a pluggable manner. So it promotes the reuse of underline authentication technology with different applications. Following are the key classes we use in authentication process.
LoginContext
This is the start point of the authentication process. This class contains 3 methods as,- login() - authenticate user
- logout() - logout user
- getSubject() - get authenticated user
Configuration
This specifies the underline authentication technology which includes following,- Login Modules
- Order of Login Modules
- Flag values which decide the behavior(Required, Requisite, Sufficient, Optional)
- Options which are consumed by Login Modules
LoginModule
This class contains the underline authentication mechanism. The interface LoginModule consists of 5 methods,
- initialize() - LoginContext call this method to initialize the login module
- login() - Authentication happens inside this method
- commit() - After successful authentication user principal creation happens here
- abort() - In case of failure, it handled here
- logout() - Remove principal in case of logout
Comments
Post a Comment