From seam-commits at lists.jboss.org Wed Jun 25 20:48:05 2008 Content-Type: multipart/mixed; boundary="===============2113816797090009339==" MIME-Version: 1.0 From: seam-commits at lists.jboss.org To: seam-commits at lists.jboss.org Subject: [seam-commits] Seam SVN: r8419 - trunk/doc/Seam_Reference_Guide/en-US. Date: Wed, 25 Jun 2008 20:48:02 -0400 Message-ID: --===============2113816797090009339== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: shane.bryzak(a)jboss.com Date: 2008-06-25 20:48:02 -0400 (Wed, 25 Jun 2008) New Revision: 8419 Modified: trunk/doc/Seam_Reference_Guide/en-US/Security.xml Log: more proofreading, documented typesafe security annotations Modified: trunk/doc/Seam_Reference_Guide/en-US/Security.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-06-25 19:47:15 U= TC (rev 8418) +++ trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-06-26 00:48:02 U= TC (rev 8419) @@ -2339,7 +2339,7 @@ Authorization = - There are a number of authorization features provided by the Seam Se= curity API for securing access to + There are a number of authorization mechanisms provided by the Seam = Security API for securing access to components, component methods, and pages. This section describes ea= ch of these. An important thing to note is that if you wish to use any of the advanced features (such a= s rule-based permissions) then your components.xml may need to be configured to = support this - see the Configuration section @@ -2400,8 +2400,8 @@ = = - Within this documentation, permissions are represented in the fo= rm name:action (generally - omitting the recipient, although in reality one is always requir= ed). + Within this documentation, permissions are generally represented= in the form target:action = + (omitting the recipient, although in reality one is always requi= red). = = @@ -2453,7 +2453,7 @@ In this example, the implied permission required to call the delete() method is account:delete. The equivalent of this would= be to write - @Restrict("#{s:hasPermission('account','delete',null)}"= ). Now let's look at + @Restrict("#{s:hasPermission('account','delete')}"). Now let's look at another example: = @@ -2492,7 +2492,7 @@ = = @@ -2546,7 +2546,7 @@ = @@ -2607,9 +2607,9 @@ Action + rendered=3D"#{s:hasPermission(cl,'modify')"/> + rendered=3D"#{s:hasPermission(cl,'delete')"/> ]]> = @@ -2755,9 +2755,9 @@ no-loop activation-group "permissions" when - check: PermissionCheck(name =3D=3D "memberBlog", action =3D=3D "insert",= granted =3D=3D false) - Principal(principalName : name) - MemberBlog(member : member -> (member.getUsername().equals(principalName= ))) + principal: Principal() + memberBlog: MemberBlog(member : member -> (member.getUsername().equals(p= rincipal.getName()))) + check: PermissionCheck(target =3D=3D memberBlog, action =3D=3D "insert",= granted =3D=3D false) then check.grant(); end;]]> @@ -2765,11 +2765,11 @@ This rule will grant the permission memberBlog:insert if the currently authenticated user (indicated by the Principal fact) has the= same name as the member for which the - blog entry is being created. The "principalName : name<= /literal>" structure that can be seen in the - Principal fact (and other places) is a variabl= e binding - it binds the name - property of the Principal to a variable called= principalName. Variable bindings - allow the value to be referred to in other places, such as the fo= llowing line which compares the member's username - to the Principal name. For more details, plea= se refer to the JBoss Rules documentation. + blog entry is being created. The "principal: Principal(= )" structure that can be seen in the + example code is a variable binding - it binds the instance of the= Principal object from the + working memory (placed there during authentication) and assigns i= t to a variable called principal. + Variable bindings allow the value to be referred to in other plac= es, such as the following line which compares the = + member's username to the Principal name. For = more details, please refer to the JBoss Rules documentation. = @@ -2825,8 +2825,74 @@ that @Restrict does. = + + Out of the box, Seam comes with annotations for standard CRUD-base= d permissions, however it is a simple matter to = + add your own. The following annotations are provided in the org.jboss.seam.annotations.security package: + = - = + + + @Insert + + + @Read + + + @Update + + + @Delete + + + = + + To use these annotations, simply place them on the method or param= eter for which you wish to perform a security check. + If placed on a method, then they should specify a target class for= which the permission will be checked. Take the + following example: + + = + + = + + In this example, a permission check will be performed for the user= to ensure that they have the rights to create + new Customer objects. The target of the permis= sion check will be Customer.class + (the actual java.lang.Class instance itself), a= nd the action is the lower case representation of the = + annotation name, which in this example is insert. + + = + + It is also possible to annotate the parameters of a component meth= od in the same way. If this is done, then it is + not required to specify a permission target (as the parameter valu= e itself will be the target of the permission check): + + = + + = + + To create your own security annotation, you simply need to annotat= e it with @PermissionCheck, for example: + + = + + + + If you wish to override the default permisison action name (which = is the lower case version of the annotation name) with + another value, you can specify it within the @PermissionC= heck annotation: + + = + + = + = = --===============2113816797090009339==--