Hi,

On Thu, 2003-07-03 at 15:01, David Wynter wrote:
> Hi Henning,
> 
> Just trying out your extended user approach below (while killing time until
> I can get some advice on this unresolved 'category' generatino problem).
> 
> I have a question on the example. You replace the TURBINE_NNN for Group,
> Permission and Role and yet they have the same columns and you have left the
> cross tables as the TURBINE supplied ones. Is this because you have to or is

The cross tables do have different foreign key references than the
"original" turbine supplied.

I left the original column names out of lazyness. The Torque Security
Service allows you to configure every column as you wish, but if you
don't change the column names, the defaults fit and you don't have to
put lots of column name definitions into your TR.properties.

In the torque security service docs in the turbine-2.3 site on jakarta
is a list of properties for each security object that you can use to
change the colum names. This is intended for people who have an existing
table scheme and must adapt Turbine to their needs.

> it just for the exercise? In other words, can I just replace TURBINE_USER
> with my CUSTOM_USER and continue to use the torque generate TURBINE_NNN
> tables for the others?

yes, sure. You can e.g. use CUSTOM_USER, TURBINE_GROUP, TURBINE_ROLE and
TURBINE_PERMISSION. In our application, we just wanted to keep one
prefix for all of the Security tables.

However, you must regenerate the ROLE_PERMISSION and USER_GROUP_ROLE
SQL-table definitions, if you use foreign keys. If you use e.g. MySQL,
you might even get away with the existing tables. If you use PostgreSQL,
you don't. _

And_ (caveat) the tables _must_ be named TURBINE_ROLE_PERMISSION and
TURBINE_USER_GROUP_ROLE, because the peers names
(TurbineRolePermissionPeer and TurbineUserGroupRolePeer) are hardcoded
in the Turbine source. :-)

        Regards
                Henning


> 
> regards,
> 
> David
> 
> -----Original Message-----
> From: Henning P. Schmiedehausen [mailto:[EMAIL PROTECTED]
> Sent: 02 July 2003 14:16
> To: [EMAIL PROTECTED]
> Subject: Re: Extending user in T2.3
> 
> 
> Zamek <[EMAIL PROTECTED]> writes:
> 
> >I would like to get a working TR.props file  or a part of TR.prop
> 
> >for compensation, I will correct, and comment the documentation.
> 
> Ok, the following is cut life out of the application running in the
> window behind this one...
> 
> --- cut ---
> services.SecurityService.classname=org.apache.turbine.services.security.torq
> ue.TorqueSecurityService
> [...]
> # -------------------------------------------------------------------
> #
> #  S E C U R I T Y  S E R V I C E
> #
> # -------------------------------------------------------------------
> 
> # Default: org.apache.turbine.services.security.db.DBUserManager
> services.SecurityService.user.manager =
> org.apache.turbine.services.security.torque.TorqueUserManager
> 
> # This is the class that implements the ACL interface.
> services.SecurityService.acl.class =
> org.apache.turbine.util.security.TurbineAccessControlList
> 
> #
> # Configure Object Classes in the Security Service
> #
> 
> # Custom User
> services.SecurityService.user.class = de.intermeta.myapp.security.MyAppUser
> 
> services.SecurityService.group.class =
> org.apache.turbine.services.security.torque.TorqueGroup
> services.SecurityService.permission.class =
> org.apache.turbine.services.security.torque.TorquePermission
> services.SecurityService.role.class =
> org.apache.turbine.services.security.torque.TorqueRole
> 
> #
> # Configure Peers for the Torque Security Service
> #
> services.SecurityService.torque.userPeer.class =
> de.intermeta.myapp.security.om.MyappUserPeer
> services.SecurityService.torque.groupPeer.class =
> de.intermeta.myapp.security.om.MyappGroupPeer
> services.SecurityService.torque.permissionPeer.class =
> de.intermeta.myapp.security.om.MyappPermissionPeer
> services.SecurityService.torque.rolePeer.class =
> de.intermeta.myapp.security.om.MyappRolePeer
> 
> [...]
> 
> --- cut ---
> 
> --- cut --- myapp-schema.xml ---
> <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
> <!DOCTYPE database SYSTEM
> "http://jakarta.apache.org/turbine/dtd/database_3_1.dtd";>
> 
> <database name="myapp"
>   defaultIdMethod="idbroker"
>   defaultJavaType="primitive"
>   defaultJavaNamingMethod="underscore"
>   package="de.intermeta.myapp.security.om">
> 
>   <table name="MYAPP_USER" idMethod="idbroker">
>     <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="LOGIN_NAME" required="true" size="64" type="VARCHAR"
> javaName="UserName"/>
>     <column name="PASSWORD_VALUE" required="true" size="16" type="VARCHAR"
> javaName="Password"/>
>     <column name="FIRST_NAME" required="true" size="64" type="VARCHAR"/>
>     <column name="LAST_NAME" required="true" size="64" type="VARCHAR"/>
>     <column name="EMAIL" size="64" type="VARCHAR"/>
>     <column name="CONFIRM_VALUE" size="16" type="VARCHAR"
> javaName="Confirmed"/>
>     <column name="MODIFIED" type="TIMESTAMP" size="0"/>
>     <column name="CREATED" type="TIMESTAMP" size="0" javaName="CreateDate"/>
>     <column name="LAST_LOGIN" type="TIMESTAMP" size="0"/>
>     <column name="OBJECTDATA" type="VARBINARY"/>
> 
> <!-- Myapp Erweiterungen -->
> 
>     <!-- Aktuell ausgewaehlte Sprachversion -->
>     <column name="MYAPP_LANGUAGE_ID" type="INTEGER" javaName="LanguageId"/>
>     <!-- Aktuell ausgewaehlte Gruppe -->
>     <column name="MYAPP_GRUPPEN_ID" type="INTEGER" javaName="GruppenId"/>
> 
>     <unique>
>         <unique-column name="LOGIN_NAME"/>
>     </unique>
> 
>   </table>
> 
>   <table name="MYAPP_PERMISSION" idMethod="idbroker">
>     <column name="PERMISSION_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="PERMISSION_NAME" required="true" size="64" type="VARCHAR"
> javaName="Name"/>
> 
>     <unique>
>       <unique-column name="PERMISSION_NAME"/>
>     </unique>
> 
>   </table>
> 
>   <table name="MYAPP_ROLE" idMethod="idbroker">
>     <column name="ROLE_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="ROLE_NAME" required="true" size="64" type="VARCHAR"
> javaName="Name"/>
> 
>     <unique>
>         <unique-column name="ROLE_NAME"/>
>     </unique>
> 
>   </table>
> 
>   <table name="MYAPP_GROUP" idMethod="idbroker">
>     <column name="GROUP_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="GROUP_NAME" required="true" type="VARCHAR" size="64"
> javaName="Name"/>
> 
>     <unique>
>         <unique-column name="GROUP_NAME"/>
>     </unique>
> 
>   </table>
> 
>   <table name="TURBINE_ROLE_PERMISSION">
>     <column name="ROLE_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="PERMISSION_ID" required="true" primaryKey="true"
> type="INTEGER"/>
> 
>     <foreign-key foreignTable="MYAPP_ROLE">
>       <reference local="ROLE_ID" foreign="ROLE_ID"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="MYAPP_PERMISSION">
>       <reference local="PERMISSION_ID" foreign="PERMISSION_ID"/>
>     </foreign-key>
>   </table>
> 
>   <table name="TURBINE_USER_GROUP_ROLE">
>     <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="GROUP_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="ROLE_ID" required="true" primaryKey="true"
> type="INTEGER"/>
> 
>     <foreign-key foreignTable="MYAPP_USER">
>       <reference local="USER_ID" foreign="USER_ID"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="MYAPP_GROUP">
>       <reference local="GROUP_ID" foreign="GROUP_ID"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="MYAPP_ROLE">
>       <reference local="ROLE_ID" foreign="ROLE_ID"/>
>     </foreign-key>
>   </table>
> 
> </database>
> --- cut --- myapp-schema.xml ---
> 
> 
> --- cut --- MyAppUser.java ---
> package de.intermeta.myapp.security;
> 
> import org.apache.turbine.services.security.torque.TorqueUser;
> 
> import de.intermeta.myapp.security.om.MyappUser;
> 
> public class MyAppUser
>         extends TorqueUser
> {
>     /**
>      * Constructor.
>      */
>     public MyAppUser()
>     {
>         super();
>     }
> 
>     /**
>      * This Constructor is used when the UserPeerManager
>      * has retrieved a list of Database Objects from the peer and
>      * must 'wrap' them into TorqueRole Objects. You should not use it
> directly!
>      *
>      * @param obj An Object from the peer
>      */
>     public MyAppUser(Persistent obj)
>     {
>         super(obj);
>     }
> 
> 
>     public int getLanguageId()
>     {
>         return ((MyappUser) getPersistentObj()).getLanguageId();
>     }
> 
>     public void setLanguageId(int languageId)
>     {
>         ((MyappUser) getPersistentObj()).setLanguageId(languageId);
>     }
> 
>     public int getGruppenId()
>     {
>         return ((MyappUser) getPersistentObj()).getGruppenId();
>     }
> 
>     public void setGruppenId(int gruppenId)
>     {
>         ((MyappUser) getPersistentObj()).setGruppenId(gruppenId);
>     }
> }
> --- cut --- MyAppUser.java ---
> 
> - Run the schema, you should get de.intermeta.myapp.security.om.<lots of
> classes>
> - add de.intermeta.maxpatch.myapp.security.MyAppUser.java
> - configure Turbine as described above
> - create the tables with maven torque:sql, put them into a database (I use
> PostgreSQL).
> 
> Insert some data into the tables:
> 
> --- cut ---
> INSERT INTO MYAPP_USER
> (USER_ID,LOGIN_NAME,PASSWORD_VALUE,FIRST_NAME,LAST_NAME)
>     VALUES (1,'turbine','turbine','Mr.','Turbine');
> 
> INSERT INTO MYAPP_PERMISSION (PERMISSION_ID,PERMISSION_NAME)
>     VALUES (1,'Myapp');
> 
> INSERT INTO MYAPP_ROLE (ROLE_ID,ROLE_NAME)
>     VALUES (1,'MyappAdmin');
> 
> 
> INSERT INTO MYAPP_GROUP (GROUP_ID,GROUP_NAME)
>     VALUES (1,'global');
> 
> 
> INSERT INTO MYAPP_GROUP (GROUP_ID,GROUP_NAME)
>     VALUES (2,'Myapp');
> 
> 
> INSERT INTO TURBINE_ROLE_PERMISSION (ROLE_ID,PERMISSION_ID)
>     VALUES (1,1);
> 
> 
> INSERT INTO TURBINE_USER_GROUP_ROLE (USER_ID,GROUP_ID,ROLE_ID)
>     VALUES (1,2,1);
> 
> --- cut ---
> 
> Now you should be able to log on with user "turbine" , pw "turbine".
> 
>       Regards
>               Henning
> 
> 
> 
> 
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> [EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/
> 
> Java, perl, Solaris, Linux, xSP Consulting, Web Services
> freelance consultant -- Jakarta Turbine Development  -- hero for hire
> 
> --- Quote of the week: "It is pointless to tell people anything when
> you know that they won't process the message." --- Jonathan Revusky
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
[EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

--- Quote of the week: "It is pointless to tell people anything when
you know that they won't process the message." --- Jonathan Revusky


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to