Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Retrieving Credentials From an Enterprise Bean Using the JAAS API

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

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

Example 22-10 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();
    ...
    }
}