cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r234177 - in /cocoon: blocks/hsqldb/trunk/conf/ blocks/ojb/trunk/conf/ blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/ blocks/portal/trunk/WEB-INF/xconf/ blocks/portal/trunk/java/org/apache/cocoon/portal/security/ trunk/
Date Sun, 21 Aug 2005 10:55:40 GMT
Author: cziegeler
Date: Sun Aug 21 03:54:05 2005
New Revision: 234177

URL: http://svn.apache.org/viewcvs?rev=234177&view=rev
Log:
Portal block: Use OJB and the HSQLDB for authentication of the portal sample.

Added:
    cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/User.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
  (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/PortalUser.java   (with
props)
Modified:
    cocoon/blocks/hsqldb/trunk/conf/cocoondb.script
    cocoon/blocks/ojb/trunk/conf/repository_user.xml
    cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal-cowarp.xconf
    cocoon/trunk/gump.xml
    cocoon/trunk/status.xml

Modified: cocoon/blocks/hsqldb/trunk/conf/cocoondb.script
URL: http://svn.apache.org/viewcvs/cocoon/blocks/hsqldb/trunk/conf/cocoondb.script?rev=234177&r1=234176&r2=234177&view=diff
==============================================================================
--- cocoon/blocks/hsqldb/trunk/conf/cocoondb.script (original)
+++ cocoon/blocks/hsqldb/trunk/conf/cocoondb.script Sun Aug 21 03:54:05 2005
@@ -14,7 +14,7 @@
 
 CREATE TABLE DEPARTMENT(ID INTEGER NOT NULL,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NULL,UNIQUE(ID))
 CREATE TABLE EMPLOYEE(ID INTEGER NOT NULL,DEPARTMENT_ID INTEGER NOT NULL,NAME VARCHAR NOT
NULL,DESCRIPTION VARCHAR NULL,UNIQUE(ID))
-CREATE TABLE USER(UID INTEGER IDENTITY PRIMARY KEY,NAME VARCHAR,FIRSTNAME VARCHAR,UNAME VARCHAR,UNIQUE(UNAME))
+CREATE TABLE USER(UID INTEGER IDENTITY PRIMARY KEY,NAME VARCHAR,FIRSTNAME VARCHAR,UNAME VARCHAR,PWD
VARCHAR,ROLE VARCHAR, UNIQUE(UNAME))
 CREATE TABLE GROUPS(GID INTEGER IDENTITY PRIMARY KEY,GNAME VARCHAR,UNIQUE(GNAME))
 CREATE TABLE USER_GROUPS(UID INTEGER,GID INTEGER,UNIQUE(UID,GID),FOREIGN KEY(UID)REFERENCES
USER(UID),FOREIGN KEY(GID)REFERENCES GROUPS(GID))
 CREATE TABLE STATE_TAX(CATEGORY VARCHAR NOT NULL,GROSSTAX_COLLECTED DOUBLE NOT NULL,NETTAX_COLLECTED
DOUBLE NOT NULL,YEAR INTEGER NOT NULL)
@@ -25,6 +25,9 @@
 CREATE TABLE CRITERION(ID BIGINT IDENTITY PRIMARY KEY,Q_ID BIGINT,C_FIELD VARCHAR,C_MATCH
VARCHAR,C_TERM VARCHAR,CONSTRAINT SYS_FK_20 FOREIGN KEY(Q_ID) REFERENCES QUERY(ID),UNIQUE(ID))
 CREATE USER SA PASSWORD "" ADMIN
 SET WRITE_DELAY 60
+INSERT INTO USER VALUES (1, 'Mustermann', 'Max', 'guest', 'guest', 'guest')
+INSERT INTO USER VALUES (2, 'Mustermann', 'Heidi', 'cocoon', 'cocoon', 'administrator')
+INSERT INTO USER VALUES (3, 'User', 'Default', 'anonymous', 'anonymous', 'guest')
 INSERT INTO DEPARTMENT VALUES(1,'Development','<span>Department producing software
packages, <i>on time</i>, and <i>bug free</i>.</span>')
 INSERT INTO DEPARTMENT VALUES(2,'Management','<span>Department spending all the budget
on <i>meetings</i> and <i>donuts</i>.</span>')
 INSERT INTO DEPARTMENT VALUES(3,'Testers','<span>Department capable of finding issues
in <i>bug free</i> software packages.</span>')

Modified: cocoon/blocks/ojb/trunk/conf/repository_user.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/ojb/trunk/conf/repository_user.xml?rev=234177&r1=234176&r2=234177&view=diff
==============================================================================
--- cocoon/blocks/ojb/trunk/conf/repository_user.xml (original)
+++ cocoon/blocks/ojb/trunk/conf/repository_user.xml Sun Aug 21 03:54:05 2005
@@ -31,6 +31,16 @@
         <field-descriptor name="name"           column="NAME"           jdbc-type="VARCHAR"/>
     </class-descriptor>
 
+ 
+     <class-descriptor class="org.apache.cocoon.ojb.samples.bean.User" table="USER">
+        <field-descriptor name="uid"             column="UID"             jdbc-type="INTEGER"
primarykey="true"/>
+        <field-descriptor name="lastname"           column="NAME"           jdbc-type="VARCHAR"/>
+        <field-descriptor name="firstname"           column="FIRSTNAME"           jdbc-type="VARCHAR"/>
+        <field-descriptor name="username"           column="UNAME"           jdbc-type="VARCHAR"/>
+        <field-descriptor name="password"           column="PWD"           jdbc-type="VARCHAR"/>
+        <field-descriptor name="role"           column="ROLE"           jdbc-type="VARCHAR"/>
+    </class-descriptor>
+    
     <!-- mappings for the QueryBean Block -->
     <class-descriptor class="org.apache.cocoon.bean.query.SimpleLuceneCriterionBean" table="CRITERION">
         <field-descriptor name="id"   column="ID"   jdbc-type="BIGINT" primarykey="true"
autoincrement="true"/>

Added: cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/User.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/User.java?rev=234177&view=auto
==============================================================================
--- cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/User.java (added)
+++ cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/User.java Sun Aug 21 03:54:05
2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005 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.cocoon.ojb.samples.bean;
+
+/**
+ * @version $Id:$
+ */
+public class User {
+	
+	private int uid;
+	private String lastname;
+	private String firstname;
+	private String username;
+	private String password;
+	private String role;
+
+	public String getFirstname() {
+		return firstname;
+	}
+
+	public void setFirstname(String firstname) {
+		this.firstname = firstname;
+	}
+
+	public String getLastname() {
+		return lastname;
+	}
+
+	public void setLastname(String lastname) {
+		this.lastname = lastname;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getRole() {
+		return role;
+	}
+
+	public void setRole(String role) {
+		this.role = role;
+	}
+
+	public int getUid() {
+		return uid;
+	}
+
+	public void setUid(int uid) {
+		this.uid = uid;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+}

Propchange: cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/User.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/ojb/trunk/java/org/apache/cocoon/ojb/samples/bean/User.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal-cowarp.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal-cowarp.xconf?rev=234177&r1=234176&r2=234177&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal-cowarp.xconf (original)
+++ cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal-cowarp.xconf Sun Aug 21 03:54:05
2005
@@ -16,15 +16,20 @@
 -->
 <!--+
     |
-    | SVN $Id:$
+    | SVN $Id$
     +-->
 <components>
   <component role="org.osoco.cowarp.ApplicationManager"
              class="org.osoco.cowarp.impl.StandardApplicationManager"/>
+  <!-- This security handler uses OJB and the hsqldb for the authentication: -->
   <component role="org.osoco.cowarp.SecurityHandler/portal" 
-             class="org.osoco.cowarp.impl.PipelineSecurityHandler">
-    <authentication-resource>cocoon:raw:/sunrise-authuser</authentication-resource>
-  </component>
+             class="org.apache.cocoon.portal.security.DBSecurityHandler"/>
+  <!-- If you want to use a pipeline for the authentication use this configuration:
+    <component role="org.osoco.cowarp.SecurityHandler/portal" 
+               class="org.osoco.cowarp.impl.PipelineSecurityHandler">
+      <authentication-resource>cocoon:raw:/sunrise-authuser</authentication-resource>
+    </component>
+  -->
   <component role="org.osoco.cowarp.Application/portal" 
              class="org.osoco.cowarp.portal.StandardPortalApplication" 
              security-handler="portal">

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/DBSecurityHandler.java?rev=234177&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
(added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
Sun Aug 21 03:54:05 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005 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.cocoon.portal.security;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ojb.samples.bean.User;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.PersistenceBrokerFactory;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.Query;
+import org.apache.ojb.broker.query.QueryByCriteria;
+import org.osoco.cowarp.AbstractSecurityHandler;
+import org.osoco.cowarp.ApplicationManager;
+
+/**
+ * @version $Id:$
+ */
+public class DBSecurityHandler 
+    extends AbstractSecurityHandler {
+
+    /**
+     * @see org.osoco.cowarp.SecurityHandler#login(Map)
+     */
+    public org.osoco.cowarp.User login(Map loginContext) throws Exception {
+        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+
+        try {
+    		Parameters para = (Parameters) loginContext.get(ApplicationManager.LOGIN_CONTEXT_PARAMETERS_KEY);
+            
+            final Criteria criteria = new Criteria();
+            criteria.addEqualTo("username", para.getParameter("name"));
+            criteria.addEqualTo("password", para.getParameter("password"));
+            final Query query = new QueryByCriteria(User.class, criteria);
+            final Collection c = broker.getCollectionByQuery(query);
+
+            if ( c.size() == 1 ) {
+                User u = (User)c.iterator().next();
+                PortalUser pUser = new PortalUser(u.getUsername());
+                pUser.setUid(u.getUid());
+                pUser.setFirstname(u.getFirstname());
+                pUser.setLastname(u.getLastname());
+                pUser.setPassword(u.getPassword());
+                pUser.setRole(u.getRole());
+                if ( this.getLogger().isInfoEnabled() ) {
+                    this.getLogger().info("Loggedin as: " + u.getFirstname() + " " + u.getLastname()
+ " (" + u.getUsername() + " " + u.getRole() +")");
+                }
+                return pUser;
+            }
+        } finally {
+            broker.close();
+        }
+        return null;
+    }
+    
+    /**
+     * @see org.osoco.cowarp.SecurityHandler#logout(Map, org.osoco.cowarp.User)
+     */
+    public void logout(Map context, org.osoco.cowarp.User user) {
+        // nothing to do
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/PortalUser.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/PortalUser.java?rev=234177&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/PortalUser.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/PortalUser.java Sun
Aug 21 03:54:05 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2005 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.cocoon.portal.security;
+
+import java.util.ArrayList;
+
+import org.osoco.cowarp.StandardUser;
+
+/**
+ * @version $Id:$
+ */
+public class PortalUser extends StandardUser {
+
+	private int uid;
+	private String lastname;
+	private String firstname;
+	private String password;
+	
+	public PortalUser(String uid) {
+		super(uid);
+		this.roles = new ArrayList();
+	}
+
+	public String getFirstname() {
+		return firstname;
+	}
+
+	public void setFirstname(String firstname) {
+		this.firstname = firstname;
+	}
+
+	public String getLastname() {
+		return lastname;
+	}
+
+	public void setLastname(String lastname) {
+		this.lastname = lastname;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getRole() {
+		return (String) roles.get(0);
+	}
+
+	public void setRole(String role) {
+		this.roles.clear();
+		this.roles.add(role);
+	}
+
+	public int getUid() {
+		return uid;
+	}
+
+	public void setUid(int uid) {
+		this.uid = uid;
+	}
+
+	public String getUsername() {
+		return id;
+	}
+
+	public void setUsername(String username) {
+		this.id = username;
+	}
+
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/PortalUser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/security/PortalUser.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/gump.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/gump.xml?rev=234177&r1=234176&r2=234177&view=diff
==============================================================================
--- cocoon/trunk/gump.xml (original)
+++ cocoon/trunk/gump.xml Sun Aug 21 03:54:05 2005
@@ -919,6 +919,7 @@
     <depend project="cocoon-block-authentication-fw"/>
     <depend project="cocoon-block-forms"/>
     <depend project="cocoon-block-cron"/>
+    <depend project="cocoon-block-ojb"/>
     <depend project="cocoon-block-template" type="samples"/>
     <depend project="jtidy"/>
     <depend project="castor"/>

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=234177&r1=234176&r2=234177&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Sun Aug 21 03:54:05 2005
@@ -530,7 +530,10 @@
    </action>
   </release>
   <release version="2.1.8" date="TBD">
-    <action dev="VG" type="update">
+   <action dev="CZ" type="add" fixes-bug="36240" due-to="Jens Maukisch" due-to-email="jmaukisch@s-und-n.de">
+      Portal block: Use OJB and the HSQLDB for authentication of the portal sample.
+    </action>
+     <action dev="VG" type="update">
       Faces block: Updated MyFaces libraries to the SVN r233484, get rid of patched
       version.
     </action>



Mime
View raw message