Author: shane.bryzak(a)jboss.com
Date: 2008-05-06 23:10:20 -0400 (Tue, 06 May 2008)
New Revision: 8120
Added:
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java
trunk/examples/seamspace/view/imagepermissions.page.xml
trunk/examples/seamspace/view/imagepermissions.xhtml
Removed:
trunk/examples/seamspace/view/permissionmanager.page.xml
trunk/examples/seamspace/view/permissionmanager.xhtml
Modified:
trunk/examples/seamspace/view/pictures.xhtml
Log:
replace generic permission manager with target-specific manager
Added: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java
(rev 0)
+++
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java 2008-05-07
03:10:20 UTC (rev 8120)
@@ -0,0 +1,108 @@
+package org.jboss.seam.example.seamspace;
+
+import static org.jboss.seam.ScopeType.CONVERSATION;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.security.management.IdentityManager;
+import org.jboss.seam.security.permission.PermissionManager;
+import org.jboss.seam.security.permission.action.PermissionSearch;
+
+@Name("imagePermission")
+@Scope(CONVERSATION)
+public class ImagePermission implements Serializable
+{
+ private static final long serialVersionUID = -4943654157860780587L;
+
+ private List<String> selectedRoles;
+ private List<Member> selectedFriends;
+ private List<String> selectedActions;
+
+ private List<String> availableRoles;
+ private List<Member> availableFriends;
+ private List<String> availableActions;
+
+ @In IdentityManager identityManager;
+ @In PermissionManager permissionManager;
+
+ @In EntityManager entityManager;
+
+ @In PermissionSearch permissionSearch;
+
+ private MemberImage target;
+
+ @SuppressWarnings("unchecked")
+ @Begin(nested = true)
+ public void createPermission()
+ {
+ target = (MemberImage) permissionSearch.getTarget();
+
+ availableRoles = identityManager.listRoles();
+ availableFriends = entityManager.createQuery(
+ "select f.friend from MemberFriend f where f.member = :member and
f.authorized = true")
+ .setParameter("member", target.getMember())
+ .getResultList();
+
+ availableActions = permissionManager.listAvailableActions(target);
+ }
+
+ public List<String> getSelectedRoles()
+ {
+ return selectedRoles;
+ }
+
+ public void setSelectedRoles(List<String> selectedRoles)
+ {
+ this.selectedRoles = selectedRoles;
+ }
+
+ public List<Member> getSelectedFriends()
+ {
+ return selectedFriends;
+ }
+
+ public void setSelectedFriends(List<Member> selectedFriends)
+ {
+ this.selectedFriends = selectedFriends;
+ }
+
+ public List<String> getSelectedActions()
+ {
+ return selectedActions;
+ }
+
+ public void setSelectedActions(List<String> selectedActions)
+ {
+ this.selectedActions = selectedActions;
+ }
+
+ public void applyPermissions()
+ {
+
+
+ Conversation.instance().end();
+ }
+
+ public List<String> getAvailableRoles()
+ {
+ return availableRoles;
+ }
+
+ public List<Member> getAvailableFriends()
+ {
+ return availableFriends;
+ }
+
+ public List<String> getAvailableActions()
+ {
+ return availableActions;
+ }
+}
Added: trunk/examples/seamspace/view/imagepermissions.page.xml
===================================================================
--- trunk/examples/seamspace/view/imagepermissions.page.xml (rev
0)
+++ trunk/examples/seamspace/view/imagepermissions.page.xml 2008-05-07 03:10:20 UTC (rev
8120)
@@ -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
Added: trunk/examples/seamspace/view/imagepermissions.xhtml
===================================================================
--- trunk/examples/seamspace/view/imagepermissions.xhtml (rev 0)
+++ trunk/examples/seamspace/view/imagepermissions.xhtml 2008-05-07 03:10:20 UTC (rev
8120)
@@ -0,0 +1,77 @@
+<!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: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">
+
+ <script type="text/javascript">
+ function confirmRevoke()
+ {
+ return confirm("Are you sure you wish to revoke this permission? This
action cannot be undone.");
+ }
+ </script>
+
+ <div id="contentMain">
+
+ <h2>Image Permissions</h2>
+
+ <div style="float: left">
+ <h3>Managing permissions for image:</h3>
+ </div>
+
+ <div class="thumbnail" style="float:right">
+ <h:graphicImage
value="/content/images?id=#{permissionSearch.target.imageId}&width=90"/>
+ </div>
+
+ <br class="clear"/>
+
+ <s:button action="#{imagePermission.createPermission}"
+ styleClass="newpermission"
+ rendered="#{s:hasPermission(permissionSearch.target,
'seam.grant-permission')}"/>
+
+ <h:dataTable
+ id="threads"
+ value="#{permissions}"
+ var="permission"
+ styleClass="security"
+ cellspacing="0"
+ headerClass="header"
+ rowClasses="odd,even"
+ columnClasses=",,action">
+ <h:column width="auto">
+ <f:facet name="header">
+ Recipient
+ </f:facet>
+ #{permission.recipient}
+ </h:column>
+ <h:column width="auto">
+ <f:facet name="header">
+ Actions Allowed
+ </f:facet>
+ #{permission.action}
+ </h:column>
+ <h:column width="auto">
+ <f:facet name="header">
+ Action
+ </f:facet>
+ <s:link value="Revoke All"
action="#{permissionSearch.revokeSelected}"
+ rendered="#{s:hasPermission(permissionSearch.target,
'seam.revoke-permission')}"
+ onclick="return confirmRevoke()"/>
+ </h:column>
+ </h:dataTable>
+
+ </div>
+
+ </ui:define>
+
+ </ui:composition>
+</html>
Deleted: trunk/examples/seamspace/view/permissionmanager.page.xml
===================================================================
--- trunk/examples/seamspace/view/permissionmanager.page.xml 2008-05-07 03:07:40 UTC (rev
8119)
+++ trunk/examples/seamspace/view/permissionmanager.page.xml 2008-05-07 03:10:20 UTC (rev
8120)
@@ -1,7 +0,0 @@
-<!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
Deleted: trunk/examples/seamspace/view/permissionmanager.xhtml
===================================================================
--- trunk/examples/seamspace/view/permissionmanager.xhtml 2008-05-07 03:07:40 UTC (rev
8119)
+++ trunk/examples/seamspace/view/permissionmanager.xhtml 2008-05-07 03:10:20 UTC (rev
8120)
@@ -1,69 +0,0 @@
-<!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: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">
-
- <script type="text/javascript">
- function confirmDelete()
- {
- return confirm("Are you sure you wish to revoke this permission? This
action cannot be undone.");
- }
- </script>
-
- <div id="contentMain">
-
- <h2>Permission Manager</h2>
-
- <h3>Managing permissions for: #{permissionSearch.target}</h3>
-
- <s:button action="#{permissionAction.createPermission}"
- styleClass="newpermission"
- rendered="#{s:hasPermission(permissionSearch.target,
'seam.grant-permission')}"/>
-
- <h:dataTable
- id="threads"
- value="#{permissions}"
- var="permission"
- styleClass="security"
- cellspacing="0"
- headerClass="header"
- rowClasses="odd,even"
- columnClasses=",,enabled,action">
- <h:column width="auto">
- <f:facet name="header">
- Recipient
- </f:facet>
- #{permission.recipient}
- </h:column>
- <h:column width="auto">
- <f:facet name="header">
- Actions Allowed
- </f:facet>
- #{permission.action}
- </h:column>
- <h:column width="auto">
- <f:facet name="header">
- Action
- </f:facet>
- <s:link value="Revoke"
action="#{permissionManager.revokePermission(permissionSearch.selectedPermission)}"
- rendered="#{s:hasPermission(permissionSearch.target,
'seam.revoke-permission')}"
- onclick="return confirmDelete()"/>
- </h:column>
- </h:dataTable>
-
- </div>
-
- </ui:define>
-
- </ui:composition>
-</html>
Modified: trunk/examples/seamspace/view/pictures.xhtml
===================================================================
--- trunk/examples/seamspace/view/pictures.xhtml 2008-05-07 03:07:40 UTC (rev 8119)
+++ trunk/examples/seamspace/view/pictures.xhtml 2008-05-07 03:10:20 UTC (rev 8120)
@@ -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.search(pictureSearch.lookupImage())}"
styleClass="padlock">
+ <s:button view="/imagepermissions.seam"
action="#{permissionSearch.search(pictureSearch.lookupImage())}"
styleClass="padlock">
<f:param name="imageId"
value="#{img.imageId}"/>
</s:button>
<s:button styleClass="trash"/>