cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kieran Kirwan" <KKir...@dto.ie>
Subject RE: Authentication Framework with Database
Date Fri, 27 Feb 2004 11:58:11 GMT
I'm using XSP to authenticate against my database.

Firstly make sure your DB authentication pipeline returns the same as the XSL sample.
I have 2 pipelines (authenticateXSL and authenticateDB) that return the same XML as follows
--------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?> 
<authentication>
	<ID>user</ID> 
</authentication>

As I have 2 authentication methods I can the decide which to use in the authentication manager
--------------------------------------------
<map:component-configurations>
	<authentication-manager>
	<handlers>
	<handler name="demohandler">
		<redirect-to uri="cocoon:/login"/>
		<authentication uri="cocoon:/authenticateXSL"/>
	</handler>
	</handlers>
	</authentication-manager>
</map:component-configurations>

<map:match pattern="authenticateDB">
<map:generate type="serverpages" src="xsp/getuserAuthentication.xsp"/>
<map:transform src="stylesheets/authenticateDB-filter.xsl"/>
<map:serialize type="xml"/>
</map:match>

<map:match pattern="authenticateXSL">
<map:generate src="content/userlist.xml"/>
	<map:transform src="stylesheets/authenticate.xsl">
	<map:parameter name="use-request-parameters" value="true"/>
	</map:transform>
	<map:serialize type="xml"/>
</map:match>




_____________________________________________
Kieran Kirwan
Executive Transportation Planner
Transportation Modelling Department
 
Dublin Transportation Office
Hainault House,
69/71 St. Stephen's Green,
Dublin 2,
Ireland.
Tel: +353 (0)1 4778113
Fax: +353 (0) 1 478 5935
website: www.dto.ie <http://www.dto.ie/>  
 



-----Original Message-----
From: Tuan Luu [mailto:tuanluu@gmx.ch]
Sent: 27 February 2004 07:20
To: users@cocoon.apache.org
Subject: Authentication Framework with Database



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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
Mail Marshal for the presence of computer viruses.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message