Title: $authz.hasPermission($contact, "16,1") throws npe

I am playing with the "contact" sample and try to change all jsps to velocity.

However, I think there is a bug in org.acegisecurity.taglibs.velocity.AuthzImpl.

A line like this throws a npe

    #if( $authz.hasPermission($contact, "16,1") )

I traced the code. AuthzImpl.setAppCtx(ApplicationContext appCtx) is never called and I couldnt figure out how to make it called from a web app.

Hence I extended the class and made mine implements ViewTool to set AppCtx in init(), and it worked. But should this code be incorporated into AuthzImpl?

========================================================

package sample.contact.security;

import org.acegisecurity.taglibs.velocity.AuthzImpl;

import org.apache.velocity.tools.view.context.ViewContext;

import org.apache.velocity.tools.view.tools.ViewTool;

import org.springframework.web.context.support.WebApplicationContextUtils;

public class MyAuthzImpl

  extends AuthzImpl

  implements ViewTool

{

  public void init( Object obj )

  {

    if ( !( obj instanceof ViewContext ) )

    {

      throw new IllegalArgumentException( "Tool can only be initialized with a ViewContext" );

    }

    ViewContext context = ( ViewContext ) obj;

    setAppCtx( WebApplicationContextUtils.getWebApplicationContext(context.getServletContext()));

  }

}

_______________________________________________
Home: http://acegisecurity.org
Acegisecurity-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer

Reply via email to