本文整理汇总了Java中org.apache.shiro.realm.AuthorizingRealm类的典型用法代码示例。如果您正苦于以下问题:Java AuthorizingRealm类的具体用法?Java AuthorizingRealm怎么用?Java AuthorizingRealm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthorizingRealm类属于org.apache.shiro.realm包,在下文中一共展示了AuthorizingRealm类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doStop
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
@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);
}
}
}
}
示例2: clearAuthzRealmCaches
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
/**
* 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 cache = ((AuthorizingRealm) realm).getAuthorizationCache();
if (cache != null) {
log.debug("Clearing cache: {}", cache);
cache.clear();
}
}
}
}
}
示例3: buildRealm
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
public AuthorizingRealm buildRealm(UserService userService, ConfigurationService configService) {
JdbcSaltedRealm realm = new JdbcSaltedRealm(userService, configService);
HashedCredentialsMatcher matcher = new HashedCredentialsMatcher("SHA-256");
matcher.setHashIterations(1024);
matcher.setStoredCredentialsHexEncoded(false);
realm.setCredentialsMatcher(matcher);
return realm;
}
示例4: getDefaultWebSecurityManager
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(AuthorizingRealm realm) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(realm);
dwsm.setCacheManager(getEhCacheManager());
return dwsm;
}
示例5: getSecurityManager
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
/**
* @return the default security manager for this application
*/
@Produces
public WebSecurityManager getSecurityManager() {
if (this.securityManager == null) {
// creates a custom security realm
final AuthorizingRealm realm
= new SecurityRealm(this.accountService);
// instantiate the custom password matcher based on bcrypt
final PasswordMatcher passwordMatcher = new PasswordMatcher();
passwordMatcher.setPasswordService(new BCryptPasswordService());
realm.setCredentialsMatcher(passwordMatcher);
// create the security manager
this.securityManager = new DefaultWebSecurityManager(realm);
// enable the remember me function based on cookies
final CookieRememberMeManager rememberMeManager
= new CookieRememberMeManager();
rememberMeManager.setCipherKey(this.createCypherKey());
this.securityManager.setRememberMeManager(rememberMeManager);
this.securityManager.setCacheManager(new MemoryConstrainedCacheManager());
}
return this.securityManager;
}
示例6: ShiroInitConfig
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
public ShiroInitConfig(AuthorizingRealm realm) {
this.realm = realm;
}
示例7: ShiroConfig
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
public ShiroConfig(AuthorizingRealm realm) {
this.realm = realm;
}
示例8: getRealm
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
public AuthorizingRealm getRealm() {
return realm;
}
示例9: setRealm
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
public void setRealm(AuthorizingRealm realm) {
this.realm = realm;
}
示例10: contributeWebSecurityManager
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
public static void contributeWebSecurityManager(Configuration<Realm> configuration, AuthorizingRealm realm) {
configuration.add(realm);
}
示例11: getShiroRealm
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
@Bean(name = "realm")
public AuthorizingRealm getShiroRealm(AccountService accountService) {
ShiroDbRealm shiroDbRealm = new ShiroDbRealm();
shiroDbRealm.setAccountService(accountService);
return shiroDbRealm;
}
示例12: authorizingRealm
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
@Bean
public AuthorizingRealm authorizingRealm(){
return new SpringRealm();
}
示例13: getSecurityManager
import org.apache.shiro.realm.AuthorizingRealm; //导入依赖的package包/类
/**
* @return the default security manager for this application
*/
@Produces
public WebSecurityManager getSecurityManager() {
if (this.securityManager == null) {
// creates a custom security realm
final AuthorizingRealm realm
= new SecurityRealm(this.accountService);
// instantiate the custom password matcher based on bcrypt
final PasswordMatcher passwordMatcher = new PasswordMatcher();
passwordMatcher.setPasswordService(new BCryptPasswordService());
realm.setCredentialsMatcher(passwordMatcher);
// create the security manager
this.securityManager = new DefaultWebSecurityManager(realm);
// enable the remember me function based on cookies
final CookieRememberMeManager rememberMeManager
= new CookieRememberMeManager();
rememberMeManager.setCipherKey(this.createCypherKey());
this.securityManager.setRememberMeManager(rememberMeManager);
}
return this.securityManager;
}