• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

J2EE applications need standardized security: verifying who the user is (authentication) and what they’re allowed to do (authorization). Without a standard API, each application implements security differently, leading to inconsistencies and security holes.

Core Idea

JAAS (Java Authentication and Authorization Service) is the standard API for performing security operations in J2EE. It enables plugging in authentication mechanisms into J2EE application servers and provides both authentication and authorization services.

How It Works

  1. Authentication: Verifies user identity (login, password, certificates, etc.)
  2. Authorization: Determines what authenticated user can do (roles, permissions)
  3. Pluggable: Different authentication mechanisms can be plugged in (LDAP, database, Kerberos, etc.)
  4. J2EE integration: Works with EJB security (Chapter 13 covers EJB security details)
  5. Standard API: Part of J2EE platform

JAAS uses a callback mechanism for authentication and Policy-based authorization.

Visual Explanation

G User User JAAS JAAS User->JAAS login EJB Container EJB Container JAAS->EJB Container authorized request LDAP LDAP JAAS->LDAP authenticate Database Database JAAS->Database authenticate Kerberos Kerberos JAAS->Kerberos authenticate

Key Properties

  • Pluggable authentication: Swap auth mechanisms without code changes
  • Authentication + Authorization: Both identity and permissions
  • J2EE standard: Part of J2EE platform
  • Callback-based: Flexible authentication dialog
  • Policy-based: Authorization via security policies

Connections

Edge Cases & Gotchas

  • Configuration complexity: JAAS config files can be tricky
  • Callback handling: Custom callbacks need careful implementation
  • Policy management: Authorization policies must be properly configured
  • Chapter 13: See EJB-specific security details there