You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-commits@incubator.apache.org by cl...@apache.org on 2005/04/05 20:55:35 UTC
svn commit: r160217 - in incubator/graffito/trunk: components/
components/src/java/org/apache/portals/graffito/security/impl/
components/src/sql/GraffitoServer/
components/src/test/org/apache/portals/graffito/security/impl/
jetspeed2-deploy/ jetspeed2-deploy/src/assembly/ jetspeed2-deploy/src/java/
jetspeed2-deploy/src/java/org/ jetspeed2-deploy/src/java/org/apache/
jetspeed2-deploy/src/java/org/apache/portals/
jetspeed2-deploy/src/java/org/apache/portals/jetspeed/
jetspeed2-deploy/src/java/org/apache/portals/jetspeed/valve/
Author: clombart
Date: Tue Apr 5 13:55:32 2005
New Revision: 160217
URL: http://svn.apache.org/viewcvs?view=rev&rev=160217
Log:
Review some security points :
* Bug fixs with the CmsPermission : "all" permission was not working correctly
* Add more unit tests for "<<ALL Files>>" and "all" permission
* Add sql script in order to init permissions for the administator : all permissions are authorised on all files. Other users cannot see the content by default. The fine grained access control will be set via the Graffito Browser Portlet.
* Add a new J2 valve : GraffitoContextValve which init the GraffioRequestContext with the request Subject. Now, The Graffito security is completly integrated with J2.
Added:
incubator/graffito/trunk/components/src/sql/GraffitoServer/delete-j2-security.sql
incubator/graffito/trunk/components/src/sql/GraffitoServer/insert-j2-security.sql
incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllFilesTestRdbmsPolicy.java
incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllPermissionTestRdbmsPolicy.java
incubator/graffito/trunk/jetspeed2-deploy/.classpath
incubator/graffito/trunk/jetspeed2-deploy/src/assembly/pipelines.xml
incubator/graffito/trunk/jetspeed2-deploy/src/java/
incubator/graffito/trunk/jetspeed2-deploy/src/java/org/
incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/
incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/
incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/jetspeed/
incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/jetspeed/valve/
incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/jetspeed/valve/GraffitoContextValve.java
Modified:
incubator/graffito/trunk/components/maven.xml
incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/AbstractSecurityTestcase.java
incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/GraffitoAction.java
incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/TestRdbmsPolicy.java
incubator/graffito/trunk/jetspeed2-deploy/maven.xml
incubator/graffito/trunk/jetspeed2-deploy/project.properties
incubator/graffito/trunk/jetspeed2-deploy/project.xml
incubator/graffito/trunk/jetspeed2-deploy/src/assembly/graffito.xml
Modified: incubator/graffito/trunk/components/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/maven.xml?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/components/maven.xml (original)
+++ incubator/graffito/trunk/components/maven.xml Tue Apr 5 13:55:32 2005
@@ -12,371 +12,299 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
- -->
-<project default="java:jar"
- xmlns:j="jelly:core"
- xmlns:define="jelly:define"
- xmlns:maven="jelly:maven"
- >
-
- <!-- ================================================================ -->
- <!-- TEST -->
- <!-- ================================================================ -->
- <preGoal name="test:test">
- <attainGoal name="dbSetup"/>
- <attainGoal name="db.reinit.test" />
- </preGoal>
-
- <goal name="dbSetup">
- <j:set var="maven.junit.sysproperties" value="${maven.junit.sysproperties} org.apache.portals.graffito.database.url org.apache.portals.graffito.database.driver org.apache.portals.graffito.database.user org.apache.portals.graffito.database.password" />
- <j:set var="org.apache.portals.graffito.database.url" value="${org.apache.portals.graffito.test.database.url}"/>
- <j:set var="org.apache.portals.graffito.database.driver" value="${org.apache.portals.graffito.test.database.driver}"/>
- <j:set var="org.apache.portals.graffito.database.user" value="${org.apache.portals.graffito.test.database.user}"/>
- <j:set var="org.apache.portals.graffito.database.password" value="${org.apache.portals.graffito.test.database.password}"/>
-
- <copy file="src/test/repository.xml" todir="${maven.test.dest}" overwrite="true" failonerror="false">
- <filterset begintoken="@" endtoken="@">
- <filter token="PLATFORM" value="${org.apache.portals.graffito.database.ojb.plateform}"/>
- </filterset>
- <filterset begintoken="@" endtoken="@">
- <filter token="DATASOURCE" value="${org.apache.portals.graffito.database.ojb.datasource}"/>
- </filterset>
- </copy>
-
- <path id="jdbc.drivers.path" path="${org.apache.portals.graffito.test.jdbc.drivers.path}"/>
- <maven:addPath id="maven.dependency.classpath" refid="jdbc.drivers.path"/>
-
- </goal>
-
-
- <!-- ================================================================ -->
- <!-- CREATE Graffito Server Master DB Script -->
- <!-- ================================================================ -->
- <goal name="db.scripts.gen" prereqs="torque:init"
- description="Build SQL scripts using Torque generator">
-
- <echo message="Generating SQL schema creation scripts for HSQLDB"/>
- <torque-sql
- basePathToDbProps="sql/base/"
- contextProperties="${torque.contextProperties}"
- controlTemplate="${torque.template.sql}"
- idTableXMLFile="${torque.idTableXMLFile}"
- outputDirectory="${maven.build.src}/sql/hsql"
- outputFile="report.${torque.project}.sql.generation"
- sqldbmap="${maven.build.src}/sql/hsql/sqldb.map"
- targetDatabase="hypersonic"
- useClasspath="true">
- <fileset dir="${torque.schema.dir}"
- includes="${torque.schema.sql.includes}"
- excludes="${torque.schema.sql.excludes}"
- />
- </torque-sql>
-
- <echo message="Generating SQL schema creation scripts for MySQL"/>
- <torque-sql
- basePathToDbProps="sql/base/"
- contextProperties="${torque.contextProperties}"
- controlTemplate="${torque.template.sql}"
- idTableXMLFile="${torque.idTableXMLFile}"
- outputDirectory="${maven.build.src}/sql/mysql"
- outputFile="report.${torque.project}.sql.generation"
- sqldbmap="${maven.build.src}/sql/mysql/sqldb.map"
- targetDatabase="mysql"
- useClasspath="true">
- <fileset dir="${torque.schema.dir}"
- includes="${torque.schema.sql.includes}"
- excludes="${torque.schema.sql.excludes}"
- />
- </torque-sql>
-
- <echo message="Generating SQL schema creation scripts for Oracle"/>
- <torque-sql
- basePathToDbProps="sql/base/"
- contextProperties="${torque.contextProperties}"
- controlTemplate="${torque.template.sql}"
- idTableXMLFile="${torque.idTableXMLFile}"
- outputDirectory="${maven.build.src}/sql/oracle"
- outputFile="report.${torque.project}.sql.generation"
- sqldbmap="${maven.build.src}/sql/oracle/sqldb.map"
- targetDatabase="oracle"
- useClasspath="true">
- <fileset dir="${torque.schema.dir}"
- includes="${torque.schema.sql.includes}"
- excludes="${torque.schema.sql.excludes}"
- />
- </torque-sql>
-
- <echo message="Generating SQL schema creation scripts for MS SQL"/>
- <torque-sql
- basePathToDbProps="sql/base/"
- contextProperties="${torque.contextProperties}"
- controlTemplate="${torque.template.sql}"
- idTableXMLFile="${torque.idTableXMLFile}"
- outputDirectory="${maven.build.src}/sql/mssql"
- outputFile="report.${torque.project}.sql.generation"
- sqldbmap="${maven.build.src}/sql/mssql/sqldb.map"
- targetDatabase="mssql"
- useClasspath="true">
- <fileset dir="${torque.schema.dir}"
- includes="${torque.schema.sql.includes}"
- excludes="${torque.schema.sql.excludes}"
- />
- </torque-sql>
-
- <echo message="Generating SQL schema creation scripts for Postgres"/>
- <torque-sql
- basePathToDbProps="sql/base/"
- contextProperties="${torque.contextProperties}"
- controlTemplate="${torque.template.sql}"
- idTableXMLFile="${torque.idTableXMLFile}"
- outputDirectory="${maven.build.src}/sql/postgres"
- outputFile="report.${torque.project}.sql.generation"
- sqldbmap="${maven.build.src}/sql/postgres/sqldb.map"
- targetDatabase="postgresql"
- useClasspath="true">
- <fileset dir="${torque.schema.dir}"
- includes="${torque.schema.sql.includes}"
- excludes="${torque.schema.sql.excludes}"
- />
- </torque-sql>
-
- </goal>
-
- <!-- ================================================================ -->
- <!-- SQL SCRIPT EXEC TEMPLATE -->
- <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
- <!-- Don't call this goal directly, call : -->
- <!-- db.create.test or db.create.production -->
- <!-- ================================================================ -->
- <goal name="db.execute">
- <sql driver="${org.apache.portals.graffito.database.driver}"
- url="${org.apache.portals.graffito.database.url}"
- userid="${org.apache.portals.graffito.database.user}"
- password="${org.apache.portals.graffito.database.password}"
- src="${database.arg.script}">
- <classpath>
- <path refid="maven.dependency.classpath"/>
- <pathelement path="${org.apache.portals.graffito.jdbc.drivers.path}"/>
- </classpath>
- </sql>
- </goal>
-
- <goal name="db.test.properties">
- <echo message="org.apache.portals.graffito.test.database.default.name : ${org.apache.portals.graffito.test.database.default.name}"/>
- <echo message="org.apache.portals.graffito.test.database.url : ${org.apache.portals.graffito.test.database.url}"/>
- <echo message="org.apache.portals.graffito.test.database.driver : ${org.apache.portals.graffito.test.database.driver}"/>
- <echo message="org.apache.portals.graffito.test.database.user : ${org.apache.portals.graffito.test.database.user}"/>
- <echo message="org.apache.portals.graffito.test.database.password : ${org.apache.portals.graffito.test.database.password}"/>
- <echo message="org.apache.portals.graffito.test.database.path : ${org.apache.portals.graffito.test.jdbc.drivers.path}"/>
- <echo message="org.apache.portals.graffito.test.jetspeed : ${org.apache.portals.graffito.test.jetspeed}"/>
-
- <j:set var="name" value="${org.apache.portals.graffito.test.database.default.name}X"/>
- <j:set var="url" value="${org.apache.portals.graffito.test.database.url}X"/>
- <j:set var="driver" value="${org.apache.portals.graffito.test.database.driver}X"/>
- <j:set var="password" value="${org.apache.portals.graffito.test.database.password}X"/>
- <j:set var="jarpath" value="${org.apache.portals.graffito.test.jdbc.drivers.path}X"/>
- <j:set var="jetspeed" value="${org.apache.portals.graffito.test.jetspeed}X"/>
-
- <j:if test="${name == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.test.database.default.name"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${url == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.test.database.url"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${driver == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.test.database.driver"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${password == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.test.database.password"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${jarpath == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.test.database.path"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${jetspeed == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.test.jetspeed"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${status == 'error'}" >
- <fail message="Impossible to continue if all Graffito build properties are not set in the build.properties defined in your USER_HOME folder"/>
- </j:if>
-
- <j:set var="org.apache.portals.graffito.database.default.name" value="${org.apache.portals.graffito.test.database.default.name}"/>
- <j:set var="org.apache.portals.graffito.database.url" value="${org.apache.portals.graffito.test.database.url}"/>
- <j:set var="org.apache.portals.graffito.database.driver" value="${org.apache.portals.graffito.test.database.driver}"/>
- <j:set var="org.apache.portals.graffito.database.user" value="${org.apache.portals.graffito.test.database.user}"/>
- <j:set var="org.apache.portals.graffito.database.password" value="${org.apache.portals.graffito.test.database.password}"/>
- <j:set var="org.apache.portals.graffito.jdbc.drivers.path" value="${org.apache.portals.graffito.test.jdbc.drivers.path}"/>
- </goal>
-
- <goal name="db.production.properties">
-
- <echo message="org.apache.portals.graffito.production.database.default.name : ${org.apache.portals.graffito.production.database.default.name}"/>
- <echo message="org.apache.portals.graffito.production.database.url : ${org.apache.portals.graffito.production.database.url}"/>
- <echo message="org.apache.portals.graffito.production.database.driver : ${org.apache.portals.graffito.production.database.driver}"/>
- <echo message="org.apache.portals.graffito.production.database.user : ${org.apache.portals.graffito.production.database.user}"/>
- <echo message="org.apache.portals.graffito.production.database.password : ${org.apache.portals.graffito.production.database.password}"/>
- <echo message="org.apache.portals.graffito.production.database.path : ${org.apache.portals.graffito.production.jdbc.drivers.path}"/>
- <echo message="org.apache.portals.graffito.production.jetspeed : ${org.apache.portals.graffito.production.jetspeed}"/>
-
- <j:set var="name" value="${org.apache.portals.graffito.production.database.default.name}X"/>
- <j:set var="url" value="${org.apache.portals.graffito.production.database.url}X"/>
- <j:set var="driver" value="${org.apache.portals.graffito.production.database.driver}X"/>
- <j:set var="password" value="${org.apache.portals.graffito.production.database.password}X"/>
- <j:set var="jarpath" value="${org.apache.portals.graffito.production.jdbc.drivers.path}X"/>
- <j:set var="jetspeed" value="${org.apache.portals.graffito.production.jetspeed}X"/>
-
- <j:if test="${name == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.production.database.default.name"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${url == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.production.database.url"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${driver == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.production.database.driver"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${password == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.production.database.password"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${jarpath == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.production.database.path"/>
- <j:set var="status" value="error"/>
- </j:if >
-
- <j:if test="${jetspeed == 'X'}">
- <echo message="No value found for the build property org.apache.portals.graffito.production.jetspeed"/>
- <j:set var="status" value="error"/>
- </j:if >
-
-
- <j:if test="${status == 'error'}" >
- <fail message="Impossible to continue if all Graffito build properties are not set in the build.properties defined in your USER_HOME folder"/>
- </j:if>
-
- <j:set var="org.apache.portals.graffito.database.default.name" value="${org.apache.portals.graffito.production.database.default.name}"/>
- <j:set var="org.apache.portals.graffito.database.url" value="${org.apache.portals.graffito.production.database.url}"/>
- <j:set var="org.apache.portals.graffito.database.driver" value="${org.apache.portals.graffito.production.database.driver}"/>
- <j:set var="org.apache.portals.graffito.database.user" value="${org.apache.portals.graffito.production.database.user}"/>
- <j:set var="org.apache.portals.graffito.database.password" value="${org.apache.portals.graffito.production.database.password}"/>
- <j:set var="org.apache.portals.graffito.jdbc.drivers.path" value="${org.apache.portals.graffito.production.jdbc.drivers.path}"/>
-
- </goal>
- <!-- ================================================================ -->
- <!-- EXECUTE CREATE DB SQL SCRIPTS -->
- <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
- <!-- ================================================================ -->
- <goal name="db.create.test">
- <attainGoal name="db.test.properties"/>
- <attainGoal name="db.create"/>
- </goal>
-
- <goal name="db.create.production">
- <attainGoal name="db.production.properties"/>
- <attainGoal name="db.create"/>
- </goal>
-
- <goal name="db.create">
-
- <j:if test="${jetspeed == 'falseX'}">
- <j:set var="database.arg.script" value="./target/src/sql/${org.apache.portals.graffito.database.default.name}/security-schema.sql" />
- <attainGoal name="db.execute" />
- <j:set var="database.arg.script" value="./target/src/sql/${org.apache.portals.graffito.database.default.name}/ojb-schema.sql" />
- <attainGoal name="db.execute" />
- </j:if>
- <j:set var="database.arg.script" value="./target/src/sql/${org.apache.portals.graffito.database.default.name}/graffitostore-schema.sql" />
- <attainGoal name="db.execute" />
- <j:set var="database.arg.script" value="./src/sql/GraffitoServer/insert-db.sql" />
- <attainGoal name="db.execute" />
- </goal>
-
- <!-- ================================================================ -->
- <!-- EXECUTE DROP DB SQL SCRIPTS -->
- <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
- <!-- ================================================================ -->
- <goal name="db.drop.test">
- <attainGoal name="db.test.properties"/>
- <attainGoal name="db.drop"/>
- </goal>
-
- <goal name="db.drop.production">
- <attainGoal name="db.production.properties"/>
- <attainGoal name="db.drop"/>
- </goal>
-
- <goal name="db.drop">
- <j:set var="database.arg.script" value="./src/sql/GraffitoServer/${org.apache.portals.graffito.database.default.name}/drop-db.sql" />
- <attainGoal name="db.execute" />
-
- <j:if test="${jetspeed == 'falseX'}">
- <j:set var="database.arg.script" value="./src/sql/GraffitoServer/${org.apache.portals.graffito.database.default.name}/drop-security.sql" />
- <attainGoal name="db.execute" />
-
- <j:set var="database.arg.script" value="./src/sql/GraffitoServer/${org.apache.portals.graffito.database.default.name}/drop-ojb.sql" />
- <attainGoal name="db.execute" />
-
- </j:if>
-
- </goal>
-
- <!-- ================================================================ -->
- <!-- EXECUTE DELETE DB SQL SCRIPTS -->
- <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
- <!-- ================================================================ -->
- <goal name="db.delete.test">
- <attainGoal name="db.test.properties"/>
- <attainGoal name="db.delete"/>
- </goal>
-
- <goal name="db.delete.production">
- <attainGoal name="db.production.properties"/>
- <attainGoal name="db.delete"/>
- </goal>
-
- <goal name="db.delete">
- <j:set var="database.arg.script" value="./src/sql/GraffitoServer/delete-db.sql" />
- <attainGoal name="db.execute" />
- </goal>
-
- <!-- ================================================================ -->
- <!-- EXECUTE DROP & CREATE DB SQL SCRIPTS -->
- <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
- <!-- ================================================================ -->
- <goal name="db.reinit.test">
- <attainGoal name="db.scripts.gen"/>
- <attainGoal name="db.test.properties"/>
- <attainGoal name="db.drop"/>
- <attainGoal name="db.create"/>
- </goal>
-
- <!-- ================================================================ -->
- <!-- Intstall Graffito services & Graffito dependencies into -->
- <!-- a deployed J2 application -->
- <!-- ================================================================ -->
-
- <goal name="deploy">
-
- <copy todir="${org.apache.jetspeed.deploy.war.dir}/jetspeed/WEB-INF/lib" overwrite="true">
- <fileset file="${basedir}/target/${maven.final.name}.jar" />
- </copy>
- </goal>
-</project>
-
-
+ -->
+<project default="java:jar" xmlns:j="jelly:core" xmlns:define="jelly:define" xmlns:maven="jelly:maven" >
+ <!-- ================================================================ -->
+ <!-- TEST -->
+ <!-- ================================================================ -->
+ <preGoal name="test:test">
+ <attainGoal name="dbSetup"/>
+ <attainGoal name="db.reinit.test" />
+ </preGoal>
+ <goal name="dbSetup">
+ <j:set var="maven.junit.sysproperties"
+ value="${maven.junit.sysproperties} org.apache.portals.graffito.database.url org.apache.portals.graffito.database.driver org.apache.portals.graffito.database.user org.apache.portals.graffito.database.password"
+ />
+ <j:set var="org.apache.portals.graffito.database.url" value="${org.apache.portals.graffito.test.database.url}"/>
+ <j:set var="org.apache.portals.graffito.database.driver" value="${org.apache.portals.graffito.test.database.driver}"/>
+ <j:set var="org.apache.portals.graffito.database.user" value="${org.apache.portals.graffito.test.database.user}"/>
+ <j:set var="org.apache.portals.graffito.database.password" value="${org.apache.portals.graffito.test.database.password}"/>
+ <copy file="src/test/repository.xml" todir="${maven.test.dest}" overwrite="true" failonerror="false">
+ <filterset begintoken="@" endtoken="@">
+ <filter token="PLATFORM" value="${org.apache.portals.graffito.database.ojb.plateform}"/>
+ </filterset>
+ <filterset begintoken="@" endtoken="@">
+ <filter token="DATASOURCE" value="${org.apache.portals.graffito.database.ojb.datasource}"/>
+ </filterset>
+ </copy>
+ <path id="jdbc.drivers.path" path="${org.apache.portals.graffito.test.jdbc.drivers.path}"/>
+ <maven:addPath id="maven.dependency.classpath" refid="jdbc.drivers.path"/>
+ </goal>
+ <!-- ================================================================ -->
+ <!-- CREATE Graffito Server Master DB Script -->
+ <!-- ================================================================ -->
+ <goal name="db.scripts.gen" prereqs="torque:init" description="Build SQL scripts using Torque generator">
+ <echo message="Generating SQL schema creation scripts for HSQLDB"/>
+ <torque-sql basePathToDbProps="sql/base/" contextProperties="${torque.contextProperties}"
+ controlTemplate="${torque.template.sql}" idTableXMLFile="${torque.idTableXMLFile}"
+ outputDirectory="${maven.build.src}/sql/hsql" outputFile="report.${torque.project}.sql.generation"
+ sqldbmap="${maven.build.src}/sql/hsql/sqldb.map" targetDatabase="hypersonic" useClasspath="true">
+ <fileset dir="${torque.schema.dir}" includes="${torque.schema.sql.includes}" excludes="${torque.schema.sql.excludes}"
+ />
+ </torque-sql>
+ <echo message="Generating SQL schema creation scripts for MySQL"/>
+ <torque-sql basePathToDbProps="sql/base/" contextProperties="${torque.contextProperties}"
+ controlTemplate="${torque.template.sql}" idTableXMLFile="${torque.idTableXMLFile}"
+ outputDirectory="${maven.build.src}/sql/mysql" outputFile="report.${torque.project}.sql.generation"
+ sqldbmap="${maven.build.src}/sql/mysql/sqldb.map" targetDatabase="mysql" useClasspath="true">
+ <fileset dir="${torque.schema.dir}" includes="${torque.schema.sql.includes}" excludes="${torque.schema.sql.excludes}"
+ />
+ </torque-sql>
+ <echo message="Generating SQL schema creation scripts for Oracle"/>
+ <torque-sql basePathToDbProps="sql/base/" contextProperties="${torque.contextProperties}"
+ controlTemplate="${torque.template.sql}" idTableXMLFile="${torque.idTableXMLFile}"
+ outputDirectory="${maven.build.src}/sql/oracle" outputFile="report.${torque.project}.sql.generation"
+ sqldbmap="${maven.build.src}/sql/oracle/sqldb.map" targetDatabase="oracle" useClasspath="true">
+ <fileset dir="${torque.schema.dir}" includes="${torque.schema.sql.includes}" excludes="${torque.schema.sql.excludes}"
+ />
+ </torque-sql>
+ <echo message="Generating SQL schema creation scripts for MS SQL"/>
+ <torque-sql basePathToDbProps="sql/base/" contextProperties="${torque.contextProperties}"
+ controlTemplate="${torque.template.sql}" idTableXMLFile="${torque.idTableXMLFile}"
+ outputDirectory="${maven.build.src}/sql/mssql" outputFile="report.${torque.project}.sql.generation"
+ sqldbmap="${maven.build.src}/sql/mssql/sqldb.map" targetDatabase="mssql" useClasspath="true">
+ <fileset dir="${torque.schema.dir}" includes="${torque.schema.sql.includes}" excludes="${torque.schema.sql.excludes}"
+ />
+ </torque-sql>
+ <echo message="Generating SQL schema creation scripts for Postgres"/>
+ <torque-sql basePathToDbProps="sql/base/" contextProperties="${torque.contextProperties}"
+ controlTemplate="${torque.template.sql}" idTableXMLFile="${torque.idTableXMLFile}"
+ outputDirectory="${maven.build.src}/sql/postgres" outputFile="report.${torque.project}.sql.generation"
+ sqldbmap="${maven.build.src}/sql/postgres/sqldb.map" targetDatabase="postgresql" useClasspath="true">
+ <fileset dir="${torque.schema.dir}" includes="${torque.schema.sql.includes}" excludes="${torque.schema.sql.excludes}"
+ />
+ </torque-sql>
+ </goal>
+ <!-- ================================================================ -->
+ <!-- SQL SCRIPT EXEC TEMPLATE -->
+ <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
+ <!-- Don't call this goal directly, call : -->
+ <!-- db.create.test or db.create.production -->
+ <!-- ================================================================ -->
+ <goal name="db.execute">
+ <sql driver="${org.apache.portals.graffito.database.driver}" url="${org.apache.portals.graffito.database.url}"
+ userid="${org.apache.portals.graffito.database.user}" password="${org.apache.portals.graffito.database.password}"
+ src="${database.arg.script}">
+ <classpath>
+ <path refid="maven.dependency.classpath"/>
+ <pathelement path="${org.apache.portals.graffito.jdbc.drivers.path}"/>
+ </classpath>
+ </sql>
+ </goal>
+ <goal name="db.test.properties">
+ <echo
+ message="org.apache.portals.graffito.test.database.default.name : ${org.apache.portals.graffito.test.database.default.name}"/>
+ <echo message="org.apache.portals.graffito.test.database.url : ${org.apache.portals.graffito.test.database.url}"/>
+ <echo message="org.apache.portals.graffito.test.database.driver : ${org.apache.portals.graffito.test.database.driver}"/>
+ <echo message="org.apache.portals.graffito.test.database.user : ${org.apache.portals.graffito.test.database.user}"/>
+ <echo
+ message="org.apache.portals.graffito.test.database.password : ${org.apache.portals.graffito.test.database.password}"/>
+ <echo message="org.apache.portals.graffito.test.database.path : ${org.apache.portals.graffito.test.jdbc.drivers.path}"/>
+ <echo message="org.apache.portals.graffito.test.jetspeed : ${org.apache.portals.graffito.test.jetspeed}"/>
+ <j:set var="name" value="${org.apache.portals.graffito.test.database.default.name}X"/>
+ <j:set var="url" value="${org.apache.portals.graffito.test.database.url}X"/>
+ <j:set var="driver" value="${org.apache.portals.graffito.test.database.driver}X"/>
+ <j:set var="password" value="${org.apache.portals.graffito.test.database.password}X"/>
+ <j:set var="jarpath" value="${org.apache.portals.graffito.test.jdbc.drivers.path}X"/>
+ <j:set var="jetspeed" value="${org.apache.portals.graffito.test.jetspeed}X"/>
+ <j:if test="${name == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.test.database.default.name"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${url == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.test.database.url"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${driver == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.test.database.driver"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${password == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.test.database.password"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${jarpath == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.test.database.path"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${jetspeed == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.test.jetspeed"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${status == 'error'}" >
+ <fail
+ message="Impossible to continue if all Graffito build properties are not set in the build.properties defined in your USER_HOME folder"/>
+ </j:if>
+ <j:set var="org.apache.portals.graffito.database.default.name"
+ value="${org.apache.portals.graffito.test.database.default.name}"/>
+ <j:set var="org.apache.portals.graffito.database.url" value="${org.apache.portals.graffito.test.database.url}"/>
+ <j:set var="org.apache.portals.graffito.database.driver" value="${org.apache.portals.graffito.test.database.driver}"/>
+ <j:set var="org.apache.portals.graffito.database.user" value="${org.apache.portals.graffito.test.database.user}"/>
+ <j:set var="org.apache.portals.graffito.database.password" value="${org.apache.portals.graffito.test.database.password}"/>
+ <j:set var="org.apache.portals.graffito.jdbc.drivers.path" value="${org.apache.portals.graffito.test.jdbc.drivers.path}"/>
+ </goal>
+ <goal name="db.production.properties">
+ <echo
+ message="org.apache.portals.graffito.production.database.default.name : ${org.apache.portals.graffito.production.database.default.name}"/>
+ <echo
+ message="org.apache.portals.graffito.production.database.url : ${org.apache.portals.graffito.production.database.url}"/>
+ <echo
+ message="org.apache.portals.graffito.production.database.driver : ${org.apache.portals.graffito.production.database.driver}"/>
+ <echo
+ message="org.apache.portals.graffito.production.database.user : ${org.apache.portals.graffito.production.database.user}"/>
+ <echo
+ message="org.apache.portals.graffito.production.database.password : ${org.apache.portals.graffito.production.database.password}"/>
+ <echo
+ message="org.apache.portals.graffito.production.database.path : ${org.apache.portals.graffito.production.jdbc.drivers.path}"/>
+ <echo message="org.apache.portals.graffito.production.jetspeed : ${org.apache.portals.graffito.production.jetspeed}"/>
+ <j:set var="name" value="${org.apache.portals.graffito.production.database.default.name}X"/>
+ <j:set var="url" value="${org.apache.portals.graffito.production.database.url}X"/>
+ <j:set var="driver" value="${org.apache.portals.graffito.production.database.driver}X"/>
+ <j:set var="password" value="${org.apache.portals.graffito.production.database.password}X"/>
+ <j:set var="jarpath" value="${org.apache.portals.graffito.production.jdbc.drivers.path}X"/>
+ <j:set var="jetspeed" value="${org.apache.portals.graffito.production.jetspeed}X"/>
+ <j:if test="${name == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.production.database.default.name"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${url == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.production.database.url"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${driver == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.production.database.driver"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${password == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.production.database.password"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${jarpath == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.production.database.path"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${jetspeed == 'X'}">
+ <echo message="No value found for the build property org.apache.portals.graffito.production.jetspeed"/>
+ <j:set var="status" value="error"/>
+ </j:if >
+ <j:if test="${status == 'error'}" >
+ <fail
+ message="Impossible to continue if all Graffito build properties are not set in the build.properties defined in your USER_HOME folder"/>
+ </j:if>
+ <j:set var="org.apache.portals.graffito.database.default.name"
+ value="${org.apache.portals.graffito.production.database.default.name}"/>
+ <j:set var="org.apache.portals.graffito.database.url" value="${org.apache.portals.graffito.production.database.url}"/>
+ <j:set var="org.apache.portals.graffito.database.driver"
+ value="${org.apache.portals.graffito.production.database.driver}"/>
+ <j:set var="org.apache.portals.graffito.database.user" value="${org.apache.portals.graffito.production.database.user}"/>
+ <j:set var="org.apache.portals.graffito.database.password"
+ value="${org.apache.portals.graffito.production.database.password}"/>
+ <j:set var="org.apache.portals.graffito.jdbc.drivers.path"
+ value="${org.apache.portals.graffito.production.jdbc.drivers.path}"/>
+ </goal>
+ <!-- ================================================================ -->
+ <!-- EXECUTE CREATE DB SQL SCRIPTS -->
+ <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
+ <!-- ================================================================ -->
+ <goal name="db.create.test">
+ <attainGoal name="db.test.properties"/>
+ <attainGoal name="db.create"/>
+ </goal>
+ <goal name="db.create.production">
+ <attainGoal name="db.production.properties"/>
+ <attainGoal name="db.create"/>
+ <j:set var="database.arg.script"
+ value="./src/sql/GraffitoServer/insert-j2-security.sql" />
+ <attainGoal name="db.execute" />
+
+ </goal>
+ <goal name="db.create">
+ <j:if test="${jetspeed == 'falseX'}">
+ <j:set var="database.arg.script"
+ value="./target/src/sql/${org.apache.portals.graffito.database.default.name}/security-schema.sql" />
+ <attainGoal name="db.execute" />
+ <j:set var="database.arg.script"
+ value="./target/src/sql/${org.apache.portals.graffito.database.default.name}/ojb-schema.sql" />
+ <attainGoal name="db.execute" />
+ </j:if>
+ <j:set var="database.arg.script"
+ value="./target/src/sql/${org.apache.portals.graffito.database.default.name}/graffitostore-schema.sql" />
+ <attainGoal name="db.execute" />
+ <j:set var="database.arg.script" value="./src/sql/GraffitoServer/insert-db.sql" />
+ <attainGoal name="db.execute" />
+ </goal>
+ <!-- ================================================================ -->
+ <!-- EXECUTE DROP DB SQL SCRIPTS -->
+ <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
+ <!-- ================================================================ -->
+ <goal name="db.drop.test">
+ <attainGoal name="db.test.properties"/>
+ <attainGoal name="db.drop"/>
+ </goal>
+ <goal name="db.drop.production">
+ <attainGoal name="db.production.properties"/>
+ <attainGoal name="db.drop"/>
+ <j:set var="database.arg.script"
+ value="./src/sql/GraffitoServer/delete-j2-security.sql" />
+ <attainGoal name="db.execute" />
+
+ </goal>
+ <goal name="db.drop">
+ <j:set var="database.arg.script"
+ value="./src/sql/GraffitoServer/${org.apache.portals.graffito.database.default.name}/drop-db.sql" />
+ <attainGoal name="db.execute" />
+ <j:if test="${jetspeed == 'falseX'}">
+ <j:set var="database.arg.script"
+ value="./src/sql/GraffitoServer/${org.apache.portals.graffito.database.default.name}/drop-security.sql" />
+ <attainGoal name="db.execute" />
+ <j:set var="database.arg.script"
+ value="./src/sql/GraffitoServer/${org.apache.portals.graffito.database.default.name}/drop-ojb.sql" />
+ <attainGoal name="db.execute" />
+ </j:if>
+ </goal>
+ <!-- ================================================================ -->
+ <!-- EXECUTE DELETE DB SQL SCRIPTS -->
+ <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
+ <!-- ================================================================ -->
+ <goal name="db.delete.test">
+ <attainGoal name="db.test.properties"/>
+ <attainGoal name="db.delete"/>
+ </goal>
+ <goal name="db.delete.production">
+ <attainGoal name="db.production.properties"/>
+ <attainGoal name="db.delete"/>
+ </goal>
+ <goal name="db.delete">
+ <j:set var="database.arg.script" value="./src/sql/GraffitoServer/delete-db.sql" />
+ <attainGoal name="db.execute" />
+ </goal>
+ <!-- ================================================================ -->
+ <!-- EXECUTE DROP & CREATE DB SQL SCRIPTS -->
+ <!-- TODO: I'd like to implement this as a plugin or use commons SQL -->
+ <!-- ================================================================ -->
+ <goal name="db.reinit.test">
+ <attainGoal name="db.scripts.gen"/>
+ <attainGoal name="db.test.properties"/>
+ <attainGoal name="db.drop"/>
+ <attainGoal name="db.create"/>
+ </goal>
+ <!-- ================================================================ -->
+ <!-- Intstall Graffito services & Graffito dependencies into -->
+ <!-- a deployed J2 application -->
+ <!-- ================================================================ -->
+ <goal name="deploy">
+ <copy todir="${org.apache.jetspeed.deploy.war.dir}/jetspeed/WEB-INF/lib" overwrite="true">
+ <fileset file="${basedir}/target/${maven.final.name}.jar" />
+ </copy>
+ </goal>
+</project>
\ No newline at end of file
Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/AbstractSecurityTestcase.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/AbstractSecurityTestcase.java?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/AbstractSecurityTestcase.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/AbstractSecurityTestcase.java Tue Apr 5 13:55:32 2005
@@ -95,6 +95,8 @@
/** The permission manager. */
protected PermissionManager pms;
protected LoginContext loginContext = null;
+
+ protected CmsRequestContextManager contextManager = null;
/**
* <p>
@@ -153,7 +155,7 @@
loginContext = new LoginContext("GRAFFITO", pch);
loginContext.login();
- CmsRequestContextManager contextManager = (CmsRequestContextManager) ctx.getBean("org.apache.portals.graffito.context.CmsRequestContextManager");
+ contextManager = (CmsRequestContextManager) ctx.getBean("org.apache.portals.graffito.context.CmsRequestContextManager");
CmsRequestContext cmsContext = new CmsRequestContextImpl();
cmsContext.setSubject(loginContext.getSubject());
contextManager.setCurrentCmsRequestContext(cmsContext);
Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/GraffitoAction.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/GraffitoAction.java?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/GraffitoAction.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/security/impl/GraffitoAction.java Tue Apr 5 13:55:32 2005
@@ -40,10 +40,10 @@
public static final int MASK_EDIT = 0x02;
public static final int MASK_LOCK = 0x04;
public static final int MASK_UNLOCK = 0x08;
- public static final int MASK_DELETE = 0x10;
+ public static final int MASK_DELETE = 0x16;
public static final int MASK_INSERT = 0x20;
public static final int MASK_UPDATE = 0x40;
- public static final int MASK_ALL = 0x48;
+ public static final int MASK_ALL = MASK_VIEW | MASK_EDIT | MASK_LOCK | MASK_UNLOCK | MASK_DELETE | MASK_INSERT | MASK_UPDATE;
/** View a cms object */
static public final String VIEW = "view";
Added: incubator/graffito/trunk/components/src/sql/GraffitoServer/delete-j2-security.sql
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/sql/GraffitoServer/delete-j2-security.sql?view=auto&rev=160217
==============================================================================
--- incubator/graffito/trunk/components/src/sql/GraffitoServer/delete-j2-security.sql (added)
+++ incubator/graffito/trunk/components/src/sql/GraffitoServer/delete-j2-security.sql Tue Apr 5 13:55:32 2005
@@ -0,0 +1,17 @@
+-----------------------------------------------------------------------------
+-- Copyright 2004 The Apache Software Foundation
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-----------------------------------------------------------------------------
+DELETE FROM PRINCIPAL_PERMISSION WHERE PRINCIPAL_ID = 6 AND PERMISSION_ID = 20;
+DELETE FROM SECURITY_PERMISSION WHERE PERMISSION_ID = 20;
Added: incubator/graffito/trunk/components/src/sql/GraffitoServer/insert-j2-security.sql
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/sql/GraffitoServer/insert-j2-security.sql?view=auto&rev=160217
==============================================================================
--- incubator/graffito/trunk/components/src/sql/GraffitoServer/insert-j2-security.sql (added)
+++ incubator/graffito/trunk/components/src/sql/GraffitoServer/insert-j2-security.sql Tue Apr 5 13:55:32 2005
@@ -0,0 +1,17 @@
+-----------------------------------------------------------------------------
+-- Copyright 2004 The Apache Software Foundation
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-----------------------------------------------------------------------------
+INSERT INTO SECURITY_PERMISSION VALUES(20,'org.apache.portals.graffito.security.impl.CmsPermission','<<ALL FILES>>','all','2004-05-22 16:27:12.572','2004-05-22 16:27:12.572');
+INSERT INTO PRINCIPAL_PERMISSION VALUES(6, 20);
Added: incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllFilesTestRdbmsPolicy.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllFilesTestRdbmsPolicy.java?view=auto&rev=160217
==============================================================================
--- incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllFilesTestRdbmsPolicy.java (added)
+++ incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllFilesTestRdbmsPolicy.java Tue Apr 5 13:55:32 2005
@@ -0,0 +1,156 @@
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.security.impl;
+
+
+import javax.security.auth.login.LoginException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.UserPrincipal;
+
+import org.apache.jetspeed.security.impl.UserPrincipalImpl;
+import org.apache.portals.graffito.security.CmsAccessController;
+import org.apache.portals.graffito.security.impl.AbstractSecurityTestcase;
+import org.apache.portals.graffito.security.impl.CmsPermission;
+
+/**
+ * Test permission on "<< ALL FILES >>"
+ *
+ */
+
+public class AllFilesTestRdbmsPolicy extends AbstractSecurityTestcase
+{
+
+ private CmsAccessController cmsAccessController;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ cmsAccessController = (CmsAccessController) ctx.getBean("org.apache.portals.graffito.security.CmsAccessController");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Fail to run due to an exception : " + e);
+ }
+
+ }
+
+ /**
+ * @see junit.framework.TestCase#tearDown()
+ */
+ public void tearDown() throws Exception
+ {
+
+ // Logout
+ try
+ {
+ loginContext.logout();
+ }
+ catch (LoginException le)
+ {
+ le.printStackTrace();
+ assertTrue("\t\t[TestRdbmsPolicy] Failed to tear down test.", false);
+ }
+ destroyUser();
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(AllFilesTestRdbmsPolicy.class);
+ }
+
+ /**
+ * Test simple permission on one document
+ *
+ */
+ public void testPermission()
+ {
+
+ assertTrue("Did not authorize view permission on a document", cmsAccessController.hasPermission(
+ "/files", "view"));
+
+ assertTrue("Did not authorize view permission on a document", cmsAccessController.hasPermission(
+ "/files/test.xml", "view"));
+
+ assertTrue("Did not authorize edit permission on document", cmsAccessController.hasPermission(
+ "/files/xx/vv/uu/test.xml", "edit"));
+
+ assertTrue("Did not authorize insert permission on document", cmsAccessController.hasPermission(
+ "/files/subfolder/test.xml", "insert"));
+
+
+ assertFalse("Authorize update permission on document", cmsAccessController.hasPermission(
+ "/files/subfolder/test.xml", "update"));
+
+ }
+
+
+
+ /**
+ * <p>
+ * Initialize user test object.
+ * </p>
+ */
+ protected void initUser()
+ {
+ try
+ {
+ ums.addUser("anon", "password");
+ }
+ catch (SecurityException sex)
+ {
+ }
+
+ UserPrincipal user = new UserPrincipalImpl("anon");
+
+ CmsPermission perm1 = new CmsPermission("<<ALL FILES>>", "view,edit,insert");
+
+ try
+ {
+ pms.addPermission(perm1);
+ pms.grantPermission(user, perm1);
+
+ }
+ catch (SecurityException sex)
+ {
+ sex.printStackTrace();
+ }
+ }
+
+ /**
+ * <p>
+ * Destroy user test object.
+ * </p>
+ */
+ protected void destroyUser() throws Exception
+ {
+ ums.removeUser("anon");
+
+ CmsPermission perm1 = new CmsPermission("<<ALL FILES>>", "view,edit,insert");
+ pms.removePermission(perm1);
+ }
+
+}
\ No newline at end of file
Added: incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllPermissionTestRdbmsPolicy.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllPermissionTestRdbmsPolicy.java?view=auto&rev=160217
==============================================================================
--- incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllPermissionTestRdbmsPolicy.java (added)
+++ incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/AllPermissionTestRdbmsPolicy.java Tue Apr 5 13:55:32 2005
@@ -0,0 +1,156 @@
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.security.impl;
+
+
+import javax.security.auth.login.LoginException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.UserPrincipal;
+
+import org.apache.jetspeed.security.impl.UserPrincipalImpl;
+import org.apache.portals.graffito.security.CmsAccessController;
+import org.apache.portals.graffito.security.impl.AbstractSecurityTestcase;
+import org.apache.portals.graffito.security.impl.CmsPermission;
+
+/**
+ * This unit test comes from Jetspeed 2. It used to check if the J2 security
+ * components are well integrated with Graffito
+ *
+ */
+
+public class AllPermissionTestRdbmsPolicy extends AbstractSecurityTestcase
+{
+
+ private CmsAccessController cmsAccessController;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ cmsAccessController = (CmsAccessController) ctx.getBean("org.apache.portals.graffito.security.CmsAccessController");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Fail to run due to an exception : " + e);
+ }
+
+ }
+
+ /**
+ * @see junit.framework.TestCase#tearDown()
+ */
+ public void tearDown() throws Exception
+ {
+
+ // Logout
+ try
+ {
+ loginContext.logout();
+ }
+ catch (LoginException le)
+ {
+ le.printStackTrace();
+ assertTrue("\t\t[TestRdbmsPolicy] Failed to tear down test.", false);
+ }
+ destroyUser();
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(AllPermissionTestRdbmsPolicy.class);
+ }
+
+ /**
+ * Test simple permission on one document
+ *
+ */
+ public void testPermission()
+ {
+
+// assertTrue("Did not authorize view permission on a document", cmsAccessController.hasPermission(
+// "/files", "view"));
+
+ assertTrue("Did not authorize view permission on a document", cmsAccessController.hasPermission(
+ "/files/test.xml", "view"));
+
+ assertTrue("Did not authorize edit permission on document", cmsAccessController.hasPermission(
+ "/files/xx/vv/uu/test.xml", "edit"));
+
+ assertTrue("Did not authorize insert permission on document", cmsAccessController.hasPermission(
+ "/files/subfolder/test.xml", "insert"));
+
+ assertTrue("Did not authorize insert permission on document", cmsAccessController.hasPermission(
+ "/files/subfolder/test.xml", "lock"));
+
+ }
+
+
+
+ /**
+ * <p>
+ * Initialize user test object.
+ * </p>
+ */
+ protected void initUser()
+ {
+ try
+ {
+ ums.addUser("anon", "password");
+ }
+ catch (SecurityException sex)
+ {
+ }
+
+ UserPrincipal user = new UserPrincipalImpl("anon");
+
+ CmsPermission perm1 = new CmsPermission("/files/-", "all");
+
+ try
+ {
+ pms.addPermission(perm1);
+ pms.grantPermission(user, perm1);
+
+ }
+ catch (SecurityException sex)
+ {
+ sex.printStackTrace();
+ }
+ }
+
+ /**
+ * <p>
+ * Destroy user test object.
+ * </p>
+ */
+ protected void destroyUser() throws Exception
+ {
+ ums.removeUser("anon");
+
+ CmsPermission perm1 = new CmsPermission("/files/-", "all");
+ pms.removePermission(perm1);
+ }
+
+}
\ No newline at end of file
Modified: incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/TestRdbmsPolicy.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/TestRdbmsPolicy.java?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/TestRdbmsPolicy.java (original)
+++ incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/security/impl/TestRdbmsPolicy.java Tue Apr 5 13:55:32 2005
@@ -16,6 +16,11 @@
+import java.security.Permission;
+import java.security.Permissions;
+import java.util.Enumeration;
+
+import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
import junit.framework.Test;
@@ -25,6 +30,7 @@
import org.apache.jetspeed.security.UserPrincipal;
import org.apache.jetspeed.security.impl.UserPrincipalImpl;
+import org.apache.portals.graffito.context.CmsRequestContext;
import org.apache.portals.graffito.security.CmsAccessController;
import org.apache.portals.graffito.security.impl.AbstractSecurityTestcase;
import org.apache.portals.graffito.security.impl.CmsPermission;
@@ -78,6 +84,10 @@
super.tearDown();
}
+ /**
+ * Start test suite
+ * @return test suite
+ */
public static Test suite()
{
// All methods starting with "test" will be executed in the test suite.
@@ -116,9 +126,36 @@
"/files/subfolder2/test.xml", "view"));
assertTrue("did not authorize view permission on the Folder.", cmsAccessController.hasPermission(
"/files/subfolder2/foo/anotherdoc.xml", "view"));
-
+ assertTrue("did not authorize insert permission on the document.", cmsAccessController.hasPermission(
+ "/files/subfolder3/test.xml", "insert"));
+ assertTrue("did not authorize view permission on the document.", cmsAccessController.hasPermission(
+ "/files/subfolder3/test.xml", "view"));
+ assertFalse("Permission error - should not update the document .", cmsAccessController.hasPermission(
+ "/files/subfolder3/test.xml", "update"));
+
}
+
+ /**
+ * Test getPermissions
+ *
+ *
+ */
+ public void testgetPermission()
+ {
+ CmsRequestContext cmsRequestContext = contextManager.getCurrentCmsRequestContext();
+ Subject subject = cmsRequestContext.getSubject();
+ Permissions permissions = pms.getPermissions(subject.getPrincipals());
+ Enumeration enum = permissions.elements();
+ while (enum.hasMoreElements())
+ {
+ Permission permission = (Permission) enum.nextElement();
+
+ System.out.println("Permission found - actions : " + permission.getActions() + " name : " + permission.getName());
+ }
+
+
+ }
/**
* <p>
* Initialize user test object.
@@ -139,14 +176,18 @@
CmsPermission perm1 = new CmsPermission("/files/test.xml", "edit");
CmsPermission perm2 = new CmsPermission("/files/subfolder1/*", "view");
CmsPermission perm3 = new CmsPermission("/files/subfolder2/-", "view");
+ CmsPermission perm4 = new CmsPermission("/files/subfolder3/*", "view,insert");
+
try
{
pms.addPermission(perm1);
pms.addPermission(perm2);
pms.addPermission(perm3);
+ pms.addPermission(perm4);
pms.grantPermission(user, perm1);
pms.grantPermission(user, perm2);
pms.grantPermission(user, perm3);
+ pms.grantPermission(user, perm4);
}
catch (SecurityException sex)
{
@@ -155,9 +196,10 @@
}
/**
- * <p>
+ *
* Destroy user test object.
- * </p>
+ *
+ * @throws Exception when it is not possible to clean up
*/
protected void destroyUser() throws Exception
{
@@ -166,9 +208,11 @@
CmsPermission perm1 = new CmsPermission("/files/test.xml", "edit");
CmsPermission perm2 = new CmsPermission("/files/subfolder1/*", "view");
CmsPermission perm3 = new CmsPermission("/files/subfolder2/-", "view");
+ CmsPermission perm4 = new CmsPermission("/files/subfolder3/-", "view,insert");
pms.removePermission(perm1);
pms.removePermission(perm2);
pms.removePermission(perm3);
+ pms.removePermission(perm4);
}
}
Added: incubator/graffito/trunk/jetspeed2-deploy/.classpath
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jetspeed2-deploy/.classpath?view=auto&rev=160217
==============================================================================
--- incubator/graffito/trunk/jetspeed2-deploy/.classpath (added)
+++ incubator/graffito/trunk/jetspeed2-deploy/.classpath Tue Apr 5 13:55:32 2005
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<classpath>
+ <classpathentry excluding="" kind="src" path="src/java">
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
+ </classpathentry>
+ <classpathentry kind="var" path="MAVEN_REPO/jetspeed2/jars/jetspeed-2.0-a1-dev.jar">
+ </classpathentry>
+ <classpathentry kind="var" path="MAVEN_REPO/jetspeed2/jars/jetspeed-api-2.0-a1-dev.jar">
+ </classpathentry>
+ <classpathentry kind="var" path="MAVEN_REPO/jetspeed2/jars/jetspeed-components-2.0-a1-dev.jar">
+ </classpathentry>
+ <classpathentry kind="var" path="MAVEN_REPO/graffito/jars/graffito-commons-1.0-a1-dev.jar">
+ </classpathentry>
+ <classpathentry kind="var" path="MAVEN_REPO/graffito/jars/graffito-api-1.0-a1-dev.jar">
+ </classpathentry>
+ <classpathentry kind="var" path="MAVEN_REPO/graffito/jars/graffito-components-1.0-a1-dev.jar">
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes">
+ </classpathentry>
+</classpath>
\ No newline at end of file
Modified: incubator/graffito/trunk/jetspeed2-deploy/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jetspeed2-deploy/maven.xml?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/jetspeed2-deploy/maven.xml (original)
+++ incubator/graffito/trunk/jetspeed2-deploy/maven.xml Tue Apr 5 13:55:32 2005
@@ -18,6 +18,11 @@
<!-- Hot Deploy for mundane everyday development under Catalina -->
<!-- ================================================================ -->
<goal name="deploy">
+ <attainGoal name="jar:install"/>
+ <copy todir="${org.apache.jetspeed.deploy.war.dir}/jetspeed/WEB-INF/lib" overwrite="true">
+ <fileset file="${basedir}/target/${maven.final.name}.jar" />
+ </copy>
+
<copy todir="${org.apache.jetspeed.deploy.war.dir}/jetspeed/WEB-INF" overwrite="true">
<fileset dir="${maven.src.dir}" />
</copy>
@@ -32,5 +37,7 @@
/>
</replaceregexp>
</j:if>
+
+
</goal>
</project>
Modified: incubator/graffito/trunk/jetspeed2-deploy/project.properties
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jetspeed2-deploy/project.properties?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/jetspeed2-deploy/project.properties (original)
+++ incubator/graffito/trunk/jetspeed2-deploy/project.properties Tue Apr 5 13:55:32 2005
@@ -26,3 +26,4 @@
maven.multiproject.type=jar
+
Modified: incubator/graffito/trunk/jetspeed2-deploy/project.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jetspeed2-deploy/project.xml?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/jetspeed2-deploy/project.xml (original)
+++ incubator/graffito/trunk/jetspeed2-deploy/project.xml Tue Apr 5 13:55:32 2005
@@ -33,11 +33,70 @@
<dependencies>
- </dependencies>
+ <dependency>
+ <id>jetspeed</id>
+ <groupId>jetspeed2</groupId>
+ <version>2.0-a1-dev</version>
+ </dependency>
+
+ <dependency>
+ <id>jetspeed-api</id>
+ <groupId>jetspeed2</groupId>
+ <version>2.0-a1-dev</version>
+ </dependency>
+
+ <dependency>
+ <id>jetspeed-components</id>
+ <groupId>jetspeed2</groupId>
+ <version>2.0-a1-dev</version>
+ </dependency>
+
+ <dependency>
+ <id>graffito-commons</id>
+ <groupId>graffito</groupId>
+ <version>1.0-a1-dev</version>
+ </dependency>
+ <dependency>
+ <id>graffito-api</id>
+ <groupId>graffito</groupId>
+ <version>1.0-a1-dev</version>
+ </dependency>
+ <dependency>
+ <id>graffito-components</id>
+ <groupId>graffito</groupId>
+ <version>1.0-a1-dev</version>
+ </dependency>
+ </dependencies>
<build>
<sourceDirectory>src/java</sourceDirectory>
+
+ <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/test</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </unitTest>
+
+ <resources>
+ <resource>
+ <directory>${basedir}/src/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+
</build>
+ <reports>
+ <report>maven-javadoc-plugin</report>
+ </reports>
+
</project>
Modified: incubator/graffito/trunk/jetspeed2-deploy/src/assembly/graffito.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jetspeed2-deploy/src/assembly/graffito.xml?view=diff&r1=160216&r2=160217
==============================================================================
--- incubator/graffito/trunk/jetspeed2-deploy/src/assembly/graffito.xml (original)
+++ incubator/graffito/trunk/jetspeed2-deploy/src/assembly/graffito.xml Tue Apr 5 13:55:32 2005
@@ -51,12 +51,13 @@
<!-- Access Controller -->
<!-- Use the following access controller for JAAS & Jetspeed security components support-->
- <!--bean id="org.apache.portals.graffito.security.CmsAccessController" class="org.apache.portals.graffito.security.impl.CmsAccessControllerImpl" >
+ <bean id="org.apache.portals.graffito.security.CmsAccessController" class="org.apache.portals.graffito.security.impl.CmsAccessControllerImpl" >
<constructor-arg ><ref bean="org.apache.portals.graffito.context.CmsRequestContextManager"/></constructor-arg>
- </bean -->
+ </bean>
- <bean id="org.apache.portals.graffito.security.CmsAccessController" class="org.apache.portals.graffito.security.impl.EmptyCmsAccessControllerImpl" />
+ <!-- bean id="org.apache.portals.graffito.security.CmsAccessController" class="org.apache.portals.graffito.security.impl.EmptyCmsAccessControllerImpl" /-->
+
<!--Ojb Factory : used to access to the OJB Persistence Broker -->
<bean id="org.apache.portals.graffito.store.impl.ojb.OjbFactory" class="org.apache.portals.graffito.store.impl.ojb.SpringOjbFactory" />
Added: incubator/graffito/trunk/jetspeed2-deploy/src/assembly/pipelines.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jetspeed2-deploy/src/assembly/pipelines.xml?view=auto&rev=160217
==============================================================================
--- incubator/graffito/trunk/jetspeed2-deploy/src/assembly/pipelines.xml (added)
+++ incubator/graffito/trunk/jetspeed2-deploy/src/assembly/pipelines.xml Tue Apr 5 13:55:32 2005
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<!--
+Copyright 2004 The Apache Software Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<beans>
+ <bean id="localizationValve"
+ class="org.apache.jetspeed.localization.impl.LocalizationValveImpl"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <va...@--></value>
+ </constructor-arg>
+ </bean>
+
+ <bean id="capabilityValve"
+ class="org.apache.jetspeed.capabilities.impl.CapabilityValveImpl"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.capabilities.Capabilities" />
+ </constructor-arg>
+ </bean>
+
+ <bean id="portalURLValve"
+ class="org.apache.jetspeed.container.url.impl.PortalURLValveImpl"
+ init-method="initialize"
+ />
+
+ <bean id="securityValve"
+ class="org.apache.jetspeed.security.impl.SecurityValveImpl"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.profiler.Profiler" />
+ </constructor-arg>
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.security.UserManager" />
+ </constructor-arg>
+ </bean>
+
+ <bean id="passwordCredentialValve"
+ class="org.apache.jetspeed.security.impl.PasswordCredentialValveImpl"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <!-- expirationWarningDays -->
+ <list>
+ <value>2</value>
+ <value>3</value>
+ <value>7</value>
+ </list>
+ </constructor-arg>
+ </bean>
+
+ <bean id="profilerValve"
+ class="org.apache.jetspeed.profiler.impl.ProfilerValveImpl"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.profiler.Profiler" />
+ </constructor-arg>
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.page.PageManager" />
+ </constructor-arg>
+ </bean>
+
+ <bean id="containerValve"
+ class="org.apache.jetspeed.container.ContainerValve"
+ init-method="initialize"
+ />
+
+ <bean id="actionValve"
+ class="org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <ref bean="org.apache.pluto.PortletContainer" />
+ </constructor-arg>
+ </bean>
+
+ <bean id="portletValve"
+ class="org.apache.jetspeed.aggregator.PortletValve"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.aggregator.PortletAggregator"/>
+ </constructor-arg>
+ </bean>
+
+ <bean id="aggregatorValve"
+ class="org.apache.jetspeed.aggregator.AggregatorValve"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.aggregator.PageAggregator"/>
+ </constructor-arg>
+ </bean>
+
+ <bean id="cleanUpValve"
+ class="org.apache.jetspeed.pipeline.valve.impl.CleanupValveImpl"
+ init-method="initialize"
+ >
+ </bean>
+
+ <bean id="GraffitoContextValve"
+ class="org.apache.portals.jetspeed.valve.GraffitoContextValve"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <ref bean="org.apache.portals.graffito.context.CmsRequestContextManager" />
+ </constructor-arg>
+ </bean>
+
+
+
+ <bean id="jetspeed-pipeline"
+ class="org.apache.jetspeed.pipeline.JetspeedPipeline"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <value>JetspeedPipeline</value>
+ </constructor-arg>
+ <constructor-arg>
+ <list>
+ <ref bean="localizationValve"/>
+ <ref bean="capabilityValve"/>
+ <ref bean="portalURLValve"/>
+ <ref bean="securityValve"/>
+ <ref bean="passwordCredentialValve"/>
+ <ref bean="GraffitoContextValve"/>
+ <ref bean="profilerValve"/>
+ <ref bean="containerValve"/>
+ <ref bean="actionValve"/>
+ <ref bean="aggregatorValve"/>
+ <ref bean="cleanUpValve"/>
+ </list>
+ </constructor-arg>
+ </bean>
+
+ <bean id="action-pipeline"
+ class="org.apache.jetspeed.pipeline.JetspeedPipeline"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <value>ActionPipeline</value>
+ </constructor-arg>
+ <constructor-arg>
+ <list>
+ <ref bean="localizationValve"/>
+ <ref bean="capabilityValve"/>
+ <ref bean="portalURLValve"/>
+ <ref bean="containerValve"/>
+ <ref bean="actionValve"/>
+ </list>
+ </constructor-arg>
+ </bean>
+
+ <bean id="portlet-pipeline"
+ class="org.apache.jetspeed.pipeline.JetspeedPipeline"
+ init-method="initialize"
+ >
+ <constructor-arg>
+ <value>PortletPipeline</value>
+ </constructor-arg>
+ <constructor-arg>
+ <list>
+ <ref bean="localizationValve"/>
+ <ref bean="portalURLValve"/>
+ <ref bean="capabilityValve"/>
+ <ref bean="securityValve"/>
+ <ref bean="profilerValve"/>
+ <ref bean="containerValve"/>
+ <ref bean="portletValve"/>
+ </list>
+ </constructor-arg>
+ </bean>
+
+
+</beans>
\ No newline at end of file
Added: incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/jetspeed/valve/GraffitoContextValve.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/jetspeed/valve/GraffitoContextValve.java?view=auto&rev=160217
==============================================================================
--- incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/jetspeed/valve/GraffitoContextValve.java (added)
+++ incubator/graffito/trunk/jetspeed2-deploy/src/java/org/apache/portals/jetspeed/valve/GraffitoContextValve.java Tue Apr 5 13:55:32 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.jetspeed.valve;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.pipeline.PipelineException;
+
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.impl.AbstractSecurityValve;
+import org.apache.portals.graffito.context.CmsRequestContext;
+import org.apache.portals.graffito.context.CmsRequestContextManager;
+import org.apache.portals.graffito.context.impl.CmsRequestContextImpl;
+
+/**
+ * Jetspeed 2 valve used to initialise the Graffito request context with the current Subject
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class GraffitoContextValve extends AbstractSecurityValve
+{
+
+ private CmsRequestContextManager cmsRequestContextManager;
+
+ /**
+ * Constructor
+ *
+ * @param cmsRequestContextManager
+ */
+ public GraffitoContextValve(CmsRequestContextManager cmsRequestContextManager)
+ {
+ this.cmsRequestContextManager = cmsRequestContextManager;
+ }
+
+ /**
+ *
+ * @see org.apache.jetspeed.pipeline.valve.Valve#invoke(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.pipeline.valve.ValveContext)
+ */
+ public void invoke(RequestContext request, ValveContext context) throws PipelineException
+ {
+ Subject subject = getSubject(request);
+ CmsRequestContext cmsRequestContext = new CmsRequestContextImpl();
+ cmsRequestContext.setSubject(subject);
+ cmsRequestContextManager.setCurrentCmsRequestContext(cmsRequestContext);
+ context.invokeNext(request);
+
+ }
+
+
+ protected Subject getSubject(RequestContext request)
+ {
+ return getSubjectFromSession(request);
+ }
+
+ protected Principal getUserPrincipal(RequestContext context)
+ {
+ return getUserPrincipal(context);
+ }
+}