Package net.sf.mark.authority.po

Examples of net.sf.mark.authority.po.AppUser


   * init所有权限
   * @param userLoginName
   * @return
   */
  public AppUser findByUserLoginName(String userLoginName) {
    AppUser user = userDao.findByUserLoginName(userLoginName);
    if (user != null) {
      Hibernate.initialize(user.getAppRoles());
      for (AppRole role : user.getAppRoles()) {
        Hibernate.initialize(role.getAppAuths());
      }
    }
    return user;
  }
View Full Code Here


    userDao.delete(instance);
  }

  @Override
  public AppUser findById(String id) {
    AppUser user = userDao.findById(id);
    Hibernate.initialize(user.getAppRoles());
    return user;
  }
View Full Code Here

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if (log.isDebugEnabled()) log.debug("========> loadUserByUsername() username: {}", username);

        AppUser user = userService.findByUserLoginName(username);
        if (user == null)
            throw new UsernameNotFoundException("用户(" + username + ")不存在");

        if (log.isDebugEnabled()) {
            log.debug("========> user: {}", user);
            log.debug("========> password: {}", user.getUserPassword());
        }
       
        boolean accountNonExpired = true;
        boolean credentialsNonExpired = true;
        boolean accountNonLocked = true;

        UserDetailsImpl userdetail = new UserDetailsImpl(
                user.getUserLoginName(), user.getUserPassword(), user.getDisableFlag(), accountNonExpired, credentialsNonExpired,
                accountNonLocked, obtainGrantedAuthorities(user), user);

        return userdetail;
    }
View Full Code Here

      return null;

    if (principal instanceof UserDetailsImpl) {
      UserDetailsImpl userDetails = (UserDetailsImpl) principal;

      AppUser appUser = userDetails.getAppUser();

      return appUser;
    } else {
      return null;
    }
View Full Code Here

   *
   * @return
   */
  public static String getCurrentUserId() {

    AppUser appUser = getCurrentUser();

    if (appUser == null)
      return null;

    return appUser.getId();
  }
View Full Code Here

  @Override
  protected void prepareModel() throws Exception {
    if (StringUtils.isNotBlank(filterId)) {
      entity = userService.findById(filterId);
    } else {
      entity = new AppUser();
    }
  }
View Full Code Here

  private static final String USER_ID = "c220319de9b447149afb17592bd8fd4c";
  private static final String ROLE_ID = "c4f90f1c228d45a099e1ff0869e0fe3c";
 
  @Test
  public void testSaveOrUpdate() {
    AppUser instance = new AppUser();
    instance.setUserLoginName("admin");
    instance.setUserPassword("admin");
    instance.setUserEmail("marksong@163.com");
    instance.setUserNickName("马克");
    AppRole role = new AppRole();
    role.setRoleName("管理员");
    instance.getAppRoles().add(role);
    roleService.saveOrUpdate(role);
    userService.saveOrUpdate(instance);
  }
View Full Code Here

    userService.saveOrUpdate(instance);
  }
 
  @Test
  public void test() {
    AppUser instance = userService.findById(USER_ID);
 
    AppRole roleInstance = roleService.findById(ROLE_ID);
   
    Set<AppRole> roles = instance.getAppRoles();
   
    roles.remove(roleInstance);
    userService.saveOrUpdate(instance);
  }
View Full Code Here

    userService.saveOrUpdate(instance);
  }
 
  @Test
  public void testFindById() {
    AppUser instance = userService.findById(USER_ID);
    assertNotNull(instance);
    assertEquals(instance.getId(), USER_ID);
  }
View Full Code Here

TOP

Related Classes of net.sf.mark.authority.po.AppUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.