8990919293949596
/** * 取出Shiro中的当前用户LoginName. */ private String getCurrentUserName() { ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal(); return user.loginName; }
126127128129130131132133
/** * 取出Shiro中的当前用户Id. */ private Long getCurrentUserId() { ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal(); return user.id; }
5859606162636465
6667686970717273
/** * 更新Shiro中当前用户的用户名. */ private void updateCurrentUserName(String userName) { ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal(); user.name = userName; }
41424344454647
private TaskDao mockTaskDao; @Before public void setUp() { MockitoAnnotations.initMocks(this); ShiroTestUtils.mockSubject(new ShiroUser(3L, "foo", "Foo")); }