Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3)
B14428-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Retrieving Credentials from an EJB Using the JAAS API

OC4J supports the use of standard JAAS API to retrieve the Subject, Principal, and credentials from within business methods and lifecycle methods of session beans (stateless and stateful) and entity beans.

Example 22-9 shows how you can use the JAAS API to retrieve credentials in a business method of an EJB deployed to OC4J.

Example 22-9 Using JAAS API to Retrieve Credentials

public class Calculator
{
    // Buisness method
    public void setNewRate(int rate)
    {
    ...
        AccessControlContext actx = AccessController.getContext();
        Subject subject = Subject.getSubject(actx);
        Set principals = subject.getPrincipals();
    ...
    }
}