本文整理了Java中org.apache.shiro.subject.Subject.isRunAs()
方法的一些代码示例,展示了Subject.isRunAs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.isRunAs()
方法的具体详情如下:
包路径:org.apache.shiro.subject.Subject
类名称:Subject
方法名:isRunAs
[英]Returns true if this Subject is 'running as' another identity other than its original one or false otherwise (normal Subject state). See the #runAs method for more information.
[中]如果此主题作为其原始身份以外的另一身份“运行”,则返回true,否则返回false(正常主题状态)。有关更多信息,请参阅#runAs方法。
代码示例来源:origin: apache/shiro
if (subject.isRunAs() && subject instanceof DelegatingSubject) {
try {
Field field = DelegatingSubject.class.getDeclaredField("principals");
代码示例来源:origin: apache/shiro
subject.login(new UsernamePasswordToken("user1", "user1"));
assertFalse(subject.isRunAs());
assertEquals("user1", subject.getPrincipal());
assertTrue(subject.hasRole("role1"));
assertTrue(subject.isRunAs());
assertEquals("user2", subject.getPrincipal());
assertTrue(subject.hasRole("role2"));
assertTrue(subject.isRunAs());
assertEquals("user3", subject.getPrincipal());
assertTrue(subject.hasRole("role3"));
assertTrue(subject.isRunAs());
assertEquals("user2", subject.getPrincipal());
assertTrue(subject.hasRole("role2"));
assertFalse(subject.isRunAs());
assertEquals("user1", subject.getPrincipal());
assertTrue(subject.hasRole("role1"));
代码示例来源:origin: org.apache.shiro/shiro-core
if (subject.isRunAs() && subject instanceof DelegatingSubject) {
try {
Field field = DelegatingSubject.class.getDeclaredField("principals");
内容来源于网络,如有侵权,请联系作者删除!