cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "angeloimm" <angelo...@libero.it>
Subject Re:Getting Authentication info
Date Thu, 09 Dec 2004 10:39:23 GMT
Hi; i'll try to be as clear as possible because i have seen that before i have not been too
clear :-)
I use the authenthication framework for log user; for this reason the framework creates the
authentication session context; in this context there is an xml token so made:

<?xml version="1.0" encoding="ISO-8859-1" ?>
   <authentication xmlns:sql="http://apache.org/cocoon/SQL/2.0"> 
      <ID>carmelo</ID>
         <role>static value undefined</role> 
            <data> 
               <token> 
	<permesso id="PM-GR-1" /> 
	<permesso id="PM-GR-2" /> 
	<permesso id="PM-GR-3" /> 
	<permesso id="PM-GR-4" /> 
	<permesso id="PM-GU-1" /> 
              </token> 
              <idutente>1</idutente> 
              <username>carmelo</username> 
              <password>carmelo</password> 
              <nome>yyyy</nome> 
              <cognome>yyyy</cognome> 
              <email>xxx@xxx.xx</email> 
              <stato>ON</stato> 
            </data> 
</authentication>
Now i'ld like to read this xml from a Java class..... how can i do?
I have written this code:

import org.apache.cocoon.webapps.authentication.context.AuthenticationContextProvider;
import org.apache.cocoon.webapps.session.context.SessionContext;
import org.apache.cocoon.ProcessingException;

import org.apache.log4j.Logger;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class CocoonSesionTest {
  
  private static Logger log = Logger.getLogger( CocoonSesionTest.class.getName() );
  public CocoonSesionTest() {
  }

  public String getDocFrag(){

    AuthenticationContextProvider au = new AuthenticationContextProvider();
    log.info( "$$$$$$$$$$$$$ au è: "+ au );
      try {
        log.info( "Calling: au.getSessionContext(authentication).getXML(authentication).getNodeName()"
);
        if( au == null ){
          
          return "Addirittura au era null";
        }
        SessionContext sc = au.getSessionContext("authentication");
        if( sc == null ){
          
          return "Il session Context era null";
        }
        return "Il valore di ID è: "+sc.getValueOfNode( "ID" );
      }
      catch (ProcessingException ex) {
        
        log.error( ex );
        ex.printStackTrace();
        return null;
    }
  }
  
  public String toString(){
    
    return "Sono il tuo CocoonSesionTest";
  }
}

I have tried to use it in a flowscript:

function buildUserHomePage() {

  log.info("--buildUserHomePage-- send loggedHome.jx");
  log.info( "########## Calling test ###################" );
  var test = new CocoonSesionTest();
  if( test == null ){
  
    log.info( "Era nullo" );
  }else{
  
    log.info( "Non era nullo e ho avuto: "+ test.toString()+" Ora vediamo il metodo" );
    log.info( test.getDocFrag()  );
  }
  log.info( "########## Test Called ###################" );
  cocoon.sendPage( "loggedHome.pjx" );
}

This function is called when the user i logged successfully; but i have this exception:
11:23:06,467 INFO  [Admin module] ########## Calling test ###################
11:23:06,828 INFO  [Admin module] Non era nullo e ho avuto: Sono il tuo CocoonSesionTest Ora
vediamo il metodo
11:23:32,344 INFO  [CocoonSesionTest] $$$$$$$$$$$$$ au è: org.apache.cocoon.webapps.authentication.context.AuthenticationContextProvider@114069b
11:23:33,927 INFO  [CocoonSesionTest] Calling: au.getSessionContext(authentication).getXML(authentication).getNodeName()
11:25:06,219 INFO  [STDOUT] "file:/C:/jboss-3.2.5/server/mySever/tmp/deploy/tmp8944NikkoCM.war/Admin/flow/admin.js",
line 82: uncaught JavaScript exception: 
at buildUserHomePage (file:/C:/jboss-3.2.5/server/mySever/tmp/deploy/tmp8944NikkoCM.war/Admin/flow/admin.js,
Line 82):
java.lang.NullPointerException

Can anybody help me??
Thnks

---------- Initial Header -----------

>From      : "angeloimm" angeloimm@libero.it
To          : "Help Cocoon" users@cocoon.apache.org
Cc          : 
Date      : Thu,  9 Dec 2004 10:17:44 +0100
Subject : Getting Authentication info

> Hi all!
> I use cocoon authentication framework ofr loggin into my application; the problem is
that i need to have user info in a java class... how can i have them? I know that in cocoon
session there is a xml rappresentation of user data, but how can i have this file in a java
class?
> Thanks to all
> 
> 
> 
> ____________________________________________________________
> Libero ADSL: 3 mesi gratis e navighi a 1.2 Mega, senza costi di attivazione.
> Abbonati subito su http://www.libero.it
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



____________________________________________________________
Libero ADSL: 3 mesi gratis e navighi a 1.2 Mega, senza costi di attivazione.
Abbonati subito su http://www.libero.it



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


Mime
View raw message