![](https://csdnimg.cn/release/download_crawler_static/2995224/bg10.jpg)
24 Getting Started Securing Enterprise Applications ...................................................................... 465
Responsibility for Administering Security ..................................................................................... 465
Securing Enterprise Beans ................................................................................................................ 466
Securing an Enterprise Bean Using Declarative Security and Annotations ....................... 469
Securing an Enterprise Bean Programmatically .................................................................... 477
Propagating a Security Identity (Run-As) ............................................................................... 480
Deploying Secure Enterprise Beans ......................................................................................... 482
Securing Application Clients ........................................................................................................... 483
Using Login Modules ................................................................................................................ 483
Using Programmatic Login ...................................................................................................... 484
Securing Enterprise Information Systems (EIS) Applications ..................................................... 485
Container-Managed Sign-On .................................................................................................. 485
Component-Managed Sign-On ............................................................................................... 485
Conguring Resource Adapter Security ................................................................................. 486
Mapping an Application Principal to EIS Principals ............................................................. 488
25 Getting Started Securing Web Applications ................................................................................. 489
Overview of Web Application Security .......................................................................................... 490
Using Deployment Descriptors to Secure Web Applications ...................................................... 492
Introduction to Web Application Deployment Descriptors ................................................ 492
Specifying Security Constraints ............................................................................................... 495
Specifying an Authentication Mechanism .............................................................................. 499
Working with Security Roles .................................................................................................... 506
Using Programmatic Security with Web Applications ................................................................. 510
Authenticating Users Programmatically ................................................................................. 511
Checking Caller Identity Programmatically ........................................................................... 513
Example Code for Programmatic Security ............................................................................. 513
Declaring and Linking Role References .................................................................................. 515
Using Message Security with Web Applications ............................................................................ 517
Examples: Securing Web Applications ........................................................................................... 517
Setting Up Your System for Running the Security Examples ............................................... 518
Example: Basic Authentication with a Servlet ........................................................................ 518
Example: Basic Authentication with JAX-WS ........................................................................ 524
Example: Form-Based Authentication with a Servlet ............................................................ 528
Contents
The Java EE 6 Tutorial,Volume I • December 200916