Good question, here are my reasons:

When the user get authetificated, his rights are saved in the authentication
context. My webapp is a (kind of) project managing tool.
The authentication pipeline returns all rights of a user for all projects.It
looks like this:

<authentication>
...
<rights>
<projects>
 <project name="Project1">
   <admin>true</admin>
   <developer>true</developer>
 </project>
 <project name="Project2">
   <admin>false</admin>
   <developer>true</developer>
  </project>
 </projects>
</rights>
...
</authentication>

When a user navigates inside a certain project I wan tto retrieve the rights
of this user of this special project

My problem was e.g. how to access the "admin" node value of a certain
project in the sitemap.

You can not nest input-module directives in the sitemap, that's what I would
have needed.

Something like:
...
<map:transform type="xslt" src="stylesheets/test.xsl">
        <map:parameter name="adminprojects"
value="{session-context:authentication/authentication/rights/projects/project[text()="{session-attr:project}"]/admin"/>
</map:transform>

However, you can't use the seeion-atrribute input module inside the session
context input module, unfortunately.

There would be work-arounds of course, like using an xsp or the session
transformer to retrieve the necessary information but I wanted a "shorter"
way. I wanted to avoid to write a new pipeline for it and then merge the
result of this pipeline with pipeline that the rights-information.

The javagurus in the group, did not answer yet, maybe I have to adress to
them directly ;-),

If you could follow all this and you have a solution, please tell,

Regards,

Stephanie



> Stephanie
> 
> Sorry to not answer this question direct, and I am sure the 
> Java gurus will help, but... why do you need this Action at
> all, when you can use the SessionPropagatorAction to
> store user info into the sitemap for access by any pipeline, or
> use the session-context to retrieve user info for protected
> pipelines ?
> 
> Derek
> 
> >>> [EMAIL PROTECTED] 2004/07/19 10:28:16 AM >>>
> Hi all,
> 
> I get a NullPointerException in my GetRolesAction, hope somebody of you
> guys
> can help me.
> 
> With my action I want to make the user roles available to the sitemap.
> The
> roles are stored in the Authentication Context. 
> 
> All I want to do is read out the roles from the Authentication context
> and
> put it in the map that is returned to the sitemap.
> 
> However I get a NullPointerException when retrieving the
> authentication
> context.
> I "followed" the exception to the Class AuthenticationContextProvider.
> I
> guess the problem is that the ServiceManager is not initialized, but
> is
> null.
> 
> How can I make my Code working? Do I have to call the service() method
> of
> the AuthenticationContextProvider to set the serviceManager instance??
> 
> Thanks alot for bringing light into my darkness,
> 
> Regards,
> 
> Stephanie
> 
> P.S.: Code and Exception Text see below:
> 
> ________________________________________________________________________
> 
> public class GetRolesAction extends AbstractAction implements
> ThreadSafe,
> Initializable{
>       
>       protected AuthenticationContextProvider contextProvider; 
> 
>       public void initialize() throws Exception {
>               contextProvider = new AuthenticationContextProvider();
>       }
> 
>       
>       public Map act(
>               Redirector redirector,
>               SourceResolver sourceResolver,
>               Map objectModel,
>               String src,
>               Parameters parameters)
>               throws Exception {
>                       
>               Map map = null;
>               
>               //check parameter
>               final String project =
> parameters.getParameter("project");
>               if(project == null){
>                       throw new ProcessingException("GetRolesAction
> requires the parameter
> 'project'.");
>               }
>               if (contextProvider == null){
>                       throw new NullPointerException("Can't get
> contextProvider.");
>               }
>               AuthenticationContext sessionContext
> =
> null;
>               
>
                
if(contextProvider.existsSessionContext(AuthenticationConstants.SESSION_CONTEXT_NAME)){
> 
>                       sessionContext =
> (AuthenticationContext)
>
contextProvider.getSessionContext(AuthenticationConstants.SESSION_CONTEXT_NAME);
>               }               
>               else{
>                                       throw new
> NullPointerException("Can't get sessionContext");
>               }
>               
>               map = new HashMap(3);
>               //check
> roles
>               if
>
(sessionContext.getSingleNode("authentication/rights/projects/[EMAIL 
PROTECTED]"+project+"]/admin")!=null)
>                       map.put("admin","true");
>               else
>                       map.put("admin","false");
>               
>               if
>
(sessionContext.getSingleNode("authentication/rights/projects/[EMAIL 
PROTECTED]"+project+"]/developer")!=null)
>                       map.put("developer","true");
>               else
>                       map.put("developer","false");
>                       
>               if
>
(sessionContext.getSingleNode("authentication/rights/projects/[EMAIL 
PROTECTED]"+project+"]/guest")!=null)
>                       map.put("guest","true");
>               else
>                       map.put("guest","false");
>               
>               return
> map;
>       }
> 
> }
> ------------------------------------------------------------------------
> 
> 
> java.lang.NullPointerException
> 
>       at
>
org.apache.cocoon.webapps.authentication.context.AuthenticationContextProvider.getSessionContext(AuthenticationContextProvider.java:97)
> 
>       at
> archivesystem.roles.GetRolesAction.act(GetRolesAction.java:57)
> 
>       at
>
org.apache.cocoon.components.treeprocessor.sitemap.ActTypeNode.invoke(ActTypeNode.java:152)
> 
>       at
>
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:84)
> 
> ....
> --------------------------------------------------------------------------
> 
> My Sitemap snippet 
> 
> <map:match pattern="protected-*">
>   <map:act type="auth-protect">
>     <map:match pattern="protected-delivery">
>               <map:generate type="request"/>
>         <map:act type="getRoles">
>           <map:parameter name="project"
> value="{session-attr:project}"/>
>               <map:select type="parameter">
>                 <map:parameter name="parameter-selector-test"
> value="{admin}"/>
>                <map:when test="true">
>                 <map:transform type="xslt"
> src="stylesheets/deliveries.xsl"/>
>               </map:when>
>               <map:otherwise>
>               <map:transform type="xslt"
> src="stylesheets/deliveries-readonly.xsl"/>
>               </map:otherwise>
>              </map:select>
>             <map:serialize type="html"/>
>             </map:act>
>       </map:match>
>       </map:act>
> </map:match>
> 
> 
> --------------------------------------------------------------------------
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
> 
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> MailScanner thanks transtec Computers for their support.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to