You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Katzigas Dimitris <dk...@mylonas.gr> on 2002/10/02 12:06:43 UTC

xsp problem with authentication context

Hi there,

I want to get the username from the authentication session with which i
authenticated and use it in a sql query.
I manage to get the data from the authentication context with some code that
i added to my
xsp file that i read in a Antonio's Gallardo Rivera posting.

My xsp file is:

<?xml version="1.0" encoding="ISO-8859-1"?>

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


<xsp:structure>

<xsp:include>org.apache.cocoon.webapps.session.context.SimpleSessionContext<
/xsp:include>
  <xsp:include>org.w3c.dom.DocumentFragment</xsp:include>
  <xsp:include>org.apache.cocoon.xml.dom.DOMUtil</xsp:include>
</xsp:structure>

  <page>

  <xsp:logic>
    SimpleSessionContext a =
((SimpleSessionContext)<xsp:expr><xsp-session:get-attribute
name="org.apache.cocoon.webapps.auth
entication.SessionContext"/></xsp:expr>);
    DocumentFragment uname =
a.getXML("/atl-handler/authentication/data/username");
    String d = DOMUtil.createText(uname);
  </xsp:logic>

    <content>
      <esql:connection>
        <esql:driver>oracle.jdbc.driver.OracleDriver</esql:driver>
        <esql:dburl>jdbc:oracle:thin:@adis:1521:mis</esql:dburl>
        <esql:username>some_user</esql:username>
        <esql:password>some_password</esql:password>
        <esql:execute-query>
          <esql:query>
            call
atl.atlenvpack.set_user(<esql:parameter><xsp:expr>uname</xsp:expr></esql:par
ameter>)
          </esql:query>
        </esql:execute-query>
        <esql:execute-query>
          <esql:query>
            select sys_context('ATLENV','CUR_USER',10) username  from dual
          </esql:query>
          <esql:results>
            <esql:row-results>
              <contcount><esql:get-string column="username"/></contcount>
            </esql:row-results>
          </esql:results>
        </esql:execute-query>
      </esql:connection>

    </content>
  </page>
</xsp:page>

The problem is that the variable "uname" doesn't got a value by the time the
expression <xsp:expr>uname</xsp:expr> is evaluated.
This problem occures only if i use the expression <xsp:expr>uname</xsp:expr>
inside a <esql:connection> tag. If i use it
somewhere else in the xsp file, i get the username with which i
authenticated.


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: xsp problem with authentication context

Posted by Barbara Post <ba...@ifrance.com>.
Hi Dimitris, I am sorry for you, indeed every user here spent "too much
time" studying... Actions use plain java code, and return sitemap
parameters. They're really fun, you may try them then... Ivan is right ;-)

Babs
----- Original Message -----
From: "Katzigas Dimitris" <dk...@mylonas.gr>
To: <co...@xml.apache.org>; "Atlanoff" <at...@mail.ru>
Sent: Wednesday, October 02, 2002 1:29 PM
Subject: Re: xsp problem with authentication context


> I' am sorry but the action stuff doesn't say anything to me.
> I have little experience on them.
>
> I invested too much time to the authentication framework and i don't wont
to
> waste it.
>
> ----- Original Message -----
> From: "Atlanoff" <at...@mail.ru>
> To: "Katzigas Dimitris" <co...@xml.apache.org>
> Sent: Wednesday, October 02, 2002 2:06 PM
> Subject: Re: xsp problem with authentication context
>
>
> > Hello Dimitris,
> > --
> > How about another way to authorize via actions:
> >
> > ///login-action
> >     ....
> >     login = (String)request.getParameter("login");
> >     password = (String)request.getParameter("password");
> >     String sql = "begin loginproc('" + login + "', '" + password + "');
> end;";
> >     ...
> >     //my static method to execute SQL inside current session
> >     DBUtils.runSQL(session, sql);
> >     ....
> >     if(...) return newSiteMap;
> >     else return null;
> >     ...
> > ///sitemap fragment
> >     <map:match pattern="enter.html">
> >         <map:act type="login">
> >             <map:redirect-to uri="main.html"/>
> >         </map:act>
> >         <map:redirect-to uri="error.html"/>
> >    </map:match>
> >
> > --
> > Best regards,
> >  Иван                            mailto:atlanoff@mail.ru
> >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail:     <co...@xml.apache.org>
> > For additional commands, e-mail:   <co...@xml.apache.org>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>
>
> ________________________________________________________________
> Etudiant: Wanadoo t'offre le Pack eXtense Haut Dйbit soit 150,92 euros
d'йconomies !
> Et pour 1 euro de plus, reзois le CD-ROM du jeu Dark Age of Camelot
> + 1 mois de jeu en rйseau offert !
> Clique ici : http://www.ifrance.com/_reloc/mail.etudiant


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: xsp problem with authentication context

Posted by Katzigas Dimitris <dk...@mylonas.gr>.
I' am sorry but the action stuff doesn't say anything to me.
I have little experience on them.

I invested too much time to the authentication framework and i don't wont to
waste it.

----- Original Message -----
From: "Atlanoff" <at...@mail.ru>
To: "Katzigas Dimitris" <co...@xml.apache.org>
Sent: Wednesday, October 02, 2002 2:06 PM
Subject: Re: xsp problem with authentication context


> Hello Dimitris,
> --
> How about another way to authorize via actions:
>
> ///login-action
>     ....
>     login = (String)request.getParameter("login");
>     password = (String)request.getParameter("password");
>     String sql = "begin loginproc('" + login + "', '" + password + "');
end;";
>     ...
>     //my static method to execute SQL inside current session
>     DBUtils.runSQL(session, sql);
>     ....
>     if(...) return newSiteMap;
>     else return null;
>     ...
> ///sitemap fragment
>     <map:match pattern="enter.html">
>         <map:act type="login">
>             <map:redirect-to uri="main.html"/>
>         </map:act>
>         <map:redirect-to uri="error.html"/>
>    </map:match>
>
> --
> Best regards,
>  Иван                            mailto:atlanoff@mail.ru
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: xsp problem with authentication context

Posted by Atlanoff <at...@mail.ru>.
Hello Dimitris,
--
How about another way to authorize via actions:

///login-action
    ....
    login = (String)request.getParameter("login");
    password = (String)request.getParameter("password");
    String sql = "begin loginproc('" + login + "', '" + password + "'); end;";
    ...
    //my static method to execute SQL inside current session
    DBUtils.runSQL(session, sql);
    ....
    if(...) return newSiteMap;
    else return null;
    ...
///sitemap fragment
    <map:match pattern="enter.html">
        <map:act type="login">
            <map:redirect-to uri="main.html"/>
        </map:act>
        <map:redirect-to uri="error.html"/>
   </map:match>

-- 
Best regards,
 Иван                            mailto:atlanoff@mail.ru



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: xsp problem with authentication context

Posted by Antonio Gallardo Rivera <ag...@agsoftware.dnsalias.com>.
I had the answer. It is posible. I made a <xsp-session:getxml> to work. It 
takes me like 3 days ans his nights. But it works now!

I will check the lastest CVS and send you the files directly as soon as I can 
. I am happy that someone will use this code. :)

It works with Cocoon 2.1-CVS. edition.

Regards,

Antonio Gallardo



El Miércoles, 02 de Octubre de 2002 04:06, Katzigas Dimitris escribió:
> Hi there,
>
> I want to get the username from the authentication session with which i
> authenticated and use it in a sql query.
> I manage to get the data from the authentication context with some code
> that i added to my
> xsp file that i read in a Antonio's Gallardo Rivera posting.
>
> My xsp file is:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <xsp:page
>           language="java"
>           xmlns:xsp="http://apache.org/xsp"
>           xmlns:xsp-request="http://apache.org/xsp/request/2.0"
>           xmlns:xsp-session="http://apache.org/xsp/session/2.0"
>           xmlns:esql="http://apache.org/cocoon/SQL/v2">
>
>
> <xsp:structure>
>
> <xsp:include>org.apache.cocoon.webapps.session.context.SimpleSessionContext
>< /xsp:include>
>   <xsp:include>org.w3c.dom.DocumentFragment</xsp:include>
>   <xsp:include>org.apache.cocoon.xml.dom.DOMUtil</xsp:include>
> </xsp:structure>
>
>   <page>
>
>   <xsp:logic>
>     SimpleSessionContext a =
> ((SimpleSessionContext)<xsp:expr><xsp-session:get-attribute
> name="org.apache.cocoon.webapps.auth
> entication.SessionContext"/></xsp:expr>);
>     DocumentFragment uname =
> a.getXML("/atl-handler/authentication/data/username");
>     String d = DOMUtil.createText(uname);
>   </xsp:logic>
>
>     <content>
>       <esql:connection>
>         <esql:driver>oracle.jdbc.driver.OracleDriver</esql:driver>
>         <esql:dburl>jdbc:oracle:thin:@adis:1521:mis</esql:dburl>
>         <esql:username>some_user</esql:username>
>         <esql:password>some_password</esql:password>
>         <esql:execute-query>
>           <esql:query>
>             call
> atl.atlenvpack.set_user(<esql:parameter><xsp:expr>uname</xsp:expr></esql:pa
>r ameter>)
>           </esql:query>
>         </esql:execute-query>
>         <esql:execute-query>
>           <esql:query>
>             select sys_context('ATLENV','CUR_USER',10) username  from dual
>           </esql:query>
>           <esql:results>
>             <esql:row-results>
>               <contcount><esql:get-string column="username"/></contcount>
>             </esql:row-results>
>           </esql:results>
>         </esql:execute-query>
>       </esql:connection>
>
>     </content>
>   </page>
> </xsp:page>
>
> The problem is that the variable "uname" doesn't got a value by the time
> the expression <xsp:expr>uname</xsp:expr> is evaluated.
> This problem occures only if i use the expression
> <xsp:expr>uname</xsp:expr> inside a <esql:connection> tag. If i use it
> somewhere else in the xsp file, i get the username with which i
> authenticated.
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>