Seam SVN: r7559 - branches/Seam_2_0/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-13 07:32:05 -0400 (Thu, 13 Mar 2008)
New Revision: 7559
Removed:
branches/Seam_2_0/build/docs.pom.xml
Log:
Prepare for JBSDEAM-2735
Deleted: branches/Seam_2_0/build/docs.pom.xml
===================================================================
--- branches/Seam_2_0/build/docs.pom.xml 2008-03-13 11:02:09 UTC (rev 7558)
+++ branches/Seam_2_0/build/docs.pom.xml 2008-03-13 11:32:05 UTC (rev 7559)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-reference-documentation</artifactId>
- <parent>
- <groupId>org.jboss.seam</groupId>
- <artifactId>parent</artifactId>
- <version>2.0.1-SNAPSHOT</version>
- </parent>
- <version>2.0.1-SNAPSHOT</version>
- <packaging>pdf</packaging>
-
-</project>
\ No newline at end of file
18 years, 1 month
Seam SVN: r7558 - branches/Seam_2_0/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-13 07:02:09 -0400 (Thu, 13 Mar 2008)
New Revision: 7558
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Persistence.xml
Log:
Backport of r7556, JBSEAM-2733
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Persistence.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Persistence.xml 2008-03-13 10:58:09 UTC (rev 7557)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Persistence.xml 2008-03-13 11:02:09 UTC (rev 7558)
@@ -145,8 +145,9 @@
</listitem>
<listitem>
<para>
- use two transactions per request; the first spans the beginning of the update model
- values phase until the end of the invoke application phase; the second spans the
+ use two transactions per request; the first spans the beginning of the restore view
+ phase (some transaction managers begin the transaction later at the beginning of the
+ apply request vaues phase) until the end of the invoke application phase; the second spans the
render response phase
</para>
</listitem>
@@ -205,21 +206,25 @@
<para>
JPA RESOURCE_LOCAL transactions with the
<literal>javax.persistence.EntityTransaction</literal>
- interface.
+ interface. <literal>EntityTransaction</literal> begins the transaction at the beginning
+ of the apply request values phase.
</para>
</listitem>
<listitem>
<para>
Hibernate managed transactions with the
<literal>org.hibernate.Transaction</literal>
- interface.
+ interface. <literal>HibernateTransaction</literal> begins the transaction at the beginning
+ of the apply request values phase.
</para>
</listitem>
<listitem>
<para>
Spring managed transactions with the
<literal>org.springframework.transaction.PlatformTransactionManager</literal>
- interface.
+ interface. The Spring <literal>PlatformTransactionManagement</literal> manager may begin the
+ transaction at the beginning of the apply request values phase if the
+ <literal>userConversationContext</literal> attribute is set.
</para>
</listitem>
<listitem>
18 years, 1 month
Seam SVN: r7556 - trunk/doc/reference/en/modules.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-13 06:54:42 -0400 (Thu, 13 Mar 2008)
New Revision: 7556
Modified:
trunk/doc/reference/en/modules/persistence.xml
Log:
JBSEAM-2733
Modified: trunk/doc/reference/en/modules/persistence.xml
===================================================================
--- trunk/doc/reference/en/modules/persistence.xml 2008-03-13 10:42:07 UTC (rev 7555)
+++ trunk/doc/reference/en/modules/persistence.xml 2008-03-13 10:54:42 UTC (rev 7556)
@@ -145,8 +145,9 @@
</listitem>
<listitem>
<para>
- use two transactions per request; the first spans the beginning of the update model
- values phase until the end of the invoke application phase; the second spans the
+ use two transactions per request; the first spans the beginning of the restore view
+ phase (some transaction managers begin the transaction later at the beginning of the
+ apply request vaues phase) until the end of the invoke application phase; the second spans the
render response phase
</para>
</listitem>
@@ -205,21 +206,25 @@
<para>
JPA RESOURCE_LOCAL transactions with the
<literal>javax.persistence.EntityTransaction</literal>
- interface.
+ interface. <literal>EntityTransaction</literal> begins the transaction at the beginning
+ of the apply request values phase.
</para>
</listitem>
<listitem>
<para>
Hibernate managed transactions with the
<literal>org.hibernate.Transaction</literal>
- interface.
+ interface. <literal>HibernateTransaction</literal> begins the transaction at the beginning
+ of the apply request values phase.
</para>
</listitem>
<listitem>
<para>
Spring managed transactions with the
<literal>org.springframework.transaction.PlatformTransactionManager</literal>
- interface.
+ interface. The Spring <literal>PlatformTransactionManagement</literal> manager may begin the
+ transaction at the beginning of the apply request values phase if the
+ <literal>userConversationContext</literal> attribute is set.
</para>
</listitem>
<listitem>
18 years, 1 month
Seam SVN: r7555 - branches/Seam_2_0/ui/src/main/config/component.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-13 06:42:07 -0400 (Thu, 13 Mar 2008)
New Revision: 7555
Modified:
branches/Seam_2_0/ui/src/main/config/component/convertDateTime.xml
branches/Seam_2_0/ui/src/main/config/component/decorate.xml
branches/Seam_2_0/ui/src/main/config/component/fragment.xml
branches/Seam_2_0/ui/src/main/config/component/graphicImage.xml
branches/Seam_2_0/ui/src/main/config/component/label.xml
branches/Seam_2_0/ui/src/main/config/component/link.xml
branches/Seam_2_0/ui/src/main/config/component/remote.xml
branches/Seam_2_0/ui/src/main/config/component/selectDate.xml
branches/Seam_2_0/ui/src/main/config/component/selection.xml
branches/Seam_2_0/ui/src/main/config/component/transformImageBlur.xml
branches/Seam_2_0/ui/src/main/config/component/transformImageSize.xml
branches/Seam_2_0/ui/src/main/config/component/transformImageType.xml
Log:
Backport r7554, JBSEAM-1567
Modified: branches/Seam_2_0/ui/src/main/config/component/convertDateTime.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/convertDateTime.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/convertDateTime.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -18,26 +18,32 @@
<property>
<name>timeStyle</name>
<classname>java.lang.String</classname>
+ <description>Predefined formatting style which determines how the time component of a date string is to be formatted and parsed. Applied only if type is "time" or "both". Valid values are "default", "short", "medium", "long", and "full". Default value is "default".</description>
</property>
<property>
<name>dateStyle</name>
<classname>java.lang.String</classname>
+ <description>Predefined formatting style which determines how the date component of a date string is to be formatted and parsed. Applied only if type is "date" or "both". Valid values are "default", "short", "medium", "long", and "full". Default value is "default".</description>
</property>
<property>
<name>pattern</name>
<classname>java.lang.String</classname>
+ <description>Custom formatting pattern which determines how the date/time string should be formatted and parsed.</description>
</property>
<property elonly="true">
<name>locale</name>
<classname>java.util.Locale</classname>
+ <description>Locale whose predefined styles for dates and times are used during formatting or parsing. If not specified, the Locale returned by FacesContext.getViewRoot().getLocale() will be used. Value must be either a VB expression that evaluates to a java.util.Locale instance, or a String that is valid to pass as the first argument to the constructor java.util.Locale(String language, String country). The empty string is passed as the second argument.</description>
</property>
<property elonly="true">
<name>timeZone</name>
<classname>java.util.TimeZone</classname>
+ <description>Time zone in which to interpret any time information in the date String. Value must be either a VB expression that evaluates to a java.util.TimeZone instance, or a String that is a timezone ID as described in the javadocs for java.util.TimeZone.getTimeZone().</description>
</property>
<property>
<name>type</name>
<classname>java.lang.String</classname>
+ <description>Specifies what contents the string value will be formatted to include, or parsed expecting. Valid values are "date", "time", and "both". Default value is "date".</description>
<defaultvalue>"date"</defaultvalue>
</property>
</converter>
Modified: branches/Seam_2_0/ui/src/main/config/component/decorate.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/decorate.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/decorate.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -32,13 +32,13 @@
<property el="false">
<name>for</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>Id of the input field to decorate</description>
</property>
<property exist="true">
<name>template</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>XHTML template to use to decorate the input field</description>
</property>
</component>
Modified: branches/Seam_2_0/ui/src/main/config/component/fragment.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/fragment.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/fragment.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,8 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlFragment</classname>
<superclass>org.jboss.seam.ui.component.UIFragment</superclass>
<description>
- <![CDATA[
- ]]>
+ <![CDATA[Surround a page fragment, allows you to apply render/not render without any html output]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.FragmentRenderer</name>
Modified: branches/Seam_2_0/ui/src/main/config/component/graphicImage.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/graphicImage.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/graphicImage.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlGraphicImage</classname>
<superclass>org.jboss.seam.ui.graphicImage.UIGraphicImage</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Output an image to the view. You can specify the file as a path, a java.io.File, java.io.InputStream, java.net.URL or byte[]]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.GraphicImageRenderer</name>
@@ -29,7 +29,7 @@
<property>
<name>fileName</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>File name for the generated URL - allows a stable file name and thus browser caching</description>
</property>
</component>
</components>
Modified: branches/Seam_2_0/ui/src/main/config/component/label.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/label.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/label.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -24,7 +24,7 @@
<property>
<name>for</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>Id of input component this label is for</description>
</property>
</component>
</components>
Modified: branches/Seam_2_0/ui/src/main/config/component/link.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/link.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/link.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -54,10 +54,12 @@
<property>
<name>outcome</name>
<classname>java.lang.String</classname>
+ <description>The outcome to use when evaluating navigation rules</description>
</property>
<property>
<name>disabled</name>
<classname>boolean</classname>
+ <description>If true, write the link as disabled in HTML</description>
</property>
<property elonly="true" transient="true" >
<name>taskInstance</name>
Modified: branches/Seam_2_0/ui/src/main/config/component/remote.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/remote.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/remote.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlRemote</classname>
<superclass>org.jboss.seam.ui.component.UIRemote</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Write out script element for use with Seam Remoting]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.RemoteRenderer</name>
@@ -26,7 +26,7 @@
<property>
<name>include</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>The Seam components to include in the Seam Remoting JS interface stubs</description>
</property>
</component>
</components>
Modified: branches/Seam_2_0/ui/src/main/config/component/selectDate.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/selectDate.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/selectDate.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,12 +7,11 @@
<classname>org.jboss.seam.ui.component.html.HtmlSelectDate</classname>
<superclass>org.jboss.seam.ui.component.UISelectDate</superclass>
<description>
- <![CDATA[Deprecated. You should use <rich:calendar /> instead.]]>
+ <![CDATA[Deprecated. You should use <rich:calendar /> instead.]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.SelectDateRenderer</name>
<classname>org.jboss.seam.ui.renderkit.SelectDateRendererBase</classname>
- <!--<template>org/jboss/seam/ui/htmlSelectDate.jspx</template>-->
</renderer>
<tag>
<name>selectDate</name>
Modified: branches/Seam_2_0/ui/src/main/config/component/selection.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/selection.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/selection.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,8 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlSelection</classname>
<superclass>org.jboss.seam.ui.component.UISelection</superclass>
<description>
- <![CDATA[
- ]]>
+ <![CDATA[]]>
</description>
<tag>
<name>selection</name>
Modified: branches/Seam_2_0/ui/src/main/config/component/transformImageBlur.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/transformImageBlur.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/transformImageBlur.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlTransformImageBlur</classname>
<superclass>org.jboss.seam.ui.graphicImage.UITransformImageBlur</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Nested in a s:graphicImage. Transform an image by applying a blur]]>
</description>
<tag>
<name>transformImageBlur</name>
@@ -20,7 +20,7 @@
<property>
<name>radius</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>The radius of the blur (essentially the ammount of blur)</description>
</property>
</component>
</components>
Modified: branches/Seam_2_0/ui/src/main/config/component/transformImageSize.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/transformImageSize.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/transformImageSize.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlTransformImageSize</classname>
<superclass>org.jboss.seam.ui.graphicImage.UITransformImageSize</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Nested in a s:graphicImage. Transform an image by altering the size]]>
</description>
<tag>
<name>transformImageSize</name>
@@ -20,22 +20,22 @@
<property>
<name>maintainRatio</name>
<classname>boolean</classname>
- <description></description>
+ <description>If true, don't alter the ratio of the image. In this case only height or width should be specificed.</description>
</property>
<property>
<name>width</name>
<classname>java.lang.Integer</classname>
- <description></description>
+ <description>The new width of the image</description>
</property>
<property>
<name>height</name>
<classname>java.lang.Integer</classname>
- <description></description>
+ <description>The new height of the image</description>
</property>
<property>
<name>factor</name>
<classname>java.lang.Double</classname>
- <description></description>
+ <description>Change the size of the image by a fraction. If factor is specified, height, width and maintainRatio should not be specified</description>
</property>
</component>
</components>
Modified: branches/Seam_2_0/ui/src/main/config/component/transformImageType.xml
===================================================================
--- branches/Seam_2_0/ui/src/main/config/component/transformImageType.xml 2008-03-13 10:41:16 UTC (rev 7554)
+++ branches/Seam_2_0/ui/src/main/config/component/transformImageType.xml 2008-03-13 10:42:07 UTC (rev 7555)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlTransformImageType</classname>
<superclass>org.jboss.seam.ui.graphicImage.UITransformImageType</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Nested in a s:graphicImage. Transform an image by changing it's type]]>
</description>
<tag>
<name>transformImageType</name>
@@ -20,7 +20,7 @@
<property>
<name>contentType</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>The mime type of the output image</description>
</property>
</component>
</components>
18 years, 1 month
Seam SVN: r7554 - trunk/ui/src/main/config/component.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-13 06:41:16 -0400 (Thu, 13 Mar 2008)
New Revision: 7554
Modified:
trunk/ui/src/main/config/component/convertDateTime.xml
trunk/ui/src/main/config/component/decorate.xml
trunk/ui/src/main/config/component/fragment.xml
trunk/ui/src/main/config/component/graphicImage.xml
trunk/ui/src/main/config/component/label.xml
trunk/ui/src/main/config/component/link.xml
trunk/ui/src/main/config/component/remote.xml
trunk/ui/src/main/config/component/selectDate.xml
trunk/ui/src/main/config/component/selection.xml
trunk/ui/src/main/config/component/transformImageBlur.xml
trunk/ui/src/main/config/component/transformImageSize.xml
trunk/ui/src/main/config/component/transformImageType.xml
Log:
JBSEAM-1567
Modified: trunk/ui/src/main/config/component/convertDateTime.xml
===================================================================
--- trunk/ui/src/main/config/component/convertDateTime.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/convertDateTime.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -18,26 +18,32 @@
<property>
<name>timeStyle</name>
<classname>java.lang.String</classname>
+ <description>Predefined formatting style which determines how the time component of a date string is to be formatted and parsed. Applied only if type is "time" or "both". Valid values are "default", "short", "medium", "long", and "full". Default value is "default".</description>
</property>
<property>
<name>dateStyle</name>
<classname>java.lang.String</classname>
+ <description>Predefined formatting style which determines how the date component of a date string is to be formatted and parsed. Applied only if type is "date" or "both". Valid values are "default", "short", "medium", "long", and "full". Default value is "default".</description>
</property>
<property>
<name>pattern</name>
<classname>java.lang.String</classname>
+ <description>Custom formatting pattern which determines how the date/time string should be formatted and parsed.</description>
</property>
<property elonly="true">
<name>locale</name>
<classname>java.util.Locale</classname>
+ <description>Locale whose predefined styles for dates and times are used during formatting or parsing. If not specified, the Locale returned by FacesContext.getViewRoot().getLocale() will be used. Value must be either a VB expression that evaluates to a java.util.Locale instance, or a String that is valid to pass as the first argument to the constructor java.util.Locale(String language, String country). The empty string is passed as the second argument.</description>
</property>
<property elonly="true">
<name>timeZone</name>
<classname>java.util.TimeZone</classname>
+ <description>Time zone in which to interpret any time information in the date String. Value must be either a VB expression that evaluates to a java.util.TimeZone instance, or a String that is a timezone ID as described in the javadocs for java.util.TimeZone.getTimeZone().</description>
</property>
<property>
<name>type</name>
<classname>java.lang.String</classname>
+ <description>Specifies what contents the string value will be formatted to include, or parsed expecting. Valid values are "date", "time", and "both". Default value is "date".</description>
<defaultvalue>"date"</defaultvalue>
</property>
</converter>
Modified: trunk/ui/src/main/config/component/decorate.xml
===================================================================
--- trunk/ui/src/main/config/component/decorate.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/decorate.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -32,13 +32,13 @@
<property el="false">
<name>for</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>Id of the input field to decorate</description>
</property>
<property exist="true">
<name>template</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>XHTML template to use to decorate the input field</description>
</property>
</component>
Modified: trunk/ui/src/main/config/component/fragment.xml
===================================================================
--- trunk/ui/src/main/config/component/fragment.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/fragment.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,8 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlFragment</classname>
<superclass>org.jboss.seam.ui.component.UIFragment</superclass>
<description>
- <![CDATA[
- ]]>
+ <![CDATA[Surround a page fragment, allows you to apply render/not render without any html output]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.FragmentRenderer</name>
Modified: trunk/ui/src/main/config/component/graphicImage.xml
===================================================================
--- trunk/ui/src/main/config/component/graphicImage.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/graphicImage.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlGraphicImage</classname>
<superclass>org.jboss.seam.ui.graphicImage.UIGraphicImage</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Output an image to the view. You can specify the file as a path, a java.io.File, java.io.InputStream, java.net.URL or byte[]]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.GraphicImageRenderer</name>
@@ -29,7 +29,7 @@
<property>
<name>fileName</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>File name for the generated URL - allows a stable file name and thus browser caching</description>
</property>
</component>
</components>
Modified: trunk/ui/src/main/config/component/label.xml
===================================================================
--- trunk/ui/src/main/config/component/label.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/label.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -24,7 +24,7 @@
<property>
<name>for</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>Id of input component this label is for</description>
</property>
</component>
</components>
Modified: trunk/ui/src/main/config/component/link.xml
===================================================================
--- trunk/ui/src/main/config/component/link.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/link.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -54,10 +54,12 @@
<property>
<name>outcome</name>
<classname>java.lang.String</classname>
+ <description>The outcome to use when evaluating navigation rules</description>
</property>
<property>
<name>disabled</name>
<classname>boolean</classname>
+ <description>If true, write the link as disabled in HTML</description>
</property>
<property elonly="true" transient="true" >
<name>taskInstance</name>
Modified: trunk/ui/src/main/config/component/remote.xml
===================================================================
--- trunk/ui/src/main/config/component/remote.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/remote.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlRemote</classname>
<superclass>org.jboss.seam.ui.component.UIRemote</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Write out script element for use with Seam Remoting]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.RemoteRenderer</name>
@@ -26,7 +26,7 @@
<property>
<name>include</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>The Seam components to include in the Seam Remoting JS interface stubs</description>
</property>
</component>
</components>
Modified: trunk/ui/src/main/config/component/selectDate.xml
===================================================================
--- trunk/ui/src/main/config/component/selectDate.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/selectDate.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,12 +7,11 @@
<classname>org.jboss.seam.ui.component.html.HtmlSelectDate</classname>
<superclass>org.jboss.seam.ui.component.UISelectDate</superclass>
<description>
- <![CDATA[Deprecated. You should use <rich:calendar /> instead.]]>
+ <![CDATA[Deprecated. You should use <rich:calendar /> instead.]]>
</description>
<renderer generate="false" override="false">
<name>org.jboss.seam.ui.SelectDateRenderer</name>
<classname>org.jboss.seam.ui.renderkit.SelectDateRendererBase</classname>
- <!--<template>org/jboss/seam/ui/htmlSelectDate.jspx</template>-->
</renderer>
<tag>
<name>selectDate</name>
Modified: trunk/ui/src/main/config/component/selection.xml
===================================================================
--- trunk/ui/src/main/config/component/selection.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/selection.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,8 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlSelection</classname>
<superclass>org.jboss.seam.ui.component.UISelection</superclass>
<description>
- <![CDATA[
- ]]>
+ <![CDATA[]]>
</description>
<tag>
<name>selection</name>
Modified: trunk/ui/src/main/config/component/transformImageBlur.xml
===================================================================
--- trunk/ui/src/main/config/component/transformImageBlur.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/transformImageBlur.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlTransformImageBlur</classname>
<superclass>org.jboss.seam.ui.graphicImage.UITransformImageBlur</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Nested in a s:graphicImage. Transform an image by applying a blur]]>
</description>
<tag>
<name>transformImageBlur</name>
@@ -20,7 +20,7 @@
<property>
<name>radius</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>The radius of the blur (essentially the ammount of blur)</description>
</property>
</component>
</components>
Modified: trunk/ui/src/main/config/component/transformImageSize.xml
===================================================================
--- trunk/ui/src/main/config/component/transformImageSize.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/transformImageSize.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlTransformImageSize</classname>
<superclass>org.jboss.seam.ui.graphicImage.UITransformImageSize</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Nested in a s:graphicImage. Transform an image by altering the size]]>
</description>
<tag>
<name>transformImageSize</name>
@@ -20,22 +20,22 @@
<property>
<name>maintainRatio</name>
<classname>boolean</classname>
- <description></description>
+ <description>If true, don't alter the ratio of the image. In this case only height or width should be specificed.</description>
</property>
<property>
<name>width</name>
<classname>java.lang.Integer</classname>
- <description></description>
+ <description>The new width of the image</description>
</property>
<property>
<name>height</name>
<classname>java.lang.Integer</classname>
- <description></description>
+ <description>The new height of the image</description>
</property>
<property>
<name>factor</name>
<classname>java.lang.Double</classname>
- <description></description>
+ <description>Change the size of the image by a fraction. If factor is specified, height, width and maintainRatio should not be specified</description>
</property>
</component>
</components>
Modified: trunk/ui/src/main/config/component/transformImageType.xml
===================================================================
--- trunk/ui/src/main/config/component/transformImageType.xml 2008-03-13 07:37:22 UTC (rev 7553)
+++ trunk/ui/src/main/config/component/transformImageType.xml 2008-03-13 10:41:16 UTC (rev 7554)
@@ -7,7 +7,7 @@
<classname>org.jboss.seam.ui.component.html.HtmlTransformImageType</classname>
<superclass>org.jboss.seam.ui.graphicImage.UITransformImageType</superclass>
<description>
- <![CDATA[]]>
+ <![CDATA[Nested in a s:graphicImage. Transform an image by changing it's type]]>
</description>
<tag>
<name>transformImageType</name>
@@ -20,7 +20,7 @@
<property>
<name>contentType</name>
<classname>java.lang.String</classname>
- <description></description>
+ <description>The mime type of the output image</description>
</property>
</component>
</components>
18 years, 1 month
Seam SVN: r7553 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-03-13 03:37:22 -0400 (Thu, 13 Mar 2008)
New Revision: 7553
Modified:
trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
Log:
added roleExists(), deleteUser(), improved config
Modified: trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java 2008-03-13 06:38:14 UTC (rev 7552)
+++ trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java 2008-03-13 07:37:22 UTC (rev 7553)
@@ -54,6 +54,12 @@
private boolean roleAttributeIsDN = true;
private String roleNameAttribute = "cn";
+
+ private String objectClassAttribute = "objectClass";
+
+ private String roleObjectClass = "organizationalRole";
+
+ private String userObjectClass = "person";
public String getServerAddress()
{
@@ -165,6 +171,36 @@
this.roleNameAttribute = roleNameAttribute;
}
+ public String getObjectClassAttribute()
+ {
+ return objectClassAttribute;
+ }
+
+ public void setObjectClassAttribute(String objectClassAttribute)
+ {
+ this.objectClassAttribute = objectClassAttribute;
+ }
+
+ public String getRoleObjectClass()
+ {
+ return roleObjectClass;
+ }
+
+ public void setRoleObjectClass(String roleObjectClass)
+ {
+ this.roleObjectClass = roleObjectClass;
+ }
+
+ public String getUserObjectClass()
+ {
+ return userObjectClass;
+ }
+
+ public void setUserObjectClass(String userObjectClass)
+ {
+ this.userObjectClass = userObjectClass;
+ }
+
public int getFeatures()
{
return featureSet.getFeatures();
@@ -183,7 +219,7 @@
protected final InitialLdapContext initialiseContext()
throws NamingException
{
- return initialiseContext(bindDN, bindCredentials);
+ return initialiseContext(getBindDN(), getBindCredentials());
}
protected final InitialLdapContext initialiseContext(String principal, String credentials)
@@ -240,16 +276,16 @@
Attributes roleAttribs = new BasicAttributes();
- BasicAttribute roleClass = new BasicAttribute("objectClass");
- roleClass.add("organizationalRole");
+ BasicAttribute roleClass = new BasicAttribute(getObjectClassAttribute());
+ roleClass.add(getRoleObjectClass());
- BasicAttribute roleName = new BasicAttribute(roleNameAttribute);
+ BasicAttribute roleName = new BasicAttribute(getRoleNameAttribute());
roleName.add(role);
roleAttribs.put(roleClass);
roleAttribs.put(roleName);
- String roleDN = String.format("%s=%s,%s", getRoleNameAttribute(), role, roleContextDN);
+ String roleDN = String.format("%s=%s,%s", getRoleNameAttribute(), role, getRoleContextDN() );
ctx.createSubcontext(roleDN, roleAttribs);
return true;
@@ -273,21 +309,93 @@
{
ctx = initialiseContext();
- String roleDN = String.format("%s=%s,%s", getRoleNameAttribute(), role, roleContextDN);
+ String roleDN = String.format("%s=%s,%s", getRoleNameAttribute(), role, getRoleContextDN() );
ctx.destroySubcontext(roleDN);
return true;
}
catch (NamingException ex)
{
- throw new IdentityManagementException("Failed to create role", ex);
+ throw new IdentityManagementException("Failed to delete role", ex);
}
}
+
+ public boolean roleExists(String role)
+ {
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ int searchScope = SearchControls.SUBTREE_SCOPE;
+ int searchTimeLimit = 10000;
+
+ String[] roleAttr = { getRoleNameAttribute() };
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(searchScope);
+ controls.setReturningAttributes(roleAttr);
+ controls.setTimeLimit(searchTimeLimit);
+
+ // TODO make these configurable
+ String roleFilter = "(&(" + getObjectClassAttribute() + "={0})(" + getRoleNameAttribute() + "={1}))";
+ Object[] filterArgs = { getRoleObjectClass(), role};
+
+ NamingEnumeration answer = ctx.search(getRoleContextDN(), roleFilter, filterArgs, controls);
+ while (answer.hasMore())
+ {
+ SearchResult sr = (SearchResult) answer.next();
+ Attributes attrs = sr.getAttributes();
+ Attribute user = attrs.get( getRoleNameAttribute() );
+
+ for (int i = 0; i < user.size(); i++)
+ {
+ Object value = user.get(i);
+ if (role.equals(value)) return true;
+ }
+ }
+ answer.close();
+ return false;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Error getting roles", ex);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
+ }
+
public boolean deleteUser(String name)
{
- // TODO Auto-generated method stub
- return false;
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ String userDN = getUserDN(name);
+ ctx.destroySubcontext(userDN);
+ return true;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Failed to delete user", ex);
+ }
}
+
+ public boolean isUserEnabled(String name)
+ {
+ // TODO implement this somehow
+ return true;
+ }
public boolean disableUser(String name)
{
@@ -310,7 +418,7 @@
{
ctx = initialiseContext();
- String roleFilter = "(uid={0})";
+ String userFilter = "(uid={0})";
// TODO make configurable
int searchScope = SearchControls.SUBTREE_SCOPE;
@@ -324,7 +432,7 @@
controls.setTimeLimit(searchTimeLimit);
Object[] filterArgs = {name};
- NamingEnumeration answer = ctx.search(userContextDN, roleFilter, filterArgs, controls);
+ NamingEnumeration answer = ctx.search(getUserContextDN(), userFilter, filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
@@ -334,7 +442,7 @@
{
Object value = roles.get(r);
String roleName = null;
- if (roleAttributeIsDN == true)
+ if (getRoleAttributeIsDN() == true)
{
String roleDN = value.toString();
String[] returnAttribute = {getRoleNameAttribute()};
@@ -395,12 +503,12 @@
// TODO Auto-generated method stub
return false;
}
-
- public boolean isUserEnabled(String name)
+
+ public boolean revokeRole(String name, String role)
{
- // TODO implement this somehow
- return true;
- }
+ // TODO Auto-generated method stub
+ return false;
+ }
public List<String> listRoles()
{
@@ -422,11 +530,10 @@
controls.setReturningAttributes(roleAttr);
controls.setTimeLimit(searchTimeLimit);
- // TODO make these configurable
- String roleFilter = "(objectClass={0})";
- Object[] filterArgs = {"organizationalRole"};
+ String roleFilter = "(" + getObjectClassAttribute() + "={0})";
+ Object[] filterArgs = { getRoleObjectClass() };
- NamingEnumeration answer = ctx.search(roleContextDN, roleFilter, filterArgs, controls);
+ NamingEnumeration answer = ctx.search( getRoleContextDN(), roleFilter, filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
@@ -482,10 +589,10 @@
controls.setTimeLimit(searchTimeLimit);
// TODO make these configurable
- String userFilter = "(objectClass={0})";
- Object[] filterArgs = {"person"};
+ String userFilter = "(" + getObjectClassAttribute() + "={0})";
+ Object[] filterArgs = { getUserObjectClass() };
- NamingEnumeration answer = ctx.search(userContextDN, userFilter, filterArgs, controls);
+ NamingEnumeration answer = ctx.search(getUserContextDN(), userFilter, filterArgs, controls);
while (answer.hasMore())
{
SearchResult sr = (SearchResult) answer.next();
@@ -524,17 +631,6 @@
return null;
}
- public boolean revokeRole(String name, String role)
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean roleExists(String name)
- {
- return false;
- }
-
public boolean userExists(String name)
{
// TODO Auto-generated method stub
18 years, 1 month
Seam SVN: r7552 - trunk/src/main/org/jboss/seam/security/permission.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-03-13 02:38:14 -0400 (Thu, 13 Mar 2008)
New Revision: 7552
Added:
trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java
trunk/src/main/org/jboss/seam/security/permission/JPAPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java
Modified:
trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java
Log:
groundwork for dynamic permissions
Added: trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java 2008-03-13 06:38:14 UTC (rev 7552)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.permission;
+
+/**
+ * Abstract base class for persistence of user/role permissions. This class should be extended
+ * to create a concrete JPA/Hibernate implementation.
+ *
+ * @author Shane Bryzak
+ */
+public abstract class AccountPermission
+{
+ public enum AccountType {user, role}
+
+ public abstract String getTarget();
+ public abstract void setTarget(String target);
+
+ public abstract String getAction();
+ public abstract void setAction(String action);
+
+ public abstract String getAccount();
+ public abstract void setAccount(String account);
+
+ public abstract AccountType getAccountType();
+ public abstract void setAccountType(AccountType accountType);
+}
Modified: trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java 2008-03-13 06:28:43 UTC (rev 7551)
+++ trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java 2008-03-13 06:38:14 UTC (rev 7552)
@@ -26,6 +26,6 @@
{
public boolean hasPermission(Object target, String action)
{
- return true;
+ return false;
}
}
Added: trunk/src/main/org/jboss/seam/security/permission/JPAPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/JPAPermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/JPAPermissionStore.java 2008-03-13 06:38:14 UTC (rev 7552)
@@ -0,0 +1,42 @@
+package org.jboss.seam.security.permission;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import java.util.List;
+
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.security.permission.AccountPermission.AccountType;
+
+/**
+ * A permission store implementation that uses JPA as its persistence mechanism.
+ *
+ * @author Shane Bryzak
+ */
+@Scope(APPLICATION)
+@BypassInterceptors
+public class JPAPermissionStore implements PermissionStore
+{
+ public boolean grantPermission(String target, String action, String account,
+ AccountType accountType)
+ {
+ return false;
+ }
+
+ public List<AccountPermission> listPermissions(String target, String action)
+ {
+ return null;
+ }
+
+ public List<AccountPermission> listPermissions(String target)
+ {
+ return null;
+ }
+
+ public boolean revokePermission(String target, String action,
+ String account, AccountType accountType)
+ {
+ return false;
+ }
+
+}
Added: trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java 2008-03-13 06:38:14 UTC (rev 7552)
@@ -0,0 +1,19 @@
+package org.jboss.seam.security.permission;
+
+import java.util.List;
+
+import org.jboss.seam.security.permission.AccountPermission.AccountType;
+
+/**
+ * Persistent store for user/role permissions
+ *
+ * @author Shane Bryzak
+ */
+public interface PermissionStore
+{
+ List<AccountPermission> listPermissions(String target, String action);
+ List<AccountPermission> listPermissions(String target);
+
+ boolean grantPermission(String target, String action, String account, AccountType accountType);
+ boolean revokePermission(String target, String action, String account, AccountType accountType);
+}
18 years, 1 month
Seam SVN: r7551 - trunk/seam-gen/resources.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-03-13 02:28:43 -0400 (Thu, 13 Mar 2008)
New Revision: 7551
Modified:
trunk/seam-gen/resources/security.drl
Log:
updated package
Modified: trunk/seam-gen/resources/security.drl
===================================================================
--- trunk/seam-gen/resources/security.drl 2008-03-13 04:32:39 UTC (rev 7550)
+++ trunk/seam-gen/resources/security.drl 2008-03-13 06:28:43 UTC (rev 7551)
@@ -2,5 +2,5 @@
import java.security.Principal;
-import org.jboss.seam.security.PermissionCheck;
+import org.jboss.seam.security.permission.PermissionCheck;
import org.jboss.seam.security.Role;
\ No newline at end of file
18 years, 1 month
Seam SVN: r7550 - in trunk/src/main/org/jboss/seam: security and 2 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-03-13 00:32:39 -0400 (Thu, 13 Mar 2008)
New Revision: 7550
Added:
trunk/src/main/org/jboss/seam/security/permission/
trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java
trunk/src/main/org/jboss/seam/security/permission/PermissionMapper.java
trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java
trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Removed:
trunk/src/main/org/jboss/seam/security/DynamicPermissionResolver.java
trunk/src/main/org/jboss/seam/security/PermissionCheck.java
trunk/src/main/org/jboss/seam/security/PermissionMapper.java
trunk/src/main/org/jboss/seam/security/PermissionResolver.java
trunk/src/main/org/jboss/seam/security/ResolverChain.java
trunk/src/main/org/jboss/seam/security/RuleBasedPermissionResolver.java
Modified:
trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java
trunk/src/main/org/jboss/seam/security/Identity.java
trunk/src/main/org/jboss/seam/security/management/IdentityStore.java
Log:
refactored
Modified: trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/init/ComponentDescriptor.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -8,7 +8,7 @@
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.core.Init;
-import org.jboss.seam.security.PermissionResolver;
+import org.jboss.seam.security.permission.PermissionResolver;
import org.jboss.seam.web.AbstractResource;
/**
Deleted: trunk/src/main/org/jboss/seam/security/DynamicPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/DynamicPermissionResolver.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/DynamicPermissionResolver.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -1,17 +0,0 @@
-package org.jboss.seam.security;
-
-import java.io.Serializable;
-
-/**
- * Resolves permissions dynamically assigned in a peristent store, such as a
- * database, for example.
- *
- * @author Shane Bryzak
- */
-public class DynamicPermissionResolver implements PermissionResolver, Serializable
-{
- public boolean hasPermission(Object target, String action)
- {
- return true;
- }
-}
Modified: trunk/src/main/org/jboss/seam/security/Identity.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/Identity.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/Identity.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -39,6 +39,7 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.persistence.PersistenceProvider;
+import org.jboss.seam.security.permission.PermissionMapper;
import org.jboss.seam.util.Strings;
import org.jboss.seam.web.Session;
Deleted: trunk/src/main/org/jboss/seam/security/PermissionCheck.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/PermissionCheck.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/PermissionCheck.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -1,62 +0,0 @@
-package org.jboss.seam.security;
-
-/**
- * Used to assert permission requirements into a WorkingMemory when evaluating
- * a @Restrict expression. The consequence of the rule is responsible for
- * granting the permission.
- *
- * @author Shane Bryzak
- */
-public class PermissionCheck
-{
- private Object target;
-
- @Deprecated
- private String name;
-
- private String action;
- private boolean granted;
-
- public PermissionCheck(Object target, String action)
- {
- if (target instanceof String)
- {
- this.name = (String) target;
- }
-
- this.target = target;
- this.action = action;
- granted = false;
- }
-
- public Object getTarget()
- {
- return target;
- }
-
- @Deprecated
- public String getName()
- {
- return name;
- }
-
- public String getAction()
- {
- return action;
- }
-
- public void grant()
- {
- this.granted = true;
- }
-
- public void revoke()
- {
- this.granted = false;
- }
-
- public boolean isGranted()
- {
- return granted;
- }
-}
Deleted: trunk/src/main/org/jboss/seam/security/PermissionMapper.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/PermissionMapper.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/PermissionMapper.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -1,118 +0,0 @@
-package org.jboss.seam.security;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Init;
-
-/**
- * Maps permission checks to resolver chains
- *
- * @author Shane Bryzak
- */
-@Scope(APPLICATION)
-@Name("org.jboss.seam.security.permissionMapper")
-@Install(precedence = BUILT_IN)
-@BypassInterceptors
-@Startup
-public class PermissionMapper
-{
- private Map<Class,Map<String,String>> resolverChains = new HashMap<Class,Map<String,String>>();
-
- private String defaultResolverChain;
-
- private static final String DEFAULT_RESOLVER_CHAIN = "org.jboss.seam.security.defaultResolverChain";
-
- private ResolverChain getResolverChain(Object target, String action)
- {
- Class targetClass = null;
-
- if (target instanceof Class)
- {
- targetClass = (Class) target;
- }
- else
- {
- // TODO target may be a component name, or an object, or a view name (or arbitrary name) -
- // we need to deal with all of these possibilities
- }
-
- if (targetClass != null)
- {
- Map<String,String> chains = resolverChains.get(target);
- if (chains != null && chains.containsKey(action))
- {
- return (ResolverChain) Component.getInstance(chains.get(action), true);
- }
- }
-
- if (defaultResolverChain != null && !"".equals(defaultResolverChain))
- {
- return (ResolverChain) Component.getInstance(defaultResolverChain, true);
- }
-
- return createDefaultResolverChain();
- }
-
- public boolean resolvePermission(Object target, String action)
- {
- ResolverChain chain = getResolverChain(target, action);
- for (PermissionResolver resolver : chain.getResolvers())
- {
- if (resolver.hasPermission(target, action))
- {
- return true;
- }
- }
-
- return false;
- }
-
- private ResolverChain createDefaultResolverChain()
- {
- ResolverChain chain = (ResolverChain) Contexts.getSessionContext().get(DEFAULT_RESOLVER_CHAIN);
-
- if (chain == null)
- {
- chain = new ResolverChain();
-
- for (String resolverName : Init.instance().getPermissionResolvers())
- {
- chain.getResolvers().add((PermissionResolver) Component.getInstance(resolverName, true));
- }
-
- Contexts.getSessionContext().set(DEFAULT_RESOLVER_CHAIN, chain);
- }
-
- return chain;
- }
-
- public static PermissionMapper instance()
- {
- if ( !Contexts.isApplicationContextActive() )
- {
- throw new IllegalStateException("No active application context");
- }
-
- PermissionMapper instance = (PermissionMapper) Component.getInstance(
- PermissionMapper.class, ScopeType.APPLICATION);
-
- if (instance == null)
- {
- throw new IllegalStateException("No PermissionMapper could be created");
- }
-
- return instance;
- }
-}
Deleted: trunk/src/main/org/jboss/seam/security/PermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/PermissionResolver.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/PermissionResolver.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -1,6 +0,0 @@
-package org.jboss.seam.security;
-
-public interface PermissionResolver
-{
- boolean hasPermission(Object target, String action);
-}
Deleted: trunk/src/main/org/jboss/seam/security/ResolverChain.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/ResolverChain.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/ResolverChain.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -1,26 +0,0 @@
-package org.jboss.seam.security;
-
-import static org.jboss.seam.ScopeType.SESSION;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-
-@Scope(SESSION)
-@BypassInterceptors
-public class ResolverChain
-{
- private List<PermissionResolver> resolvers = new ArrayList<PermissionResolver>();
-
- public List<PermissionResolver> getResolvers()
- {
- return resolvers;
- }
-
- public void setResolvers(List<PermissionResolver> resolvers)
- {
- this.resolvers = resolvers;
- }
-}
Deleted: trunk/src/main/org/jboss/seam/security/RuleBasedPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/RuleBasedPermissionResolver.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/RuleBasedPermissionResolver.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -1,246 +0,0 @@
-package org.jboss.seam.security;
-
-import static org.jboss.seam.ScopeType.SESSION;
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import java.io.Serializable;
-import java.security.Principal;
-import java.security.acl.Group;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-
-import org.drools.FactHandle;
-import org.drools.RuleBase;
-import org.drools.StatefulSession;
-import org.drools.base.ClassObjectFilter;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.security.management.JpaIdentityStore;
-import org.jboss.seam.security.management.UserAccount;
-
-@Name("org.jboss.seam.security.ruleBasedPermissionResolver")
-@Scope(SESSION)
-@BypassInterceptors
-@Install(precedence=FRAMEWORK, classDependencies="org.drools.WorkingMemory")
-@Startup
-public class RuleBasedPermissionResolver implements PermissionResolver, Serializable
-{
- public static final String RULES_COMPONENT_NAME = "securityRules";
-
- private static final LogProvider log = Logging.getLogProvider(RuleBasedPermissionResolver.class);
-
- private StatefulSession securityContext;
-
- private RuleBase securityRules;
-
- @Create
- public boolean create()
- {
- initSecurityContext();
- return getSecurityContext() != null;
- }
-
- protected void initSecurityContext()
- {
- if (getSecurityRules() == null)
- {
- setSecurityRules((RuleBase) Component.getInstance(RULES_COMPONENT_NAME, true));
- }
-
- if (getSecurityRules() != null)
- {
- setSecurityContext(getSecurityRules().newStatefulSession(false));
- }
-
- if (getSecurityContext() == null)
- {
- log.warn("no security rule base available - please install a RuleBase with the name '" +
- RULES_COMPONENT_NAME + "' if permission checks are required.");
- }
- }
-
- @Observer(Identity.EVENT_POST_AUTHENTICATE)
- public void postAuthenticate()
- {
- if (getSecurityContext() != null)
- {
- getSecurityContext().insert(Identity.instance().getPrincipal());
- }
- }
-
- /**
- * Performs a permission check for the specified name and action
- *
- * @param target Object The target of the permission check
- * @param action String The action to be performed on the target
- * @return boolean True if the user has the specified permission
- */
- public boolean hasPermission(Object target, String action)
- {
- StatefulSession securityContext = getSecurityContext();
-
- if (securityContext == null) return false;
-
- List<FactHandle> handles = new ArrayList<FactHandle>();
-
- if (!(target instanceof String) && !(target instanceof Class))
- {
- handles.add( securityContext.insert(target) );
- }
-
- 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 )
- {
- synchronizeContext();
-
- handles.add( securityContext.insert(check) );
-
- securityContext.fireAllRules();
-
- for (FactHandle handle : handles)
- securityContext.retract(handle);
- }
-
- return check.isGranted();
- }
-
- @SuppressWarnings("unchecked")
- @Observer(Identity.EVENT_LOGGED_OUT)
- public void unAuthenticate()
- {
- if (getSecurityContext() != null)
- {
- getSecurityContext().dispose();
- setSecurityContext(null);
- }
- initSecurityContext();
- }
-
- /**
- * Synchronises the state of the security context with that of the subject
- */
- private void synchronizeContext()
- {
- Identity identity = Identity.instance();
-
- getSecurityContext().insert(identity.getPrincipal());
-
- if (getSecurityContext() != null)
- {
- for ( Group sg : identity.getSubject().getPrincipals(Group.class) )
- {
- if ( Identity.ROLES_GROUP.equals( sg.getName() ) )
- {
- Enumeration e = sg.members();
- while (e.hasMoreElements())
- {
- Principal role = (Principal) e.nextElement();
-
- boolean found = false;
- Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
- while (iter.hasNext())
- {
- Role r = iter.next();
- if (r.getName().equals(role.getName()))
- {
- found = true;
- break;
- }
- }
-
- if (!found)
- {
- getSecurityContext().insert(new Role(role.getName()));
- }
-
- }
- }
- }
-
- Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
- while (iter.hasNext())
- {
- Role r = iter.next();
- if (!identity.hasRole(r.getName()))
- {
- FactHandle fh = getSecurityContext().getFactHandle(r);
- getSecurityContext().retract(fh);
- }
- }
- }
- }
-
-
- public StatefulSession getSecurityContext()
- {
- return securityContext;
- }
-
- public void setSecurityContext(StatefulSession securityContext)
- {
- this.securityContext = securityContext;
- }
-
-
- public RuleBase getSecurityRules()
- {
- return securityRules;
- }
-
- public void setSecurityRules(RuleBase securityRules)
- {
- this.securityRules = securityRules;
- }
-
- public static RuleBasedPermissionResolver instance()
- {
- if ( !Contexts.isSessionContextActive() )
- {
- throw new IllegalStateException("No active session context");
- }
-
- RuleBasedPermissionResolver instance = (RuleBasedPermissionResolver) Component.getInstance(
- RuleBasedPermissionResolver.class, ScopeType.SESSION);
-
- if (instance == null)
- {
- throw new IllegalStateException("No RuleBasedPermissionResolver could be created");
- }
-
- return instance;
- }
-
- /**
- * If we were authenticated with the JpaIdentityStore, then insert the authenticated
- * UserAccount into the security context.
- */
- @Observer(Identity.EVENT_POST_AUTHENTICATE)
- public void setUserAccountInSecurityContext()
- {
- if (Contexts.isEventContextActive() && Contexts.isSessionContextActive() &&
- Contexts.getEventContext().isSet(JpaIdentityStore.AUTHENTICATED_USER))
- {
- getSecurityContext().insert(Contexts.getEventContext().get(JpaIdentityStore.AUTHENTICATED_USER));
- }
- }
-}
Modified: trunk/src/main/org/jboss/seam/security/management/IdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/IdentityStore.java 2008-03-13 01:11:48 UTC (rev 7549)
+++ trunk/src/main/org/jboss/seam/security/management/IdentityStore.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -43,12 +43,6 @@
this.features = features;
}
- public FeatureSet addFeature(int feature)
- {
- features |= feature;
- return this;
- }
-
public int getFeatures()
{
return features;
Added: trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -0,0 +1,31 @@
+package org.jboss.seam.security.permission;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.Serializable;
+
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+
+/**
+ * Resolves permissions dynamically assigned in a persistent store, such as a
+ * database, for example.
+ *
+ * @author Shane Bryzak
+ */
+@Name("org.jboss.seam.security.dynamicPermissionResolver")
+@Scope(APPLICATION)
+@BypassInterceptors
+@Install(precedence=FRAMEWORK)
+@Startup
+public class DynamicPermissionResolver implements PermissionResolver, Serializable
+{
+ public boolean hasPermission(Object target, String action)
+ {
+ return true;
+ }
+}
Added: trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionCheck.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -0,0 +1,62 @@
+package org.jboss.seam.security.permission;
+
+/**
+ * Used to assert permission requirements into a WorkingMemory when evaluating
+ * a @Restrict expression. The consequence of the rule is responsible for
+ * granting the permission.
+ *
+ * @author Shane Bryzak
+ */
+public class PermissionCheck
+{
+ private Object target;
+
+ @Deprecated
+ private String name;
+
+ private String action;
+ private boolean granted;
+
+ public PermissionCheck(Object target, String action)
+ {
+ if (target instanceof String)
+ {
+ this.name = (String) target;
+ }
+
+ this.target = target;
+ this.action = action;
+ granted = false;
+ }
+
+ public Object getTarget()
+ {
+ return target;
+ }
+
+ @Deprecated
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getAction()
+ {
+ return action;
+ }
+
+ public void grant()
+ {
+ this.granted = true;
+ }
+
+ public void revoke()
+ {
+ this.granted = false;
+ }
+
+ public boolean isGranted()
+ {
+ return granted;
+ }
+}
Added: trunk/src/main/org/jboss/seam/security/permission/PermissionMapper.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionMapper.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionMapper.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -0,0 +1,118 @@
+package org.jboss.seam.security.permission;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Init;
+
+/**
+ * Maps permission checks to resolver chains
+ *
+ * @author Shane Bryzak
+ */
+@Scope(APPLICATION)
+@Name("org.jboss.seam.security.permissionMapper")
+@Install(precedence = BUILT_IN)
+@BypassInterceptors
+@Startup
+public class PermissionMapper
+{
+ private Map<Class,Map<String,String>> resolverChains = new HashMap<Class,Map<String,String>>();
+
+ private String defaultResolverChain;
+
+ private static final String DEFAULT_RESOLVER_CHAIN = "org.jboss.seam.security.defaultResolverChain";
+
+ private ResolverChain getResolverChain(Object target, String action)
+ {
+ Class targetClass = null;
+
+ if (target instanceof Class)
+ {
+ targetClass = (Class) target;
+ }
+ else
+ {
+ // TODO target may be a component name, or an object, or a view name (or arbitrary name) -
+ // we need to deal with all of these possibilities
+ }
+
+ if (targetClass != null)
+ {
+ Map<String,String> chains = resolverChains.get(target);
+ if (chains != null && chains.containsKey(action))
+ {
+ return (ResolverChain) Component.getInstance(chains.get(action), true);
+ }
+ }
+
+ if (defaultResolverChain != null && !"".equals(defaultResolverChain))
+ {
+ return (ResolverChain) Component.getInstance(defaultResolverChain, true);
+ }
+
+ return createDefaultResolverChain();
+ }
+
+ public boolean resolvePermission(Object target, String action)
+ {
+ ResolverChain chain = getResolverChain(target, action);
+ for (PermissionResolver resolver : chain.getResolvers())
+ {
+ if (resolver.hasPermission(target, action))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private ResolverChain createDefaultResolverChain()
+ {
+ ResolverChain chain = (ResolverChain) Contexts.getSessionContext().get(DEFAULT_RESOLVER_CHAIN);
+
+ if (chain == null)
+ {
+ chain = new ResolverChain();
+
+ for (String resolverName : Init.instance().getPermissionResolvers())
+ {
+ chain.getResolvers().add((PermissionResolver) Component.getInstance(resolverName, true));
+ }
+
+ Contexts.getSessionContext().set(DEFAULT_RESOLVER_CHAIN, chain);
+ }
+
+ return chain;
+ }
+
+ public static PermissionMapper instance()
+ {
+ if ( !Contexts.isApplicationContextActive() )
+ {
+ throw new IllegalStateException("No active application context");
+ }
+
+ PermissionMapper instance = (PermissionMapper) Component.getInstance(
+ PermissionMapper.class, ScopeType.APPLICATION);
+
+ if (instance == null)
+ {
+ throw new IllegalStateException("No PermissionMapper could be created");
+ }
+
+ return instance;
+ }
+}
Added: trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -0,0 +1,6 @@
+package org.jboss.seam.security.permission;
+
+public interface PermissionResolver
+{
+ boolean hasPermission(Object target, String action);
+}
Added: trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -0,0 +1,26 @@
+package org.jboss.seam.security.permission;
+
+import static org.jboss.seam.ScopeType.SESSION;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+
+@Scope(SESSION)
+@BypassInterceptors
+public class ResolverChain
+{
+ private List<PermissionResolver> resolvers = new ArrayList<PermissionResolver>();
+
+ public List<PermissionResolver> getResolvers()
+ {
+ return resolvers;
+ }
+
+ public void setResolvers(List<PermissionResolver> resolvers)
+ {
+ this.resolvers = resolvers;
+ }
+}
Added: trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2008-03-13 04:32:39 UTC (rev 7550)
@@ -0,0 +1,247 @@
+package org.jboss.seam.security.permission;
+
+import static org.jboss.seam.ScopeType.SESSION;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.Serializable;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.FactHandle;
+import org.drools.RuleBase;
+import org.drools.StatefulSession;
+import org.drools.base.ClassObjectFilter;
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.Seam;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.contexts.Contexts;
+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.management.JpaIdentityStore;
+
+@Name("org.jboss.seam.security.ruleBasedPermissionResolver")
+@Scope(SESSION)
+@BypassInterceptors
+@Install(precedence=FRAMEWORK, classDependencies="org.drools.WorkingMemory")
+@Startup
+public class RuleBasedPermissionResolver implements PermissionResolver, Serializable
+{
+ public static final String RULES_COMPONENT_NAME = "securityRules";
+
+ private static final LogProvider log = Logging.getLogProvider(RuleBasedPermissionResolver.class);
+
+ private StatefulSession securityContext;
+
+ private RuleBase securityRules;
+
+ @Create
+ public boolean create()
+ {
+ initSecurityContext();
+ return getSecurityContext() != null;
+ }
+
+ protected void initSecurityContext()
+ {
+ if (getSecurityRules() == null)
+ {
+ setSecurityRules((RuleBase) Component.getInstance(RULES_COMPONENT_NAME, true));
+ }
+
+ if (getSecurityRules() != null)
+ {
+ setSecurityContext(getSecurityRules().newStatefulSession(false));
+ }
+
+ if (getSecurityContext() == null)
+ {
+ log.warn("no security rule base available - please install a RuleBase with the name '" +
+ RULES_COMPONENT_NAME + "' if permission checks are required.");
+ }
+ }
+
+ @Observer(Identity.EVENT_POST_AUTHENTICATE)
+ public void postAuthenticate()
+ {
+ if (getSecurityContext() != null)
+ {
+ getSecurityContext().insert(Identity.instance().getPrincipal());
+ }
+ }
+
+ /**
+ * Performs a permission check for the specified name and action
+ *
+ * @param target Object The target of the permission check
+ * @param action String The action to be performed on the target
+ * @return boolean True if the user has the specified permission
+ */
+ public boolean hasPermission(Object target, String action)
+ {
+ StatefulSession securityContext = getSecurityContext();
+
+ if (securityContext == null) return false;
+
+ List<FactHandle> handles = new ArrayList<FactHandle>();
+
+ if (!(target instanceof String) && !(target instanceof Class))
+ {
+ handles.add( securityContext.insert(target) );
+ }
+
+ 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 )
+ {
+ synchronizeContext();
+
+ handles.add( securityContext.insert(check) );
+
+ securityContext.fireAllRules();
+
+ for (FactHandle handle : handles)
+ securityContext.retract(handle);
+ }
+
+ return check.isGranted();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Observer(Identity.EVENT_LOGGED_OUT)
+ public void unAuthenticate()
+ {
+ if (getSecurityContext() != null)
+ {
+ getSecurityContext().dispose();
+ setSecurityContext(null);
+ }
+ initSecurityContext();
+ }
+
+ /**
+ * Synchronises the state of the security context with that of the subject
+ */
+ private void synchronizeContext()
+ {
+ Identity identity = Identity.instance();
+
+ getSecurityContext().insert(identity.getPrincipal());
+
+ if (getSecurityContext() != null)
+ {
+ for ( Group sg : identity.getSubject().getPrincipals(Group.class) )
+ {
+ if ( Identity.ROLES_GROUP.equals( sg.getName() ) )
+ {
+ Enumeration e = sg.members();
+ while (e.hasMoreElements())
+ {
+ Principal role = (Principal) e.nextElement();
+
+ boolean found = false;
+ Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
+ while (iter.hasNext())
+ {
+ Role r = iter.next();
+ if (r.getName().equals(role.getName()))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ getSecurityContext().insert(new Role(role.getName()));
+ }
+
+ }
+ }
+ }
+
+ Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
+ while (iter.hasNext())
+ {
+ Role r = iter.next();
+ if (!identity.hasRole(r.getName()))
+ {
+ FactHandle fh = getSecurityContext().getFactHandle(r);
+ getSecurityContext().retract(fh);
+ }
+ }
+ }
+ }
+
+
+ public StatefulSession getSecurityContext()
+ {
+ return securityContext;
+ }
+
+ public void setSecurityContext(StatefulSession securityContext)
+ {
+ this.securityContext = securityContext;
+ }
+
+
+ public RuleBase getSecurityRules()
+ {
+ return securityRules;
+ }
+
+ public void setSecurityRules(RuleBase securityRules)
+ {
+ this.securityRules = securityRules;
+ }
+
+ public static RuleBasedPermissionResolver instance()
+ {
+ if ( !Contexts.isSessionContextActive() )
+ {
+ throw new IllegalStateException("No active session context");
+ }
+
+ RuleBasedPermissionResolver instance = (RuleBasedPermissionResolver) Component.getInstance(
+ RuleBasedPermissionResolver.class, ScopeType.SESSION);
+
+ if (instance == null)
+ {
+ throw new IllegalStateException("No RuleBasedPermissionResolver could be created");
+ }
+
+ return instance;
+ }
+
+ /**
+ * If we were authenticated with the JpaIdentityStore, then insert the authenticated
+ * UserAccount into the security context.
+ */
+ @Observer(Identity.EVENT_POST_AUTHENTICATE)
+ public void setUserAccountInSecurityContext()
+ {
+ if (Contexts.isEventContextActive() && Contexts.isSessionContextActive() &&
+ Contexts.getEventContext().isSet(JpaIdentityStore.AUTHENTICATED_USER))
+ {
+ getSecurityContext().insert(Contexts.getEventContext().get(JpaIdentityStore.AUTHENTICATED_USER));
+ }
+ }
+}
18 years, 1 month