Search in sources :

Example 1 with KillBillJdbcRealm

use of org.killbill.billing.util.security.shiro.realm.KillBillJdbcRealm in project killbill by killbill.

the class DefaultSecurityApi method invalidateJDBCAuthorizationCache.

private void invalidateJDBCAuthorizationCache(final String username) {
    final Collection<Realm> realms = ((DefaultSecurityManager) SecurityUtils.getSecurityManager()).getRealms();
    final KillBillJdbcRealm killBillJdbcRealm = (KillBillJdbcRealm) Iterables.tryFind(realms, new Predicate<Realm>() {

        @Override
        public boolean apply(@Nullable final Realm input) {
            return (input instanceof KillBillJdbcRealm);
        }
    }).orNull();
    if (killBillJdbcRealm != null) {
        final SimplePrincipalCollection principals = new SimplePrincipalCollection();
        principals.add(username, killBillJdbcRealm.getName());
        killBillJdbcRealm.clearCachedAuthorizationInfo(principals);
    }
}
Also used : KillBillJdbcRealm(org.killbill.billing.util.security.shiro.realm.KillBillJdbcRealm) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) DefaultSecurityManager(org.apache.shiro.mgt.DefaultSecurityManager) Realm(org.apache.shiro.realm.Realm) AuthorizingRealm(org.apache.shiro.realm.AuthorizingRealm) KillBillJdbcRealm(org.killbill.billing.util.security.shiro.realm.KillBillJdbcRealm)

Example 2 with KillBillJdbcRealm

use of org.killbill.billing.util.security.shiro.realm.KillBillJdbcRealm in project killbill by killbill.

the class TestUtilModuleWithEmbeddedDB method provideRealms.

@Provides
@Singleton
protected Set<Realm> provideRealms(final EmbeddedDB embeddedDB, final SecurityConfig securityConfig) throws IOException {
    final Ini ini = new Ini();
    ini.load("[users]\n" + "tester = tester, creditor\n" + "[roles]\n" + "creditor = invoice:credit, customx:customy\n");
    final Realm iniRealm = new IniRealm(ini);
    final Realm killBillJdbcRealm = new KillBillJdbcRealm(embeddedDB.getDataSource(), securityConfig);
    return ImmutableSet.<Realm>of(iniRealm, killBillJdbcRealm);
}
Also used : Ini(org.apache.shiro.config.Ini) KillBillJdbcRealm(org.killbill.billing.util.security.shiro.realm.KillBillJdbcRealm) IniRealm(org.apache.shiro.realm.text.IniRealm) IniRealm(org.apache.shiro.realm.text.IniRealm) KillBillJdbcRealm(org.killbill.billing.util.security.shiro.realm.KillBillJdbcRealm) Realm(org.apache.shiro.realm.Realm) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Realm (org.apache.shiro.realm.Realm)2 KillBillJdbcRealm (org.killbill.billing.util.security.shiro.realm.KillBillJdbcRealm)2 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 Ini (org.apache.shiro.config.Ini)1 DefaultSecurityManager (org.apache.shiro.mgt.DefaultSecurityManager)1 AuthorizingRealm (org.apache.shiro.realm.AuthorizingRealm)1 IniRealm (org.apache.shiro.realm.text.IniRealm)1 SimplePrincipalCollection (org.apache.shiro.subject.SimplePrincipalCollection)1