1 Reply Latest reply: Jan 11, 2012 5:41 PM by Rafael Martony RSS

    JaasAuthenticationProvider and AuthorityGranter

    Domenic LaRosa Newbie

      I'm trying to get JasperServer to run in JBoss using my JAAS implementation. I can get the authentication to work, but I'm having a problem with the AuthorityGranter bean in my applicationContext-security.xml file.

      Here's the error that I get when JBoss tries to load my JasperServer.war file:

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ptiJaasAuthenticationProvider' defined in ServletContext resource [/WEB-INF/applicationContext-security.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
      PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [org.acegisecurity.providers.jaas.AuthorityGranter[]] for property 'authorityGranters'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.perimeter.authentication.PtiAuthorityGranter] to required type [org.acegisecurity.providers.jaas.AuthorityGranter] for property 'authorityGranters[0]': no matching editors or conversion strategy found
      
      Caused by:
      
      org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
      
      PropertyAccessException 1:
      
      org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [org.acegisecurity.providers.jaas.AuthorityGranter[]] for property 'authorityGranters'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.perimeter.authentication.PtiAuthorityGranter] to required type [org.acegisecurity.providers.jaas.AuthorityGranter] for property 'authorityGranters[0]': no matching editors or conversion strategy found
      
      Caused by:
      
      java.lang.IllegalArgumentException: Cannot convert value of type [com.perimeter.authentication.PtiAuthorityGranter] to required type [org.acegisecurity.providers.jaas.AuthorityGranter] for property 'authorityGranters[0]': no matching editors or conversion strategy found
      
       at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:224)
      
       at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:124)
      
       at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:282)
      
       at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:197)
      
       at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate


      My AuthorityGranter class is as follows:
      public class PtiAuthorityGranter implements org.acegisecurity.providers.jaas.AuthorityGranter
      {
       public Set grant(Principal principal)
       {
       Set rtnSet = new HashSet();
      
       // just add administrator right off the bat for now
       // TODO: check database for permissions and add appropriate ones
       rtnSet.add("ROLE_ADMINISTRATOR");
      
       // if (principal.getName().equals("TEST_PRINCIPAL")) {
       // rtnSet.add("ROLE_TEST1");
       // rtnSet.add("ROLE_TEST2");
       // }
      
       return rtnSet;
       }
      }


      Here's the snippet from applicationContext-security.xml:

       <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
       <property name="providers">
       <list>
       <!-- here is the list of authentication mechanisms -->
       <ref local="ptiJaasAuthenticationProvider"/>
       </list>
       </property>
       </bean>
      
       <bean id="ptiJaasAuthenticationProvider" class="org.acegisecurity.providers.jaas.JaasAuthenticationProvider">
      
       <!-- TODO: we don't actually want to look here,
       we should look in server/default/conf/login-conf.xml for jboss -->
       <property name="loginConfig">
       <value>/WEB-INF/login.conf</value>
       </property>
      
       <property name="loginContextName">
       <value>RealtimeAppDb</value>
       </property>
      
       <property name="callbackHandlers">
       <list>
       <bean class="org.acegisecurity.providers.jaas.JaasNameCallbackHandler"/>
       <bean class="org.acegisecurity.providers.jaas.JaasPasswordCallbackHandler"/>
       </list>
       </property>
      
       <property name="authorityGranters">
       <list>
       <bean class="com.perimeter.authentication.PtiAuthorityGranter"/>
       </list>
       </property>
       </bean>
      


      Any help, of course, is greatly appreciated.

      Domenic