示例#1
0
 @Transactional(readOnly = true)
 public String getCurrentUsername() {
   Subject subject = SecurityUtils.getSubject();
   if (subject != null) {
     Principal principal = (Principal) subject.getPrincipal();
     if (principal != null) {
       return principal.getUsername();
     }
   }
   return null;
 }
示例#2
0
 @Transactional(readOnly = true)
 public Admin getCurrent() {
   Subject subject = SecurityUtils.getSubject();
   if (subject != null) {
     Principal principal = (Principal) subject.getPrincipal();
     if (principal != null) {
       return adminDao.find(principal.getId());
     }
   }
   return null;
 }