Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Java : Education - Tutorials
Java security, Part 2: Authentication and authorization
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
3. Authentication in JAAS
  


Login context page 8 of 13


A LoginContext is a Java class that is used to set up the login process, actually login, and get the Subject if the login is successful. It has four main methods, as follows:

  • LoginContext("JAASExample", newUsernamePasswoerdCallbackHandler()) is the constructor. It takes the string used in the login.config file as its first parameter, and a callback handler, which does the real work, as its second parameter. (We'll discuss callback handlers next.)

  • login() actually attempts the login, subject to the rules specified in the login.config file.

  • getSubject() returns the authenticated Subject if the login was an overall success.

  • logout() logs the Subject off of the LoginContext.

Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact