You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "J.D. Williams" <jd...@austin.rr.com> on 2007/02/27 15:55:15 UTC

Authentication Framework and database

I have been using the DatabaseAuthenticatorAction, but now need to
switch to the Authentication Framework, using a database as the
authentication resource.

In my authentication resource, the following works:

<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
   <sql:query>select name from user where name = 'example'</sql:query>
</sql:execute-query>

but this does not:

<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query>
  select name from user where name = '<sql:substitute-value
name="${request:param:username}"/>'
</sql:query>
</sql:execute-query>

I can also hard-code the username by appending '?username=example' to
the url. The login page works, so why is the username parameter not
being passed properly?


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


Re: Authentication Framework and database

Posted by "J.D. Williams" <jd...@austin.rr.com>.
Nice catch on the ":" instead of "-"

Unfortunately, it did not work.

Tried your other suggestions, as well, and others, too. Any clue on
where I might look or how I might determine where the problem is?

Here is the authentication matcher.

       <map:match pattern="authenticate">
       <map:generate src="docs/sql-page.xml"/>
       <map:transform type="sql">
          <map:parameter name="use-connection" value="sandbox"/>
          <map:parameter name="show-nr-of-rows" value="true"/>
          <map:parameter name="username"
value="{request-param:username}"/>
        </map:transform>
        <map:transform src="stylesheets/sql2html.xsl">
          <map:parameter name="servletPath"
value="{request:servletPath}"/>
          <map:parameter name="sitemapURI"
value="{request:sitemapURI}"/>
          <map:parameter name="contextPath"
value="{request:contextPath}"/>
          <map:parameter name="file" value=".xml"/>
        </map:transform>
        <map:serialize type="xml"/>
      </map:match>

And here is the query from sql-page.xml

    <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
      <sql:query>select name from user where name =
'<sql:substitute-value name="username"/>'</sql:query>
    </sql:execute-query>


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


RE: Authentication Framework and database

Posted by "J.D. Williams" <jd...@austin.rr.com>.
Tried both. Neither works.

Came up with an XSP hack that will work for now.

On Thu, 2007-03-01 at 09:13 +0100, Armaz Mellati wrote:
> Hi
> 
> 
> It seems to me you are doing this wrong : 
> 	<sql:substitute-value name="request-param:username"/> 
> Replace that with
> 	<sql:substitute-value name="username"/>
> 
> 
> Look carefully at http://cocoon.apache.org/2.1/userdocs/sql-transformer.html right bbelow "Substitution".
> 
> Hope it helps.
> 
> Regards
> Armaz 
> 
> > -----Original Message-----
> > From: J.D. Williams [mailto:jdwilliams@austin.rr.com] 
> > Sent: Tuesday, February 27, 2007 8:57 PM
> > To: users@cocoon.apache.org
> > Subject: Re: Authentication Framework and database
> > 
> > Thought it might be some whitespace from careless XSL 
> > writing, but I got rid of the superfluous whitespace (I 
> > think) and still no luck.
> > 
> > I could use another set of eyes on this to help me see what I 
> > am missing.
> > 
> > The login page is the one from the authentication framework sample in
> > 2.1.9
> > 
> > The only changes I have made to the sitemap are the 
> > authentication resource, as follows:
> > 
> >     <map:pipeline internal-only="true">
> >        <map:match pattern="authenticate">
> >        <map:generate src="docs/sql-page.xml"/>
> >        <map:transform type="sql">
> >           <map:parameter name="use-connection" value="sandbox"/>
> >           <map:parameter name="show-nr-of-rows" value="true"/>
> >           <map:parameter name="username"
> > value="{request-param:username}"/>
> >        </map:transform>
> >         <map:transform src="stylesheets/sql2xml.xsl">
> >           <map:parameter name="use-request-parameters" value="true"/>
> >         </map:transform>
> >         <map:serialize type="xml"/>
> >       </map:match>
> >     </map:pipeline>
> > 
> > Using this query in the sql-page.xml:
> > 
> > <page>
> >   <content>
> >     <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> >       <sql:query>select * from user where name = 
> > '<sql:substitute-value name="request-param:username"/>'</sql:query>
> >     </sql:execute-query>
> >   </content>
> > </page>
> > 
> > And using this XSL:
> > 
> > <?xml version="1.0"?>
> > 
> > <xsl:stylesheet version="1.0"
> >                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >                 xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> > 
> >   <xsl:template match="/page/content/sql:rowset/sql:row">
> >         <authentication
> > xmlns:session="http://apache.org/cocoon/session/1.0">
> >           <xsl:apply-templates select="sql:name"/>
> >         </authentication>
> >   </xsl:template>
> >   
> > <xsl:template match="sql:name">
> >   <ID>
> >   <xsl:value-of select="."/>
> >     </ID>
> > </xsl:template>
> >   
> > </xsl:stylesheet>
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


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


RE: Authentication Framework and database

Posted by "J.D. Williams" <jd...@austin.rr.com>.
Thanks for your effort, though.

On Thu, 2007-03-01 at 09:13 +0100, Armaz Mellati wrote:
> Hi
> 
> 
> It seems to me you are doing this wrong : 
> 	<sql:substitute-value name="request-param:username"/> 
> Replace that with
> 	<sql:substitute-value name="username"/>
> 
> 
> Look carefully at http://cocoon.apache.org/2.1/userdocs/sql-transformer.html right bbelow "Substitution".
> 
> Hope it helps.
> 
> Regards
> Armaz 
> 
> > -----Original Message-----
> > From: J.D. Williams [mailto:jdwilliams@austin.rr.com] 
> > Sent: Tuesday, February 27, 2007 8:57 PM
> > To: users@cocoon.apache.org
> > Subject: Re: Authentication Framework and database
> > 
> > Thought it might be some whitespace from careless XSL 
> > writing, but I got rid of the superfluous whitespace (I 
> > think) and still no luck.
> > 
> > I could use another set of eyes on this to help me see what I 
> > am missing.
> > 
> > The login page is the one from the authentication framework sample in
> > 2.1.9
> > 
> > The only changes I have made to the sitemap are the 
> > authentication resource, as follows:
> > 
> >     <map:pipeline internal-only="true">
> >        <map:match pattern="authenticate">
> >        <map:generate src="docs/sql-page.xml"/>
> >        <map:transform type="sql">
> >           <map:parameter name="use-connection" value="sandbox"/>
> >           <map:parameter name="show-nr-of-rows" value="true"/>
> >           <map:parameter name="username"
> > value="{request-param:username}"/>
> >        </map:transform>
> >         <map:transform src="stylesheets/sql2xml.xsl">
> >           <map:parameter name="use-request-parameters" value="true"/>
> >         </map:transform>
> >         <map:serialize type="xml"/>
> >       </map:match>
> >     </map:pipeline>
> > 
> > Using this query in the sql-page.xml:
> > 
> > <page>
> >   <content>
> >     <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> >       <sql:query>select * from user where name = 
> > '<sql:substitute-value name="request-param:username"/>'</sql:query>
> >     </sql:execute-query>
> >   </content>
> > </page>
> > 
> > And using this XSL:
> > 
> > <?xml version="1.0"?>
> > 
> > <xsl:stylesheet version="1.0"
> >                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >                 xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> > 
> >   <xsl:template match="/page/content/sql:rowset/sql:row">
> >         <authentication
> > xmlns:session="http://apache.org/cocoon/session/1.0">
> >           <xsl:apply-templates select="sql:name"/>
> >         </authentication>
> >   </xsl:template>
> >   
> > <xsl:template match="sql:name">
> >   <ID>
> >   <xsl:value-of select="."/>
> >     </ID>
> > </xsl:template>
> >   
> > </xsl:stylesheet>
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


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


RE: Authentication Framework and database

Posted by Armaz Mellati <ar...@uninett.no>.
Hi


It seems to me you are doing this wrong : 
	<sql:substitute-value name="request-param:username"/> 
Replace that with
	<sql:substitute-value name="username"/>


Look carefully at http://cocoon.apache.org/2.1/userdocs/sql-transformer.html right bbelow "Substitution".

Hope it helps.

Regards
Armaz 

> -----Original Message-----
> From: J.D. Williams [mailto:jdwilliams@austin.rr.com] 
> Sent: Tuesday, February 27, 2007 8:57 PM
> To: users@cocoon.apache.org
> Subject: Re: Authentication Framework and database
> 
> Thought it might be some whitespace from careless XSL 
> writing, but I got rid of the superfluous whitespace (I 
> think) and still no luck.
> 
> I could use another set of eyes on this to help me see what I 
> am missing.
> 
> The login page is the one from the authentication framework sample in
> 2.1.9
> 
> The only changes I have made to the sitemap are the 
> authentication resource, as follows:
> 
>     <map:pipeline internal-only="true">
>        <map:match pattern="authenticate">
>        <map:generate src="docs/sql-page.xml"/>
>        <map:transform type="sql">
>           <map:parameter name="use-connection" value="sandbox"/>
>           <map:parameter name="show-nr-of-rows" value="true"/>
>           <map:parameter name="username"
> value="{request-param:username}"/>
>        </map:transform>
>         <map:transform src="stylesheets/sql2xml.xsl">
>           <map:parameter name="use-request-parameters" value="true"/>
>         </map:transform>
>         <map:serialize type="xml"/>
>       </map:match>
>     </map:pipeline>
> 
> Using this query in the sql-page.xml:
> 
> <page>
>   <content>
>     <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>       <sql:query>select * from user where name = 
> '<sql:substitute-value name="request-param:username"/>'</sql:query>
>     </sql:execute-query>
>   </content>
> </page>
> 
> And using this XSL:
> 
> <?xml version="1.0"?>
> 
> <xsl:stylesheet version="1.0"
>                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                 xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> 
>   <xsl:template match="/page/content/sql:rowset/sql:row">
>         <authentication
> xmlns:session="http://apache.org/cocoon/session/1.0">
>           <xsl:apply-templates select="sql:name"/>
>         </authentication>
>   </xsl:template>
>   
> <xsl:template match="sql:name">
>   <ID>
>   <xsl:value-of select="."/>
>     </ID>
> </xsl:template>
>   
> </xsl:stylesheet>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


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


Re: Authentication Framework and database

Posted by "J.D. Williams" <jd...@austin.rr.com>.
Thought it might be some whitespace from careless XSL writing, but I got
rid of the superfluous whitespace (I think) and still no luck.

I could use another set of eyes on this to help me see what I am
missing.

The login page is the one from the authentication framework sample in
2.1.9

The only changes I have made to the sitemap are the authentication
resource, as follows:

    <map:pipeline internal-only="true">
       <map:match pattern="authenticate">
       <map:generate src="docs/sql-page.xml"/>
       <map:transform type="sql">
          <map:parameter name="use-connection" value="sandbox"/>
          <map:parameter name="show-nr-of-rows" value="true"/>
          <map:parameter name="username"
value="{request-param:username}"/>
       </map:transform>
        <map:transform src="stylesheets/sql2xml.xsl">
          <map:parameter name="use-request-parameters" value="true"/>
        </map:transform>
        <map:serialize type="xml"/>
      </map:match>
    </map:pipeline>

Using this query in the sql-page.xml:

<page>
  <content>
    <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
      <sql:query>select * from user where name = '<sql:substitute-value
name="request-param:username"/>'</sql:query>
    </sql:execute-query>
  </content>
</page>

And using this XSL:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:sql="http://apache.org/cocoon/SQL/2.0">

  <xsl:template match="/page/content/sql:rowset/sql:row">
        <authentication
xmlns:session="http://apache.org/cocoon/session/1.0">
          <xsl:apply-templates select="sql:name"/>
        </authentication>
  </xsl:template>
  
<xsl:template match="sql:name">
  <ID>
  <xsl:value-of select="."/>
    </ID>
</xsl:template>
  
</xsl:stylesheet>


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


Re: Authentication Framework and database

Posted by "J.D. Williams" <jd...@austin.rr.com>.
Well, I still have not gotten it to work, and frankly I am just guessing
as to what the problem is.

You know, it is quite frustrating to spend several days looking through
docs and email archives and see this same problem over and over, yet I
find no solution. Several email threads to the list have died out with
no solution apparent.

Frustrating.

On Tue, 2007-02-27 at 16:25 +0100, Tobia wrote:
> J.D. Williams scrisse:
> > <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> >   <sql:query>
> >     select name from user where name = 
> >         '<sql:substitute-value name="${request:param:username}"/>'
> >   </sql:query>
> > </sql:execute-query>
> 
> That looks wrong.
> 
> Try name="request-param:username", with a dash in request-param and
> without the ${ } construct.  If that doesn't work, you will have to pass
> the parameter to the SQL transformer from the sitemap:
> 
> 	<map:transform type="sql">
> 	  <map:parameter name="username" value="{request-param:username}"/>
> 	</map:transform>
> 
> and then use the plain name:
> 
> 	<sql:substitute-value name="username"/>
> 
> 
> Tobia
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


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


Re: Authentication Framework and database

Posted by Tobia <to...@linux.it>.
J.D. Williams scrisse:
> <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>   <sql:query>
>     select name from user where name = 
>         '<sql:substitute-value name="${request:param:username}"/>'
>   </sql:query>
> </sql:execute-query>

That looks wrong.

Try name="request-param:username", with a dash in request-param and
without the ${ } construct.  If that doesn't work, you will have to pass
the parameter to the SQL transformer from the sitemap:

	<map:transform type="sql">
	  <map:parameter name="username" value="{request-param:username}"/>
	</map:transform>

and then use the plain name:

	<sql:substitute-value name="username"/>


Tobia

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


Re: Authentication Framework and database

Posted by Andre Juffer <An...@oulu.fi>.
J.D. Williams wrote:
> I have been using the DatabaseAuthenticatorAction, but now need to
> switch to the Authentication Framework, using a database as the
> authentication resource.
> 
> In my authentication resource, the following works:
> 
> <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>    <sql:query>select name from user where name = 'example'</sql:query>
> </sql:execute-query>
> 
> but this does not:
> 
> <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> <sql:query>
>   select name from user where name = '<sql:substitute-value
> name="${request:param:username}"/>'
> </sql:query>
> </sql:execute-query>

You would need request-param:username instead of request:param:username. 
(Note the dash.)

> 
> I can also hard-code the username by appending '?username=example' to
> the url. The login page works, so why is the username parameter not
> being passed properly?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
NordProt                     | WWW: www.nordprot.org

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