cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdaw...@bodycare-int.co.uk
Subject Authentication - Accessing The Context
Date Mon, 31 Mar 2003 08:28:40 GMT
I'm using the authentication framework in version 2.1 of cocoon.

I can get the system to authenticate a user and then re-direct to
the correct page based on whether they were authenticated or
not.

However, I'm having a problem trying to retrieve information from
the 'authentication' context of the session when the user is accepted.
I get a context does not exist error when I try and access the context
in login_ok.xml. 

If I switch logging to DEBUG level I get the following error before the
user is authenticated.

[NamespaceNormalizingDOMStreamer] Encountered a 
DOM Element without a localName. DOM Level 1 trees 
are not supported by this DOMStreamer.

I think it occurs when the Authentication system
attempts to write the <authentication> node that I return from check.xsp
to the log file.


What am I missing ???

Also is it possible to access the information stored in the 
'authentication'
context via 'xsp-session' in an XSP.

Thanks

Tony

====================== sitemap.xmap 
=========================================
  <map:pipelines>
    <map:component-configurations>
      <authentication-manager>
        <handlers>
          <handler name="global">
            <redirect-to uri="cocoon://login_page"/>
            <authentication uri="cocoon:raw://check"/>
          </handler>
        </handlers>
      </authentication-manager>
    </map:component-configurations>
    <map:pipeline>
      <map:match pattern="check">
        <map:generate type="serverpages" src="check.xsp"/>
        <map:serialize type="xml"/>
      </map:match>
      <map:match pattern="login_page">
        <map:read mime-type="text/xhtml" src="login_page.html"/>
      </map:match>
      <map:match pattern="login_ok">
        <map:generate src="login_ok.xml"/>
        <map:transform type="session"/>
        <map:serialize type="xml"/>
      </map:match>
      <map:match pattern="login">
        <map:act type="auth-login">
          <map:parameter name="handler" value="global"/>
          <map:parameter name="parameter_userid" value="{request-param:name}"/>
          <map:parameter name="parameter_password" value="{request-param:password}"/>
          <map:redirect-to uri="login_ok"/>
        </map:act>
        <map:read mime-type="text/html" src="login_failed.html"/>
      </map:match>
      <map:match pattern="logout">
        <map:act type="auth-logout">
          <map:parameter name="handler" value="global"/>
          <map:redirect-to uri="login_page"/>
        </map:act>
      </map:match>
    </map:pipeline>
  </map:pipelines>

========================== login_ok.xml 
=============================================================
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:session="http://cocoon.apache.org/session/1.0" >
        <session:getxml context="authentication" path="/authentication/ID" />
</page>


========================= check.xsp 
================================================================
<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xsl"?>

<xsp:page        language="java" 
                        xmlns:xsp="http://apache.org/xsp" 
                        xmlns:esql="http://apache.org/cocoon/SQL/v2" 
                        xmlns:xsp-request="http://apache.org/xsp/request/2.0"
                        xmlns:log="http://apache.org/xsp/log/2.0" >

<authentication>
        <esql:connection>
                <esql:pool>web</esql:pool>
                <esql:execute-query>
                        <esql:query>
                                select id, site from users where username 
= '<xsp-request:get-parameter name="userid" />' and password = '<xsp-request:get-parameter
name="password" />'
                        </esql:query> 
                        <esql:results>
                                <esql:row-results>
                                        <ID><esql:get-int column="id" /></ID>
                                        <data><esql:get-string column="site" /></data>
                                </esql:row-results>
                        </esql:results>
                        <esql:no-results>
                                <data>No match found - <xsp-request:get-query-string
as="string" /></data>
                        </esql:no-results>
                </esql:execute-query>
        </esql:connection>
</authentication> 
</xsp:page>



Mime
View raw message