Author: shane.bryzak(a)jboss.com
Date: 2008-05-05 09:55:04 -0400 (Mon, 05 May 2008)
New Revision: 8116
Added:
trunk/examples/seamspace/view/permissiondetail.xhtml
trunk/examples/seamspace/view/permissionmanager.page.xml
trunk/examples/seamspace/view/roledetail.page.xml
trunk/examples/seamspace/view/rolemanager.page.xml
trunk/examples/seamspace/view/userdetail.page.xml
trunk/examples/seamspace/view/usermanager.page.xml
Modified:
trunk/examples/seamspace/resources/META-INF/security-rules.drl
trunk/examples/seamspace/resources/WEB-INF/pages.xml
trunk/examples/seamspace/resources/import.sql
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java
trunk/examples/seamspace/view/permissionmanager.xhtml
trunk/examples/seamspace/view/pictures.xhtml
Log:
extract user/permission management .page.xml files from pages.xml for easier distribution
Modified: trunk/examples/seamspace/resources/META-INF/security-rules.drl
===================================================================
--- trunk/examples/seamspace/resources/META-INF/security-rules.drl 2008-05-05 13:53:54 UTC
(rev 8115)
+++ trunk/examples/seamspace/resources/META-INF/security-rules.drl 2008-05-05 13:55:04 UTC
(rev 8116)
@@ -28,6 +28,19 @@
check.grant();
end
+# This rule allows members to revoke permissions on their images to other users/roles
+
+rule RevokeImagePermissions
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
+ check: PermissionCheck(target == image, action == "seam.revoke-permission",
granted == false)
+then
+ check.grant();
+end
+
rule ViewProfileImage
no-loop
activation-group "permissions"
Modified: trunk/examples/seamspace/resources/WEB-INF/pages.xml
===================================================================
--- trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-05-05 13:53:54 UTC (rev
8115)
+++ trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-05-05 13:55:04 UTC (rev
8116)
@@ -63,46 +63,6 @@
</page>
- <page view-id="/usermanager.xhtml"
action="#{userSearch.loadUsers}">
- <restrict>#{s:hasPermission('seam.user',
'read')}</restrict>
-
- <navigation from-action="#{userAction.createUser}">
- <redirect view-id="/userdetail.xhtml"/>
- </navigation>
-
- <navigation
from-action="#{userAction.editUser(userSearch.selectedUser)}">
- <redirect view-id="/userdetail.xhtml"/>
- </navigation>
- </page>
-
- <page view-id="/rolemanager.xhtml"
action="#{roleSearch.loadRoles}">
- <restrict>#{s:hasPermission('seam.role',
'read')}</restrict>
-
- <navigation from-action="#{roleAction.createRole}">
- <redirect view-id="/roledetail.xhtml"/>
- </navigation>
-
- <navigation
from-action="#{roleAction.editRole(roleSearch.selectedRole)}">
- <redirect view-id="/roledetail.xhtml"/>
- </navigation>
- </page>
-
- <page view-id="/userdetail.xhtml">
- <navigation from-action="#{userAction.save}">
- <rule if-outcome="success">
- <redirect view-id="/usermanager.xhtml"/>
- </rule>
- </navigation>
- </page>
-
- <page view-id="/roledetail.xhtml">
- <navigation from-action="#{roleAction.save}">
- <rule if-outcome="success">
- <redirect view-id="/rolemanager.xhtml"/>
- </rule>
- </navigation>
- </page>
-
<page view-id="/profile.xhtml">
<param name="name"
value="#{selectedMember.memberName}"/>
Modified: trunk/examples/seamspace/resources/import.sql
===================================================================
--- trunk/examples/seamspace/resources/import.sql 2008-05-05 13:53:54 UTC (rev 8115)
+++ trunk/examples/seamspace/resources/import.sql 2008-05-05 13:55:04 UTC (rev 8116)
@@ -33,6 +33,8 @@
update Member set picture_id = 3 where memberid = 3;
update Member set picture_id = 4 where memberid = 4;
+insert into AccountPermission (permissionId, recipient, target, action, discriminator)
values (1, 'friends', 'MemberImage:5', 'view', 'role');
+
insert into MemberBlog (blogid, member_id, entrydate, title, text) values (1, 1,
'2007-01-05', 'My first blog entry!', '*Lorem ipsum* dolor sit amet,
consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.');
insert into MemberBlog (blogid, member_id, entrydate, title, text) values (2, 1,
'2007-01-07', 'I love latin', 'Sed ut perspiciatis unde omnis iste
natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque
ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt
explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed
quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro
quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia
non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat
voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit
laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum
qui dolorem eum fugiat quo voluptas nulla pariatur?');
Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java
===================================================================
---
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java 2008-05-05
13:53:54 UTC (rev 8115)
+++
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java 2008-05-05
13:55:04 UTC (rev 8116)
@@ -9,10 +9,7 @@
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
-import org.jboss.seam.annotations.Name;
-
@Entity
-@Name("memberImage")
public class MemberImage implements Serializable
{
private static final long serialVersionUID = -8088455267213832920L;
Added: trunk/examples/seamspace/view/permissiondetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/permissiondetail.xhtml (rev 0)
+++ trunk/examples/seamspace/view/permissiondetail.xhtml 2008-05-05 13:55:04 UTC (rev
8116)
@@ -0,0 +1,63 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:s="http://jboss.com/products/seam/taglib">
+
+ <ui:composition template="template.xhtml">
+
+ <ui:define name="head">
+ <link href="style/security.css" rel="stylesheet"
type="text/css"/>
+ </ui:define>
+
+ <ui:define name="content">
+
+ <div id="contentMain">
+
+ <h2>Permission Details</h2>
+
+ <h:messages globalOnly="true"/>
+
+ <h3>Granting permissions for: #{permissionSearch.target}</h3>
+
+ <h:form>
+
+ <div class="formRow">
+ <h:outputLabel for="recipient" value="Recipient"
styleClass="formLabel"/>
+ <h:inputText id="recipient"
value="#{permissionAction.recipient}"/>
+ <div class="validationError"><h:message
for="recipient"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="action" value="Action"
styleClass="formLabel"/>
+ <h:inputText id="action"
value="#{permissionAction.action}"/>
+ <div class="validationError"><h:message
for="action"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="actions" value="Allowable actions"
styleClass="formLabel"/>
+ <div class="selectMany">
+ <h:selectManyCheckbox id="actions"
value="#{permissionAction.actions}" layout="pageDirection"
styleClass="roles">
+ <s:selectItems
value="#{permissionManager.listAvailableActions(permissionAction.target)}"
var="action" label="#{action}"/>
+ </h:selectManyCheckbox>
+ </div>
+ <div class="validationError"><h:message
for="actions"/></div>
+ </div>
+
+ <div class="formButtons">
+ <h:commandButton value="Save"
action="#{permissionAction.save}" styleClass="formButton"/>
+ <s:button view="/permissionmanager.xhtml"
value="Cancel" propagation="end"
styleClass="formButton"/>
+ </div>
+
+ <br class="clear"/>
+
+ </h:form>
+
+ </div>
+
+ </ui:define>
+
+ </ui:composition>
+</html>
Added: trunk/examples/seamspace/view/permissionmanager.page.xml
===================================================================
--- trunk/examples/seamspace/view/permissionmanager.page.xml (rev
0)
+++ trunk/examples/seamspace/view/permissionmanager.page.xml 2008-05-05 13:55:04 UTC (rev
8116)
@@ -0,0 +1,7 @@
+<!DOCTYPE page PUBLIC
+ "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
+ "http://jboss.com/products/seam/pages-1.2.dtd">
+
+<page action="#{permissionSearch.refresh}">
+
+</page>
\ No newline at end of file
Modified: trunk/examples/seamspace/view/permissionmanager.xhtml
===================================================================
--- trunk/examples/seamspace/view/permissionmanager.xhtml 2008-05-05 13:53:54 UTC (rev
8115)
+++ trunk/examples/seamspace/view/permissionmanager.xhtml 2008-05-05 13:55:04 UTC (rev
8116)
@@ -16,7 +16,7 @@
<script type="text/javascript">
function confirmDelete()
{
- return confirm("Are you sure you wish to delete this permission? This
action cannot be undone.");
+ return confirm("Are you sure you wish to revoke this permission? This
action cannot be undone.");
}
</script>
@@ -55,8 +55,7 @@
<f:facet name="header">
Action
</f:facet>
-
- <s:link value="Delete"
action="#{permissionManager.revokePermission(permissionSearch.selectedPermission)}"
+ <s:link value="Revoke"
action="#{permissionManager.revokePermission(permissionSearch.selectedPermission)}"
rendered="#{s:hasPermission(permissionSearch.target,
'seam.revoke-permission')}"
onclick="return confirmDelete()"/>
</h:column>
Modified: trunk/examples/seamspace/view/pictures.xhtml
===================================================================
--- trunk/examples/seamspace/view/pictures.xhtml 2008-05-05 13:53:54 UTC (rev 8115)
+++ trunk/examples/seamspace/view/pictures.xhtml 2008-05-05 13:55:04 UTC (rev 8116)
@@ -45,7 +45,7 @@
<a href="content/images?id=#{img.imageId}"
rel="lightbox[pictureset]" title="#{img.caption}">
<h:graphicImage
value="/content/images?id=#{img.imageId}&width=90"
border="0"/>
</a>
- <s:button view="/permissionmanager.seam"
action="#{permissionSearch.loadPermissions(pictureSearch.lookupImage())}"
styleClass="padlock">
+ <s:button view="/permissionmanager.seam"
action="#{permissionSearch.search(pictureSearch.lookupImage())}"
styleClass="padlock">
<f:param name="imageId"
value="#{img.imageId}"/>
</s:button>
<s:button styleClass="trash"/>
Added: trunk/examples/seamspace/view/roledetail.page.xml
===================================================================
--- trunk/examples/seamspace/view/roledetail.page.xml (rev 0)
+++ trunk/examples/seamspace/view/roledetail.page.xml 2008-05-05 13:55:04 UTC (rev 8116)
@@ -0,0 +1,11 @@
+<!DOCTYPE page PUBLIC
+ "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
+ "http://jboss.com/products/seam/pages-1.2.dtd">
+
+<page>
+ <navigation from-action="#{roleAction.save}">
+ <rule if-outcome="success">
+ <redirect view-id="/rolemanager.xhtml"/>
+ </rule>
+ </navigation>
+</page>
\ No newline at end of file
Added: trunk/examples/seamspace/view/rolemanager.page.xml
===================================================================
--- trunk/examples/seamspace/view/rolemanager.page.xml (rev 0)
+++ trunk/examples/seamspace/view/rolemanager.page.xml 2008-05-05 13:55:04 UTC (rev 8116)
@@ -0,0 +1,15 @@
+<!DOCTYPE page PUBLIC
+ "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
+ "http://jboss.com/products/seam/pages-1.2.dtd">
+
+<page action="#{roleSearch.loadRoles}">
+ <restrict>#{s:hasPermission('seam.role',
'read')}</restrict>
+
+ <navigation from-action="#{roleAction.createRole}">
+ <redirect view-id="/roledetail.xhtml"/>
+ </navigation>
+
+ <navigation
from-action="#{roleAction.editRole(roleSearch.selectedRole)}">
+ <redirect view-id="/roledetail.xhtml"/>
+ </navigation>
+</page>
\ No newline at end of file
Added: trunk/examples/seamspace/view/userdetail.page.xml
===================================================================
--- trunk/examples/seamspace/view/userdetail.page.xml (rev 0)
+++ trunk/examples/seamspace/view/userdetail.page.xml 2008-05-05 13:55:04 UTC (rev 8116)
@@ -0,0 +1,11 @@
+<!DOCTYPE page PUBLIC
+ "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
+ "http://jboss.com/products/seam/pages-1.2.dtd">
+
+<page>
+ <navigation from-action="#{userAction.save}">
+ <rule if-outcome="success">
+ <redirect view-id="/usermanager.xhtml"/>
+ </rule>
+ </navigation>
+</page>
\ No newline at end of file
Added: trunk/examples/seamspace/view/usermanager.page.xml
===================================================================
--- trunk/examples/seamspace/view/usermanager.page.xml (rev 0)
+++ trunk/examples/seamspace/view/usermanager.page.xml 2008-05-05 13:55:04 UTC (rev 8116)
@@ -0,0 +1,15 @@
+<!DOCTYPE page PUBLIC
+ "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
+ "http://jboss.com/products/seam/pages-1.2.dtd">
+
+<page action="#{userSearch.loadUsers}">
+ <restrict>#{s:hasPermission('seam.user',
'read')}</restrict>
+
+ <navigation from-action="#{userAction.createUser}">
+ <redirect view-id="/userdetail.xhtml"/>
+ </navigation>
+
+ <navigation
from-action="#{userAction.editUser(userSearch.selectedUser)}">
+ <redirect view-id="/userdetail.xhtml"/>
+ </navigation>
+</page>
\ No newline at end of file