Hello
In the example setion  of cocoon I saw an example of an authentication
framework. They did compare the user input against an xml file (userlist.xml). 

How can I do authentication with a database, extend the authentication
framework to a database?

Here is what I tried to do, but it doesn't work: 

I have installed Tomcat 4.1.29, cocoon 2.1.2, database connections  to
oracle and postgresql is working
connection with mod_jk is also fine.

sitemap.xmap (i have extended the example with my crap)

                <map:pipeline internal-only="true">
                        <!-- This is the authentication respource -->
                        <map:match pattern="authenticate">
                                <map:generate src="auth/userlist.xml"/>
                                <map:transform
src="auth/stylesheets/userwork.xsl">
                                        <map:parameter
name="use-request-parameters" value="true"/>
                                </map:transform>
                                <map:transform type="sql">
                                        <map:parameter name="use-connection"
value="kt01"/>
                                </map:transform>
                                <map:transform
src="auth/stylesheets/userlist.xsl">
                                        <map:parameter
name="use-request-parameters" value="true"/>
                                </map:transform>
                                <map:transform
src="auth/stylesheets/authenticate.xsl">
                                        <map:parameter
name="use-request-parameters" value="true"/>
                                </map:transform>
                                <map:serialize type="xml"/>
                        </map:match>
                </map:pipeline>
<!-- pipeline for internal use ends here -->

Here are the used files (userlist.xml, userlist.xsl, userwork.xsl,
authenticate.xsl) 

userlist.xml: 
<?xml version="1.0" encoding="ISO-8859-1"?>
<authentication/>


userwork.xsl: 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
        xmlns:sql="http://apache.org/cocoon/SQL/2.0";>
<!-- Get the name from the request paramter -->
<xsl:param name="name"/>
<xsl:param name="password"/>
<input type="hidden" name="name" value="$name">
<input type="hidden" name="password" value="$password">



<sqlcmd>
        <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0";>
                <sql:query>
                        select username, password from benutzer
                        where username=normalize-space($username)
                        and password=normalize-space($password)
                </sql:query>
        </sql:execute-query>
</sqlcmd>


userlist.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
        xmlns:sql="http://apache.org/cocoon/SQL/2.0";>

<!-- Get the name from the request paramter -->
<xsl:param name="name"/>
<xsl:param name="password"/>
<input type="hidden" name="name" value="$name">
<input type="hidden" name="password" value="$password">


<xsl:template match="/">
        <authentication>
                <users>
                        <xsl:apply-templates select="page"/>
                </users>
        </authentication>
</xsl:template>

<xsl:template match="sqlcmd">
        <xsl:apply-templates select="sql:rowset"/>
</xsl:template>

<xsl:template match="sql:rowset">
        <xsl:apply-templates/>
</xsl:template>
<xsl:template match="sql:row">
                <user>
                        <name>
                                <xsl:value-of select="sql:username"/>
                        </name>
                </user>
</xsl:template>

authenticate.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<!-- Get the name from the request paramter -->
<xsl:param name="name"/>
<xsl:param name="password"/>

<!-- Aufbau der Seite, beginnend mit users --> 
<xsl:template match="authentication">
  <authentication>
        <xsl:apply-templates select="users"/>
  </authentication>
</xsl:template>


<xsl:template match="users">
    <xsl:apply-templates select="user"/>
</xsl:template>


<xsl:template match="user">
    <!-- Compare the name of the user -->
    <xsl:if test="normalize-space(name) = $name">
        <!-- found, so create the ID -->
        <ID><xsl:value-of select="name"/></ID>
    </xsl:if>
</xsl:template>


</xsl:stylesheet>


Is there a more simple way to do it? or what is wrong?
thanks for any reply 
Tuan

-- 
GMX ProMail (250 MB Mailbox, 50 FreeSMS, Virenschutz, 2,99 EUR/Monat...)
jetzt 3 Monate GRATIS + 3x DER SPIEGEL +++ http://www.gmx.net/derspiegel +++


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

Reply via email to