📄 ch09s02.html
字号:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>EJB Security Overview</title><link rel="stylesheet" href="styles.css" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/styles.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets Vimages/callouts/"><link rel="home" href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html" title="JBoss 3.0 Documentation"><link rel="up" href="ch09.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch09.html" title="Chapter 9. JBossSX Security Extension Framework"><link rel="previous" href="ch09.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch09.html" title="Chapter 9. JBossSX Security Extension Framework"><link rel="next" href="ch09s08.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch09s08.html" title="The JBoss Security Model"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="jboss.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/jboss.gif" border="0"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch09.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch09.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch09.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch09.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch09s08.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch09s08.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table><div class="section"><a name="sx.EJBSecurityOverview"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="sx.EJBSecurityOverview"></a>EJB Security Overview</h2></div></div><div class="section"><a name="d0e6018"></a><div class="titlepage"><div><h3 class="title"><a name="d0e6018"></a>The EJB 1.1 Declarative Security Model</h3></div></div><p>The security model advocated by the EJB 1.1 spec is a declarative
model that avoids the introduction of security code into the EJB business
methods. From
<i>Enterprise JavaBeans Specification, v1.1,
Section 15.1</i>:“The EJB architecture encourages the Bean
Provider to implement the enterprise bean class without hard-coding the
security policies and mechanisms into the business methods. In most cases, the
enterprise bean's business method should not contain any security-related
logic. This allows the Deployer to configure the security policies for the
application in a way that is most appropriate for the operational environment
of the enterprise.”
</p><div class="section"><a name="d0e6029"></a><div class="titlepage"><div><h4 class="title"><a name="d0e6029"></a>Declarative Security Setup</h4></div></div><p>The EJB1.1 declarative security model is specified using the ejb-jar security-role and method-permission elements. <a href="ch09s02.html#sx.ejb-jar.SecurityElements" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch09s02.html#sx.ejb-jar.SecurityElements" title="Figure 9.1. EJB 1.1 ejb-jar.xml Security Elements">Figure 9.1</a> illustrates the security related elements of the ejb-jar.xml deployment descriptor.</p><div class="figure"><p><a name="sx.ejb-jar.SecurityElements"></a><b>Figure 9.1. EJB 1.1 ejb-jar.xml Security Elements</b></p><div class="mediaobject"><img src="ejb_11_security_dtd.jpg" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ejb_11_security_dtd.jpg"></div></div><p>The application assembler defines the required method permissions for each security role. A method permission is a permission to invoke a specified group of methods of the enterprise beans' home and remote interfaces. A security role is a semantic grouping of method permissions. A user must have at least one security role associated with a method in or to have permission invoke the method. Because the application assembler does not, in general, know the security environment of the operational environment, the security roles are meant to be logical roles, each representing a type of user that should have the same access rights to the grouping of methods.
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="d0e6044"></a>What is a Role</h3><p>From <i>Enterprise JavaBeans Specification, v1.1, Section 15.3</i>: “It is important to keep in mind that the security roles are used to define the logical security view of an application. They should not be confused with the user groups, users, principals, and other concepts that exist in the target enterprise's operational environment.”
</p></div>
</p><p>A security role is defined using the following ejb-jar
elements:</p><div class="variablelist"><dl><dt><a name="d0e6059"></a><span class="term">security-role</span></dt><dd><p><a name="d0e6062"></a>The security-role element contains the definition of a
security role.</p></dd><dt><a name="d0e6065"></a><span class="term">role-name</span></dt><dd><p><a name="d0e6068"></a>The role-name element contains the name of a security role,
e.g., Admin, owner, Architect.</p></dd><dt><a name="d0e6071"></a><span class="term">description</span></dt><dd><p><a name="d0e6074"></a>An optional description of the security role</p></dd></dl></div><p>The following EJB 1.1 spec example illustrates a security role
definition in a deployment descriptor.
<div class="example"><p><a name="sx.security-role.example"></a><b>Example 9.1. Sample security-role usage</b></p><pre class="programlisting">
...
<assembly-descriptor>
<security-role>
<description>
This role includes the employees of the
enterprise who are allowed to access the
employee self-service application. This role
is allowed only to access his/her own
information.
</description>
<role-name>employee</role-name>
</security-role>
<security-role>
<description>
This role includes the employees of the human
resources department. The role is allowed to
view and update all employee records.
</description>
<role-name>hr-department</role-name>
</security-role>
<security-role>
<description>
This role includes the employees of the payroll
department. The role is allowed to view and
update the payroll entry for any employee.
</description>
<role-name>payroll-department</role-name>
</security-role>
...
</assembly-descriptor>
</pre></div>
</p><p>From <i>Enterprise JavaBeans Specification, v1.1, Section 15.3.2</i>, If the application assembler has defined security roles for the enterprise beans in the ejb-jar file, they can also specify the methods of the remote and home interface that each security role is allowed to invoke. The assembler defines the method permissions relation in the deployment descriptor using the method-permission elements as follows. </p><div class="itemizedlist"><ul><li><p><a name="d0e6091"></a>Each method-permission element includes a list of one or
more security roles and a list of one or more methods. All the listed security
roles are allowed to invoke all the listed methods.</p></li><li><p><a name="d0e6094"></a>Each security role in the list is identified by the
role-name element, and each method (or a set of methods, as described below) is
identified by the method element. An optional description can be associated
with a method-permission element using the description element.</p></li><li><p><a name="d0e6097"></a>The method permissions relation is defined as the union of
all the method permissions defined in the individual method-permission
elements.</p></li><li><p><a name="d0e6100"></a>A security role or a method may appear in multiple
method-permission elements. It is possible that some methods are not assigned
to any security roles. This means that none of the security roles defined by
the Application Assembler needs access to the methods.</p></li></ul></div><p>The method element uses the ejb-name, method-name, and
method-params elements to denote one or more methods of an enterprise bean's
home and remote interfaces. There are three legal styles for composing the
method element: </p><div class="variablelist"><dl><dt><a name="d0e6106"></a><span class="term">Style 1:</span></dt><dd><p><a name="d0e6109"></a>
<div class="literallayout"><br>
<method><br>
<br>
<ejb-name>EJBNAME</ejb-name><br>
<method-name>*</method-name><br>
</method><br>
</div>This style is used for referring to all of the remote and
home interface methods of a specified enterprise bean.</p></dd><dt><a name="d0e6115"></a><span class="term">Style 2:</span></dt><dd><p><a name="d0e6118"></a>
<div class="literallayout"><br>
<method><br>
<ejb-name>EJBNAME</ejb-name><br>
<method-name>METHOD</method-name><br>
</method><br>
</div>This style is used for referring to a specified method of
the remote or home interface of the specified enterprise bean. If there are
multiple methods with the same overloaded name, this style refers to all of the
overloaded methods.</p></dd><dt><a name="d0e6124"></a><span class="term">Style 3:</span></dt><dd><p><a name="d0e6127"></a>
<div class="literallayout"><br>
<method><br>
<ejb-name>EJBNAME</ejb-name><br>
<method-name>METHOD</method-name><br>
<method-params><br>
<method-param>PARAMETER_1</method-param><br>
...<br>
<method-param>PARAMETER_N</method-param><br>
</method-params><br>
</method><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -