Java Code Examples for org.apache.shiro.subject.Subject#releaseRunAs()
The following examples show how to use
org.apache.shiro.subject.Subject#releaseRunAs() .
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: RoleController.java From springboot-learn with MIT License | 5 votes |
public void reloadAuthorizingByUserId(User user) { RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager(); UserRealm shiroRealm = (UserRealm) rsm.getRealms().iterator().next(); Subject subject = SecurityUtils.getSubject(); String realmName = subject.getPrincipals().getRealmNames().iterator().next(); SimplePrincipalCollection principals = new SimplePrincipalCollection(user, realmName); subject.runAs(principals); shiroRealm.getAuthorizationCache().remove(subject.getPrincipals()); subject.releaseRunAs(); LOG.info("用户[{}]的权限更新成功!!", user.getUsername()); }
Example 2
Source File: ShiroServiceImpl.java From springboot-shiro with MIT License | 5 votes |
/** * 重新加载用户权限 * * @param user */ @Override public void reloadAuthorizingByUserId(User user) { RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager(); ShiroRealm shiroRealm = (ShiroRealm) rsm.getRealms().iterator().next(); Subject subject = SecurityUtils.getSubject(); String realmName = subject.getPrincipals().getRealmNames().iterator().next(); SimplePrincipalCollection principals = new SimplePrincipalCollection(user, realmName); subject.runAs(principals); shiroRealm.getAuthorizationCache().remove(subject.getPrincipals()); subject.releaseRunAs(); log.info("用户[{}]的权限更新成功!!", user.getUsername()); }
Example 3
Source File: ShiroServiceImpl.java From OneBlog with GNU General Public License v3.0 | 5 votes |
/** * 重新加载用户权限 * * @param user */ private void reloadAuthorizingByUserId(User user) { RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager(); ShiroRealm shiroRealm = (ShiroRealm) rsm.getRealms().iterator().next(); Subject subject = SecurityUtils.getSubject(); String realmName = subject.getPrincipals().getRealmNames().iterator().next(); SimplePrincipalCollection principals = new SimplePrincipalCollection(user.getId(), realmName); subject.runAs(principals); shiroRealm.getAuthorizationCache().remove(subject.getPrincipals()); subject.releaseRunAs(); log.info("用户[{}]的权限更新成功!!", user.getUsername()); }