org.apache.shiro.subject.Subject.releaseRunAs()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.apache.shiro.subject.Subject.releaseRunAs()方法的一些代码示例,展示了Subject.releaseRunAs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.releaseRunAs()方法的具体详情如下:
包路径:org.apache.shiro.subject.Subject
类名称:Subject
方法名:releaseRunAs

Subject.releaseRunAs介绍

[英]Releases the current 'run as' (assumed) identity and reverts back to the previous 'pre run as' identity that existed before #runAs runAs was called.

This method returns 'run as' (assumed) identity being released or null if this Subject is not operating under an assumed identity.
[中]释放当前的“运行方式”(假定)标识,并恢复到调用#运行方式运行方式之前存在的上一个“预运行方式”标识。
此方法返回正在释放的“运行方式”(假定)标识,如果此主题未在假定标识下运行,则返回null。

代码示例

代码示例来源:origin: apache/shiro

subject.releaseRunAs();
subject.releaseRunAs();

代码示例来源:origin: theonedev/onedev

@Override
public void process(IFormSubmitter submittingComponent) {
  SecurityUtils.getSubject().runAs(getUser().getPrincipals());
  try {
    super.process(submittingComponent);
  } finally {
    SecurityUtils.getSubject().releaseRunAs();
  }
}

代码示例来源:origin: java-aodeng/hope-plus

/***
 * 重新加载用户权限
 * @param user
 */
@Override
public void reloadAuthorizingByUserId(SysUser user) {
  RealmSecurityManager realmSecurityManager=(RealmSecurityManager) SecurityUtils.getSecurityManager();
  HopeShiroRealm hopeShiroReam=(HopeShiroRealm)realmSecurityManager.getRealms().iterator().next();
  Subject subject=SecurityUtils.getSubject();
  String realmName=subject.getPrincipals().getRealmNames().iterator().next();
  SimplePrincipalCollection simplePrincipalCollection=new SimplePrincipalCollection(user,realmName);
  subject.runAs(simplePrincipalCollection);
  hopeShiroReam.getAuthorizationCache().remove(subject.getPrincipals());
  subject.releaseRunAs();
  log.info("[以下用户权限更新成功!]-[{}]",user.getUsername());
}

代码示例来源:origin: zhangyd-c/OneBlog

/**
 * 重新加载用户权限
 *
 * @param user
 */
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.getId(), realmName);
  subject.runAs(principals);
  shiroRealm.getAuthorizationCache().remove(subject.getPrincipals());
  subject.releaseRunAs();
  log.info("用户[{}]的权限更新成功!!", user.getUsername());
}

代码示例来源:origin: zhangyd-c/springboot-shiro

/**
 * 重新加载用户权限
 *
 * @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.getId(), realmName);
  subject.runAs(principals);
  shiroRealm.getAuthorizationCache().remove(subject.getPrincipals());
  subject.releaseRunAs();
  LOG.info("用户[{}]的权限更新成功!!", user.getUsername());
}

代码示例来源:origin: theonedev/onedev

SecurityUtils.getSubject().releaseRunAs();

相关文章