org.apache.shiro.realm.AuthenticatingRealm Java Examples
The following examples show how to use
org.apache.shiro.realm.AuthenticatingRealm.
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 |
@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 |
/** * Looks up registered {@link AuthenticatingRealm}s, and clears their authc caches if they have it set. */ private void clearAuthcRealmCaches() { // 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 AuthenticatingRealm) { Cache<Object, AuthenticationInfo> cache = ((AuthenticatingRealm) realm).getAuthenticationCache(); if (cache != null) { log.debug("Clearing cache: {}", cache); cache.clear(); } } } } }
Example #3
Source File: ShiroConfig.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 4 votes |
private void biuldRealms() { Map<String,Realm> customizedRealms = this.customizer.getRealms(); UsernamePasswordRealm usernamePasswordRealm = new UsernamePasswordRealm( this.properties,this.cacheDelegator,this.accountProvider,this.limitListener); usernamePasswordRealm.setCredentialsMatcher(booleanMatcher); if (this.properties.isAuthCacheEnabled()) { usernamePasswordRealm.setAuthorizationCacheName(ShiroProperties.CACHE_NAME_AUTHORIZATION); usernamePasswordRealm.setAuthenticationCacheName(ShiroProperties.CACHE_NAME_AUTHENTICATION); usernamePasswordRealm.setCachingEnabled(Boolean.TRUE); usernamePasswordRealm.setAuthenticationCachingEnabled(Boolean.TRUE); usernamePasswordRealm.setAuthorizationCachingEnabled(Boolean.TRUE); } else { usernamePasswordRealm.setCachingEnabled(Boolean.FALSE); } this.realms.put("usernamePasswordRealm", usernamePasswordRealm); if (this.properties.isHmacEnabled()) { HmacRealm hmacRealm = new HmacRealm( this.properties,this.cacheDelegator,this.statelessAccountProvider); hmacRealm.setCredentialsMatcher(booleanMatcher); hmacRealm.setCachingEnabled(Boolean.FALSE); this.realms.put("hmacRealm", hmacRealm); } if (this.properties.isJwtEnabled()) { JwtRealm jwtRealm = new JwtRealm( this.properties,this.cacheDelegator,this.statelessAccountProvider); jwtRealm.setCredentialsMatcher(booleanMatcher); jwtRealm.setCachingEnabled(Boolean.FALSE); this.realms.put("jwtRealm", jwtRealm); } if (this.properties.isFreePasswordEnabled()||this.properties.isJssoClient()) { UsernameRealm usernameRealm = new UsernameRealm(this.properties,this.accountProvider); usernameRealm.setCredentialsMatcher(booleanMatcher); usernameRealm.setCachingEnabled(Boolean.FALSE); this.realms.put("usernameRealm", usernameRealm); } if(MapUtils.isNotEmpty(customizedRealms)) { boolean errorExist = customizedRealms.values().stream() .filter(r-> (r instanceof AuthenticatingRealm)) .anyMatch(r->Objects.isNull(((AuthenticatingRealm)r).getCredentialsMatcher())); if(errorExist) throw new IllegalConfigException("Realm 必须有对应的CredentialsMatcher"); customizedRealms.forEach((k,v)->this.realms.put(k, v)); } }