Hi Sebastian
You could create your own realm implementation to do this (extend
AuthorizingRealm).
and implement doGetAuthenticationInfo to read values from your property file
and implement doGetAuthorizationInfo to read values from your database
Kind regards
Animesh
On Wed, Sep 24, 2008 at 3:36 AM, Sebastian_K <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> is it possible to use one Realm for authentifikation (e.g. PropertiesRealm
> only with password information) and then after login another Realm for
> authorization (e.g. JdbcRealm with no password information but with
> user-role-permission information)?
>
> I tried this, but that's definitely wrong:
>
> DefaultSecurityManager securityManager = new DefaultSecurityManager();
> securityManager.setRealm(propertiesRealm);
>
> UsernamePasswordToken token = new UsernamePasswordToken("sebastian",
> "secret" );
> token.setRememberMe(true);
> Subject user = securityManager.login(token);
> /*...*/ user.isAuthenticated();
> securityManager.setRealm(jdbcRealm);
> user = SecurityUtils.getSubject();
> /*...*/ user.hasRole("clerk");
>
> I get a NoSuchElementExcepition
> Exception in thread "main" java.util.NoSuchElementException
> at java.util.Collections$EmptySet$1.next(Collections.java:2912)
> at
> java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1010)
> at
>
> org.jsecurity.realm.jdbc.JdbcRealm.doGetAuthorizationInfo(JdbcRealm.java:265)
> at
>
> org.jsecurity.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:279)
> at
> org.jsecurity.realm.AuthorizingRealm.hasRole(AuthorizingRealm.java:500)
> at
>
> org.jsecurity.authz.ModularRealmAuthorizer.hasRole(ModularRealmAuthorizer.java:178)
> at
>
> org.jsecurity.mgt.AuthorizingSecurityManager.hasRole(AuthorizingSecurityManager.java:213)
> at
> org.jsecurity.subject.DelegatingSubject.hasRole(DelegatingSubject.java:211)
> at JDBCSample.main(JDBCSample.java:54)
>
> Can somebody help me please.
>
> Sebastian
>
> --
> View this message in context:
> http://n2.nabble.com/Multiple-Realms%2C-one-for-Authentikation%2C-one-for-Authorization-tp1113845p1113845.html
> Sent from the JSecurity User mailing list archive at Nabble.com.
>
>