cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r234170 - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/hsqldb/conf/ src/blocks/ojb/conf/ src/blocks/ojb/java/org/apache/cocoon/ojb/samples/bean/ src/blocks/portal/conf/ src/blocks/portal/java/org/apache/cocoon/portal/security/
Date Sun, 21 Aug 2005 10:01:51 GMT
Author: cziegeler
Date: Sun Aug 21 03:00:44 2005
New Revision: 234170

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

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

Modified: cocoon/branches/BRANCH_2_1_X/gump.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/gump.xml?rev=234170&r1=234169&r2=234170&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/gump.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/gump.xml Sun Aug 21 03:00:44 2005
@@ -1030,6 +1030,7 @@
     <depend project="cocoon-block-authentication-fw"/>
     <depend project="cocoon-block-forms"/>
     <depend project="cocoon-block-cron"/>
+    <depend project="cocoon-block-ojb"/>
     <depend project="jtidy"/>
     <depend project="castor"/>
     <depend project="commons-collections"/>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/hsqldb/conf/cocoondb.script
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/hsqldb/conf/cocoondb.script?rev=234170&r1=234169&r2=234170&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/hsqldb/conf/cocoondb.script (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/hsqldb/conf/cocoondb.script Sun Aug 21 03:00:44
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/branches/BRANCH_2_1_X/src/blocks/ojb/conf/repository_user.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/conf/repository_user.xml?rev=234170&r1=234169&r2=234170&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/conf/repository_user.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/conf/repository_user.xml Sun Aug 21 03:00:44
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/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/bean/User.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/bean/User.java?rev=234170&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/bean/User.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/bean/User.java
Sun Aug 21 03:00:44 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/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/bean/User.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/cocoon-portal-cowarp.xconf
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/cocoon-portal-cowarp.xconf?rev=234170&r1=234169&r2=234170&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/cocoon-portal-cowarp.xconf (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/cocoon-portal-cowarp.xconf Sun Aug
21 03:00:44 2005
@@ -16,15 +16,21 @@
 -->
 <!--+
     |
-    | SVN $Id:$
+    | SVN $Id$
     +-->
 <xconf xpath="/cocoon" unless="component[@role='org.osoco.cowarp.ApplicationManager']">
   <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>
+             class="org.apache.cocoon.portal.security.DBSecurityHandler"/>
   </component>
+  <!-- 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/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/DBSecurityHandler.java?rev=234170&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
Sun Aug 21 03:00:44 2005
@@ -0,0 +1,75 @@
+/*
+ * 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());
+                System.out.println("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/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/DBSecurityHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/PortalUser.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/PortalUser.java?rev=234170&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/PortalUser.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/PortalUser.java
Sun Aug 21 03:00:44 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/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/security/PortalUser.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=234170&r1=234169&r2=234170&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Sun Aug 21 03:00:44 2005
@@ -196,6 +196,9 @@
 
   <changes>
   <release version="@version@" date="@date@">
+    <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="AN" type="fix">
       XSP block: Move AttributeImpl in xsp.xsl to class scope.
       That allows top-level xsp:logic to define markup generating methods.



Mime
View raw message