Jump to content
We've recently updated our Privacy Statement, available here ×

JaasAuthenticationProvider & AuthorityGranter


dlarosa11

Recommended Posts

Hello out there. I've been banging my head for a couple of days and have no more obvious (or not so obvious) strategies for getting JasperServer to use my Jaas classes to authenticate. The authenticate actually works fine, but I choke when trying to grant authority.

[p]

I am looking for a working example of a JaasAuthentication provider with a home-spun AuthorityGranter. The only example I've found is the TestAuthorityGranter class, but I don't see it all rolled up in a working applicationContext-security.xml file.

[p]

I've created a class that implements the acegi AuthorityGranter interface, but when JBoss tries to create the bean from my applicationSContext-security.xml file, I'm getting the following exception:

 

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)

 

Here is my AuthorityGranter:

 

Code:

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 a snippet from my applicationContext-security.xml

 

Code:
[code]
<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

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...