Seam SVN: r8099 - trunk/seam-gen.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-05-02 14:39:14 -0400 (Fri, 02 May 2008)
New Revision: 8099
Modified:
trunk/seam-gen/build.xml
Log:
New location for hsqldb.jar
Modified: trunk/seam-gen/build.xml
===================================================================
--- trunk/seam-gen/build.xml 2008-05-02 07:06:08 UTC (rev 8098)
+++ trunk/seam-gen/build.xml 2008-05-02 18:39:14 UTC (rev 8099)
@@ -368,7 +368,7 @@
message="Enter the Hibernate dialect for your database [${hibernate.dialect.default}]"
defaultvalue="${hibernate.dialect.default}"/>
- <property name="old.driver.jar" value="lib/hsqldb.jar"/>
+ <property name="old.driver.jar" value="../lib/gen/hsqldb.jar"/>
<input addproperty="driver.jar.new"
message="Enter the filesystem path to the JDBC driver jar [${old.driver.jar}]"
defaultvalue="${old.driver.jar}"/>
@@ -628,13 +628,13 @@
<target name="copy-icefaces-maven" if="icefaces.property" unless="icefaces.lib.property">
<artifact:dependencies filesetId="icefaces.fileset" versionsId="icefaces.versions">
- <dependency groupId="org.icefaces" artifactId="icefaces" version="1.6.1">
+ <dependency groupId="org.icefaces" artifactId="icefaces" version="1.7.0">
<exclusion groupId="javax.el" artifactId="el-api" />
</dependency>
- <dependency groupId="org.icefaces" artifactId="icefaces-comps" version="1.6.1">
+ <dependency groupId="org.icefaces" artifactId="icefaces-comps" version="1.7.0">
<exclusion groupId="javax.el" artifactId="el-api" />
</dependency>
- <dependency groupId="org.icefaces" artifactId="icefaces-facelets" version="1.6.1">
+ <dependency groupId="org.icefaces" artifactId="icefaces-facelets" version="1.7.0">
<exclusion groupId="javax.el" artifactId="el-api" />
</dependency>
<remoteRepository refId="repository.jboss.org" />
16 years
Seam SVN: r8098 - trunk/examples/icefaces/view.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-05-02 03:06:08 -0400 (Fri, 02 May 2008)
New Revision: 8098
Modified:
trunk/examples/icefaces/view/hotelview.xhtml
Log:
incorrectly displaying name instead of price for hotel rate
Modified: trunk/examples/icefaces/view/hotelview.xhtml
===================================================================
--- trunk/examples/icefaces/view/hotelview.xhtml 2008-05-01 21:30:51 UTC (rev 8097)
+++ trunk/examples/icefaces/view/hotelview.xhtml 2008-05-02 07:06:08 UTC (rev 8098)
@@ -36,7 +36,7 @@
<s:decorate template="display.xhtml">
<ui:define name="label">Nightly rate:</ui:define>
- <h:outputText value="#{hotel.name}">
+ <h:outputText value="#{hotel.price}">
<f:convertNumber type="currency" currencySymbol="$"/>
</h:outputText>
</s:decorate>
16 years
Seam SVN: r8097 - trunk/seam-gen/icefaces/view.
by seam-commits@lists.jboss.org
Author: jguglielmin
Date: 2008-05-01 17:30:51 -0400 (Thu, 01 May 2008)
New Revision: 8097
Modified:
trunk/seam-gen/icefaces/view/home.xhtml
Log:
ICE-2694. Minor fixes for ICEfaces templates and adding resizable columns to ice:dataTables
Modified: trunk/seam-gen/icefaces/view/home.xhtml
===================================================================
--- trunk/seam-gen/icefaces/view/home.xhtml 2008-05-01 16:37:41 UTC (rev 8096)
+++ trunk/seam-gen/icefaces/view/home.xhtml 2008-05-01 21:30:51 UTC (rev 8097)
@@ -15,7 +15,7 @@
<ice:panelGrid id="homePanelGrid" columns="2" columnClasses="leftMenu,leftMenu">
<img src="img/ICEfaces-logo.gif" alt="Icefaces and Seam: framework demo"/>
<ice:panelGroup id="homePanelGroup">
- <p>This ICEfaces 1.6.1 + Seam 2.0.0 enabled Application includes:</p>
+ <p>This ICEfaces and Seam enabled Application includes:</p>
<ul>
<li>Ant build script</li>
<li>Deployment to JBoss AS (EAR or WAR)</li>
@@ -25,7 +25,7 @@
<li>JPA entity classes</li>
<li>A configurable DataSource and JPA EntityManager</li>
<li>Templated Facelets views</li>
- <li>ICEFaces panels and tables</li>
+ <li>ICEFaces panels and tables with resizable columns</li>
<li>Default CSS stylesheet</li>
<li>Internationalization support</li>
</ul>
16 years
Seam SVN: r8096 - in trunk/seam-gen/icefaces: view and 1 other directory.
by seam-commits@lists.jboss.org
Author: jguglielmin
Date: 2008-05-01 12:37:41 -0400 (Thu, 01 May 2008)
New Revision: 8096
Modified:
trunk/seam-gen/icefaces/src/TimerBeanImpl.java
trunk/seam-gen/icefaces/view/edit.xhtml.ftl
trunk/seam-gen/icefaces/view/editproperty.xhtml.ftl
trunk/seam-gen/icefaces/view/list.xhtml
trunk/seam-gen/icefaces/view/list.xhtml.ftl
trunk/seam-gen/icefaces/view/view.xhtml.ftl
Log:
ICE-2694. Minor fixes for ICEfaces templates and adding resizable columns to ice:dataTables
Modified: trunk/seam-gen/icefaces/src/TimerBeanImpl.java
===================================================================
--- trunk/seam-gen/icefaces/src/TimerBeanImpl.java 2008-05-01 15:27:18 UTC (rev 8095)
+++ trunk/seam-gen/icefaces/src/TimerBeanImpl.java 2008-05-01 16:37:41 UTC (rev 8096)
@@ -53,7 +53,6 @@
import com.icesoft.faces.async.render.RenderManager;
import com.icesoft.faces.async.render.IntervalRenderer;
import com.icesoft.faces.async.render.Renderable;
-import com.icesoft.faces.context.ViewListener;
import com.icesoft.faces.context.effects.Effect;
import com.icesoft.faces.context.effects.BlindDown;
@@ -69,7 +68,7 @@
@Name("timer")
@Scope(ScopeType.PAGE)
-public class TimerBeanImpl implements Renderable, ViewListener, Serializable {
+public class TimerBeanImpl implements Renderable, Serializable {
// expand/contract effects to take place of panelCollapsible
private Effect currentEffect=new BlindUp();
@@ -175,7 +174,6 @@
log.trace("*** new TimerBean renderable... " + myId );
}
- state.addViewListener(this );
FacesContext fc = FacesContext.getCurrentInstance();
synchronous = (String) fc.getExternalContext().getInitParameterMap().
get( "com.icesoft.faces.synchronousUpdate" );
@@ -222,16 +220,7 @@
cleanup();
}
- public void viewCreated() {
- }
- public void viewDisposed() {
- if(log.isTraceEnabled() ) {
- log.trace("*** View disposed: " + myId );
- }
- cleanup();
- }
-
private void cleanup() {
if (ir != null) {
ir.remove(this);
Modified: trunk/seam-gen/icefaces/view/edit.xhtml.ftl
===================================================================
--- trunk/seam-gen/icefaces/view/edit.xhtml.ftl 2008-05-01 15:27:18 UTC (rev 8095)
+++ trunk/seam-gen/icefaces/view/edit.xhtml.ftl 2008-05-01 16:37:41 UTC (rev 8096)
@@ -109,7 +109,7 @@
<#if !c2h.isCollection(parentProperty) && !c2h.isManyToOne(parentProperty) && parentProperty != parentPojo.versionProperty!>
<#if parentPojo.isComponent(parentProperty)>
<#foreach componentProperty in parentProperty.value.propertyIterator>
- <ice:column id="$editColumn${componentProperty.name}Id">
+ <ice:column id="editColumn${componentProperty.name}Id">
<f:facet name="header">${componentProperty.name}</f:facet>
${'#'}{${parentName}.${parentProperty.name}.${componentProperty.name}}
</ice:column>
Modified: trunk/seam-gen/icefaces/view/editproperty.xhtml.ftl
===================================================================
--- trunk/seam-gen/icefaces/view/editproperty.xhtml.ftl 2008-05-01 15:27:18 UTC (rev 8095)
+++ trunk/seam-gen/icefaces/view/editproperty.xhtml.ftl 2008-05-01 16:37:41 UTC (rev 8096)
@@ -101,8 +101,8 @@
</#if>
size="${size}"
maxlength="${column.length}"
+ partialSubmit="true"
value="${'#'}{${homeName}.instance.${property.name}.${componentProperty.name}}">
- partialSubmit="true"
</ice:inputText>
</#if>
<#else>
@@ -112,9 +112,9 @@
</#if>
<#if propertyIsId>
disabled="${'#'}{${homeName}.managed}"
-</#if>
- value="${'#'}{${homeName}.instance.${property.name}.${componentProperty.name}}">
- partialSubmit="true"
+</#if>
+ partialSubmit="true"
+ value="${'#'}{${homeName}.instance.${property.name}.${componentProperty.name}}">
</ice:inputText>
</#if>
</s:decorate>
Modified: trunk/seam-gen/icefaces/view/list.xhtml
===================================================================
--- trunk/seam-gen/icefaces/view/list.xhtml 2008-05-01 15:27:18 UTC (rev 8095)
+++ trunk/seam-gen/icefaces/view/list.xhtml 2008-05-01 16:37:41 UTC (rev 8096)
@@ -27,6 +27,7 @@
rendered="#{empty @listName@.resultList}"/>
<ice:dataTable id="@listName@TableId" var="@componentName@"
value="#{@listName@.resultList}"
+ resizable="true"
columnClasses="allCols"
rendered="#{not empty @listName@.resultList}">
<ice:column id="list@componentName@.id">
Modified: trunk/seam-gen/icefaces/view/list.xhtml.ftl
===================================================================
--- trunk/seam-gen/icefaces/view/list.xhtml.ftl 2008-05-01 15:27:18 UTC (rev 8095)
+++ trunk/seam-gen/icefaces/view/list.xhtml.ftl 2008-05-01 16:37:41 UTC (rev 8096)
@@ -81,6 +81,7 @@
<ice:dataTable id="${listName}TableId"
var="${componentName}"
value="${'#'}{${listName}.resultList}"
+ resizable="true"
columnClasses="allCols"
rendered="${'#'}{not empty ${listName}.resultList}">
<#foreach property in pojo.allPropertiesIterator>
@@ -110,7 +111,7 @@
<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
<#if parentPojo.isComponent(parentPojo.identifierProperty)>
<#foreach componentProperty in parentPojo.identifierProperty.value.propertyIterator>
- <ice:column id="listColumn${propertyName}${listName}Id">
+ <ice:column id="listColumn${componentProperty}${listName}Id">
<f:facet name="header">
<#assign propertyPath = property.name + '.' + parentPojo.identifierProperty.name + '.' + componentProperty.name>
<s:link styleClass="columnHeader"
Modified: trunk/seam-gen/icefaces/view/view.xhtml.ftl
===================================================================
--- trunk/seam-gen/icefaces/view/view.xhtml.ftl 2008-05-01 15:27:18 UTC (rev 8095)
+++ trunk/seam-gen/icefaces/view/view.xhtml.ftl 2008-05-01 16:37:41 UTC (rev 8096)
@@ -107,7 +107,7 @@
</ice:column>
</#foreach>
<#else>
- <ice:column id="view$${parentParentPojo.identifierProperty.name}ColumnName">
+ <ice:column id="view${parentParentPojo.identifierProperty.name}ColumnName">
<f:facet name="header">${parentProperty.name} ${parentParentPojo.identifierProperty.name}</f:facet>
${'#'}{${parentName}.${parentProperty.name}.${parentParentPojo.identifierProperty.name}}
</ice:column>
16 years
Seam SVN: r8095 - tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/src/org/jboss/seam/example/seamspace/test.
by seam-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2008-05-01 11:27:18 -0400 (Thu, 01 May 2008)
New Revision: 8095
Modified:
tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/src/org/jboss/seam/example/seamspace/test/RegisterTest.java
Log:
commit of changes Shane made for JBSEAM-2934
Modified: tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/src/org/jboss/seam/example/seamspace/test/RegisterTest.java
===================================================================
--- tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/src/org/jboss/seam/example/seamspace/test/RegisterTest.java 2008-05-01 15:26:24 UTC (rev 8094)
+++ tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/src/org/jboss/seam/example/seamspace/test/RegisterTest.java 2008-05-01 15:27:18 UTC (rev 8095)
@@ -29,7 +29,7 @@
setValue("#{newMember.firstName}", "Shane");
setValue("#{newMember.lastName}", "Bryzak");
setValue("#{newMember.memberName}", "shane123");
- setValue("#{register.username}", "sbryzak");
+ setValue("#{newMember.username}", "sbryzak");
setValue("#{register.password}", "secret");
setValue("#{register.confirm}", "secret");
setValue("#{register.gender}", "Male");
16 years
Seam SVN: r8094 - tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/resources.
by seam-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2008-05-01 11:26:24 -0400 (Thu, 01 May 2008)
New Revision: 8094
Modified:
tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/resources/import.sql
Log:
commit of changes Shane made for JBSEAM-2934
Modified: tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/resources/import.sql
===================================================================
--- tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/resources/import.sql 2008-05-01 08:43:02 UTC (rev 8093)
+++ tags/JBoss_Seam_2_0_2_CR2/examples/seamspace/resources/import.sql 2008-05-01 15:26:24 UTC (rev 8094)
@@ -6,6 +6,7 @@
insert into MemberRole (roleid, name) values (1, 'user');
insert into MemberRole (roleid, name) values (2, 'admin');
+insert into MemberRoles (member_id, role_id) values (1, 1);
insert into MemberRoles (member_id, role_id) values (1, 2);
insert into MemberRoles (member_id, role_id) values (2, 1);
insert into MemberRoles (member_id, role_id) values (3, 1);
16 years
Seam SVN: r8093 - trunk/src/main/org/jboss/seam/annotations/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-01 04:43:02 -0400 (Thu, 01 May 2008)
New Revision: 8093
Modified:
trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java
Log:
minor
Modified: trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java
===================================================================
--- trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java 2008-05-01 08:41:03 UTC (rev 8092)
+++ trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java 2008-05-01 08:43:02 UTC (rev 8093)
@@ -1,5 +1,23 @@
package org.jboss.seam.annotations.security.management;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Flags an entity field or method as representing whether a role is conditional or not
+ *
+ * @author Shane Bryzak
+ */
+@Target({METHOD,FIELD})
+@Documented
+@Retention(RUNTIME)
+@Inherited
public @interface RoleConditional
{
16 years
Seam SVN: r8092 - in trunk/src/main/org/jboss/seam: security and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-01 04:41:03 -0400 (Thu, 01 May 2008)
New Revision: 8092
Added:
trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java
trunk/src/main/org/jboss/seam/security/permission/RoleCheck.java
Modified:
trunk/src/main/org/jboss/seam/security/Role.java
trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Log:
changed some terminology, implemented conditional roles
Added: trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java
===================================================================
--- trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java (rev 0)
+++ trunk/src/main/org/jboss/seam/annotations/security/management/RoleConditional.java 2008-05-01 08:41:03 UTC (rev 8092)
@@ -0,0 +1,6 @@
+package org.jboss.seam.annotations.security.management;
+
+public @interface RoleConditional
+{
+
+}
Modified: trunk/src/main/org/jboss/seam/security/Role.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/Role.java 2008-05-01 04:30:06 UTC (rev 8091)
+++ trunk/src/main/org/jboss/seam/security/Role.java 2008-05-01 08:41:03 UTC (rev 8092)
@@ -1,28 +1,28 @@
package org.jboss.seam.security;
/**
- * Represents a user role. A dynamic role is a special type of role that is assigned to a user
+ * Represents a user role. A conditional role is a special type of role that is assigned to a user
* based on the contextual state of a permission check.
*
* @author Shane Bryzak
*/
public class Role extends SimplePrincipal
{
- private boolean dynamic;
+ private boolean conditional;
public Role(String name)
{
super(name);
}
- public Role(String name, boolean dynamic)
+ public Role(String name, boolean conditional)
{
this(name);
- this.dynamic = true;
+ this.conditional = true;
}
- public boolean isDynamic()
+ public boolean isConditional()
{
- return dynamic;
+ return conditional;
}
}
Modified: trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2008-05-01 04:30:06 UTC (rev 8091)
+++ trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2008-05-01 08:41:03 UTC (rev 8092)
@@ -97,9 +97,10 @@
{
Role role = (Role) permission.getRecipient();
- if (role.isDynamic())
+ if (role.isConditional())
{
- // TODO implement dynamic permissions
+ RuleBasedPermissionResolver resolver = RuleBasedPermissionResolver.instance();
+ return resolver.checkConditionalRole(role.getName(), target, action);
}
else if (identity.hasRole(role.getName()))
{
Added: trunk/src/main/org/jboss/seam/security/permission/RoleCheck.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/RoleCheck.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/RoleCheck.java 2008-05-01 08:41:03 UTC (rev 8092)
@@ -0,0 +1,34 @@
+package org.jboss.seam.security.permission;
+
+import java.io.Serializable;
+
+/**
+ * Used when performing rule-based dynamic role checks
+ *
+ * @author Shane Bryzak
+ */
+public class RoleCheck implements Serializable
+{
+ private String name;
+ private boolean granted;
+
+ public RoleCheck(String name)
+ {
+ this.name = name;
+ }
+
+ public boolean isGranted()
+ {
+ return granted;
+ }
+
+ public void grant()
+ {
+ this.granted = true;
+ }
+
+ public void revoke()
+ {
+ this.granted = false;
+ }
+}
Modified: trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2008-05-01 04:30:06 UTC (rev 8091)
+++ trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2008-05-01 08:41:03 UTC (rev 8092)
@@ -106,8 +106,7 @@
{
handles.add( securityContext.insert(target) );
}
-
- if (target instanceof Class)
+ else if (target instanceof Class)
{
String componentName = Seam.getComponentName((Class) target);
target = componentName != null ? componentName : ((Class) target).getName();
@@ -117,19 +116,69 @@
synchronized( securityContext )
{
- synchronizeContext();
-
- handles.add( securityContext.insert(check) );
-
- securityContext.fireAllRules();
+ try
+ {
+ synchronizeContext();
+
+ handles.add( securityContext.insert(check) );
- for (FactHandle handle : handles)
- securityContext.retract(handle);
+ securityContext.fireAllRules();
+ }
+ finally
+ {
+ for (FactHandle handle : handles)
+ {
+ securityContext.retract(handle);
+ }
+ }
}
return check.isGranted();
}
+ public boolean checkConditionalRole(String roleName, Object target, String action)
+ {
+ if (getSecurityContext() == null) return false;
+
+ RoleCheck roleCheck = new RoleCheck(roleName);
+
+ List<FactHandle> handles = new ArrayList<FactHandle>();
+ handles.add(getSecurityContext().insert(roleCheck));
+
+ if (!(target instanceof String) && !(target instanceof Class))
+ {
+ handles.add( securityContext.insert(target) );
+ }
+ else if (target instanceof Class)
+ {
+ String componentName = Seam.getComponentName((Class) target);
+ target = componentName != null ? componentName : ((Class) target).getName();
+ }
+
+ PermissionCheck check = new PermissionCheck(target, action);
+
+ synchronized( securityContext )
+ {
+ try
+ {
+ synchronizeContext();
+
+ handles.add( securityContext.insert(check));
+
+ securityContext.fireAllRules();
+ }
+ finally
+ {
+ for (FactHandle handle : handles)
+ {
+ securityContext.retract(handle);
+ }
+ }
+ }
+
+ return roleCheck.isGranted();
+ }
+
@SuppressWarnings("unchecked")
@Observer(Identity.EVENT_LOGGED_OUT)
public void unAuthenticate()
16 years
Seam SVN: r8091 - in trunk/src/main/org/jboss/seam/security: permission and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-01 00:30:06 -0400 (Thu, 01 May 2008)
New Revision: 8091
Modified:
trunk/src/main/org/jboss/seam/security/Role.java
trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java
Log:
groundwork for dynamic roles
Modified: trunk/src/main/org/jboss/seam/security/Role.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/Role.java 2008-05-01 02:37:36 UTC (rev 8090)
+++ trunk/src/main/org/jboss/seam/security/Role.java 2008-05-01 04:30:06 UTC (rev 8091)
@@ -1,14 +1,28 @@
package org.jboss.seam.security;
/**
- * Represents a user role
+ * Represents a user role. A dynamic role is a special type of role that is assigned to a user
+ * based on the contextual state of a permission check.
*
* @author Shane Bryzak
*/
public class Role extends SimplePrincipal
{
+ private boolean dynamic;
+
public Role(String name)
{
super(name);
}
+
+ public Role(String name, boolean dynamic)
+ {
+ this(name);
+ this.dynamic = true;
+ }
+
+ public boolean isDynamic()
+ {
+ return dynamic;
+ }
}
Modified: trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2008-05-01 02:37:36 UTC (rev 8090)
+++ trunk/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2008-05-01 04:30:06 UTC (rev 8091)
@@ -17,6 +17,8 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.Role;
+import org.jboss.seam.security.SimplePrincipal;
/**
* Resolves dynamically-assigned permissions, mapped to a user or a role, and kept in persistent
@@ -85,14 +87,24 @@
for (Permission permission : permissions)
{
- if (username.equals(permission.getRecipient().getName()))
+ if (permission.getRecipient() instanceof SimplePrincipal &&
+ username.equals(permission.getRecipient().getName()))
{
return true;
}
- if (identity.hasRole(permission.getRecipient().getName()))
+ if (permission.getRecipient() instanceof Role)
{
- return true;
+ Role role = (Role) permission.getRecipient();
+
+ if (role.isDynamic())
+ {
+ // TODO implement dynamic permissions
+ }
+ else if (identity.hasRole(role.getName()))
+ {
+ return true;
+ }
}
}
16 years
Seam SVN: r8090 - in trunk/src/main/org/jboss/seam: security/permission and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-30 22:37:36 -0400 (Wed, 30 Apr 2008)
New Revision: 8090
Modified:
trunk/src/main/org/jboss/seam/annotations/security/permission/Identifier.java
trunk/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java
trunk/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
Log:
finished permission identifier implementation
Modified: trunk/src/main/org/jboss/seam/annotations/security/permission/Identifier.java
===================================================================
--- trunk/src/main/org/jboss/seam/annotations/security/permission/Identifier.java 2008-05-01 00:08:50 UTC (rev 8089)
+++ trunk/src/main/org/jboss/seam/annotations/security/permission/Identifier.java 2008-05-01 02:37:36 UTC (rev 8090)
@@ -24,4 +24,5 @@
public @interface Identifier
{
Class<? extends IdentifierStrategy> value();
+ String name() default "";
}
Modified: trunk/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java 2008-05-01 00:08:50 UTC (rev 8089)
+++ trunk/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java 2008-05-01 02:37:36 UTC (rev 8090)
@@ -1,5 +1,11 @@
package org.jboss.seam.security.permission;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.seam.Seam;
+import org.jboss.seam.annotations.security.permission.Identifier;
+
/**
* An Identifier strategy for class-based permission checks
*
@@ -7,6 +13,8 @@
*/
public class ClassIdentifierStrategy implements IdentifierStrategy
{
+ private Map<Class,String> identifierNames = new ConcurrentHashMap<Class,String>();
+
public boolean canIdentify(Class targetClass)
{
return Class.class.equals(targetClass);
@@ -14,8 +22,43 @@
public String getIdentifier(Object target)
{
- // TODO Auto-generated method stub
- return null;
+ if (!(target instanceof Class))
+ {
+ throw new IllegalArgumentException("Target [" + target + "] must be instance of Class");
+ }
+
+ return getIdentifierName((Class) target);
}
-
+
+ private String getIdentifierName(Class cls)
+ {
+ if (!identifierNames.containsKey(cls))
+ {
+ String name = null;
+
+ if (cls.isAnnotationPresent(Identifier.class))
+ {
+ Identifier identifier = (Identifier) cls.getAnnotation(Identifier.class);
+ if (identifier.name() != null && !"".equals(name.trim()))
+ {
+ name = identifier.name();
+ }
+ }
+
+ if (name == null)
+ {
+ name = Seam.getComponentName(cls);
+ }
+
+ if (name == null)
+ {
+ name = cls.getName().substring(cls.getName().lastIndexOf('.') + 1);
+ }
+
+ identifierNames.put(cls, name);
+ return name;
+ }
+
+ return identifierNames.get(cls);
+ }
}
Modified: trunk/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2008-05-01 00:08:50 UTC (rev 8089)
+++ trunk/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2008-05-01 02:37:36 UTC (rev 8090)
@@ -1,9 +1,14 @@
package org.jboss.seam.security.permission;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import org.jboss.seam.Component;
+import org.jboss.seam.Seam;
+import org.jboss.seam.annotations.security.permission.Identifier;
import org.jboss.seam.core.Expressions;
import org.jboss.seam.core.Expressions.ValueExpression;
import org.jboss.seam.persistence.PersistenceProvider;
@@ -19,6 +24,8 @@
private PersistenceProvider persistenceProvider;
+ private Map<Class,String> identifierNames = new ConcurrentHashMap<Class,String>();
+
public EntityIdentifierStrategy()
{
persistenceProvider = (PersistenceProvider) Component.getInstance(PersistenceProvider.class, true);
@@ -37,9 +44,41 @@
public String getIdentifier(Object target)
{
- // TODO temporary, need to implement properly
- return target.getClass().getName() + ":" + persistenceProvider.getId(target, lookupEntityManager());
+ return String.format("%s:%s", getIdentifierName(target.getClass()),
+ persistenceProvider.getId(target, lookupEntityManager()).toString());
}
+
+ private String getIdentifierName(Class cls)
+ {
+ if (!identifierNames.containsKey(cls))
+ {
+ String name = null;
+
+ if (cls.isAnnotationPresent(Identifier.class))
+ {
+ Identifier identifier = (Identifier) cls.getAnnotation(Identifier.class);
+ if (identifier.name() != null && !"".equals(name.trim()))
+ {
+ name = identifier.name();
+ }
+ }
+
+ if (name == null)
+ {
+ name = Seam.getComponentName(cls);
+ }
+
+ if (name == null)
+ {
+ name = cls.getName().substring(cls.getName().lastIndexOf('.') + 1);
+ }
+
+ identifierNames.put(cls, name);
+ return name;
+ }
+
+ return identifierNames.get(cls);
+ }
private EntityManager lookupEntityManager()
{
16 years