示例#1
0
 @Override
 public void assertAuthorized() throws AuthorizationException {
   Subject subject = getSubject();
   // 数据库角色
   if (jdbcRole != null) {
     subject.checkRole(jdbcRole);
     return;
   }
 }
示例#2
0
  @Test
  public void test() {
    Subject subject = SecurityUtils.getSubject();
    UsernamePasswordToken token = new UsernamePasswordToken(u1.getUsername(), password);
    subject.login(token);

    Assert.assertTrue(subject.isAuthenticated());
    subject.checkRole("admin");
    subject.checkPermission("user:create");

    userService.changePassword(u1.getId(), password + "1");
    userRealm.clearCache(subject.getPrincipals());

    token = new UsernamePasswordToken(u1.getUsername(), password + "1");
    subject.login(token);
  }