org.apache.shiro.realm.AuthorizingRealm Java Examples

The following examples show how to use org.apache.shiro.realm.AuthorizingRealm. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RealmManagerImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void doStop() throws Exception {
  eventManager.unregister(this);

  configuration = null;

  // reset shiro caches
  Collection<Realm> realms = realmSecurityManager.getRealms();
  if (realms != null) {
    for (Realm realm : realms) {
      if (realm instanceof AuthenticatingRealm) {
        ((AuthenticatingRealm) realm).setAuthenticationCache(null);
      }
      if (realm instanceof AuthorizingRealm) {
        ((AuthorizingRealm) realm).setAuthorizationCache(null);
      }
    }
  }
}
 
Example #2
Source File: RealmManagerImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Looks up registered {@link AuthorizingRealm}s, and clears their authz caches if they have it set.
 */
private void clearAuthzRealmCaches() {
  // NOTE: we don't need to iterate all the Sec Managers, they use the same Realms, so one is fine.
  Collection<Realm> realms = realmSecurityManager.getRealms();
  if (realms != null) {
    for (Realm realm : realms) {
      if (realm instanceof AuthorizingRealm) {
        Cache<Object, AuthorizationInfo> cache = ((AuthorizingRealm) realm).getAuthorizationCache();
        if (cache != null) {
          log.debug("Clearing cache: {}", cache);
          cache.clear();
        }
      }
    }
  }
}
 
Example #3
Source File: ShiroConfig.java    From fastdep with Apache License 2.0 5 votes vote down vote up
/**
 * securityManager
 *
 * @param authorizingRealm AuthorizingRealm bean
 * @return securityManager
 */
@Bean("securityManager")
@ConditionalOnMissingBean(SecurityManager.class)
public DefaultWebSecurityManager getManager(AuthorizingRealm authorizingRealm) {
    DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
    manager.setRealm(authorizingRealm);
    DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
    DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
    defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
    subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
    manager.setSubjectDAO(subjectDAO);
    return manager;
}
 
Example #4
Source File: ShiroConfiguration.java    From spring-boot-quickstart with Apache License 2.0 5 votes vote down vote up
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(AuthorizingRealm realm) {
    DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
    dwsm.setRealm(realm);
    dwsm.setCacheManager(getEhCacheManager());
    return dwsm;
}
 
Example #5
Source File: ShiroConfiguration.java    From spring-boot-quickstart with Apache License 2.0 4 votes vote down vote up
@Bean(name = "realm")
public AuthorizingRealm getShiroRealm(AccountService accountService) {
    ShiroDbRealm shiroDbRealm = new ShiroDbRealm();
    shiroDbRealm.setAccountService(accountService);
    return shiroDbRealm;
}
 
Example #6
Source File: ShiroConfig.java    From fastdep with Apache License 2.0 2 votes vote down vote up
/**
 * AuthorizingRealm
 *
 * @param jwtUtil jwt util bean
 * @return AuthorizingRealm
 */
@Bean
@ConditionalOnMissingBean(AuthorizingRealm.class)
public AuthorizingRealm authorizingRealm(JwtUtil jwtUtil) {
    return new UserRealm(jwtUtil);
}