Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, v1.1 - Sun Microsystems.pdf
Скачиваний:
11
Добавлен:
24.05.2014
Размер:
1.62 Mб
Скачать

Sun Microsystem Inc

Bean Provider’s responsibilities

Enterprise JavaBeans v1.1, Final Release

Security management

The following code sample illustrates the use of the isCallerInRole(String roleName) method.

public class PayrollBean ... { EntityContext ejbContext;

public void updateEmployeeInfo(EmplInfo info) {

oldInfo = ... read from database;

//The salary field can be changed only by caller’s

//who have the security role "payroll"

if (info.salary != oldInfo.salary && !ejbContext.isCallerInRole("payroll")) {

throw new SecurityException(...);

}

...

}

...

}

15.2.5.3 Declaration of security roles referenced from the bean’s code

The Bean Provider is responsible for declaring in the security-role-ref elements of the deployment descriptor all the security role names used in the enterprise bean code. Declaring the security roles references in the code allows the Application Assembler or Deployer to link the names of the security roles used in the code to the security roles defined for an assembled application through the secu- rity-role elements.

The Bean Provider must declare each security role referenced in the code using the secu- rity-role-ref element as follows:

Declare the name of the security role using the role-name element. The name must be the security role name that is used as a parameter to the isCallerInRole(String roleName) method.

Optional: Provide a description of the security role in the description element.

A security role reference, including the name defined by the role-name element, is scoped to the session or entity bean element whose declaration contains the security-role-ref element.

225

11/24/99