Package org.springside.examples.showcase.common.entity

Examples of org.springside.examples.showcase.common.entity.User


  /**
   * 获取用户Detail信息的回调函数.
   */
  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {

    User user = accountManager.findUserByLoginName(username);
    if (user == null) {
      throw new UsernameNotFoundException("用户" + username + " 不存在");
    }

    Set<GrantedAuthority> grantedAuths = obtainGrantedAuthorities(user);

    //showcase的User类中无以下属性,暂时全部设为true.
    boolean enabled = true;
    boolean accountNonExpired = true;
    boolean credentialsNonExpired = true;
    boolean accountNonLocked = true;

    OperatorDetails userDetails = new OperatorDetails(user.getLoginName(), user.getShaPassword(), enabled,
        accountNonExpired, credentialsNonExpired, accountNonLocked, grantedAuths);
    //加入登录时间信息和用户角色
    userDetails.setLoginTime(new Date());
    userDetails.setRoleList(user.getRoleList());
    return userDetails;
  }
View Full Code Here


  @GET
  @Path("{id}")
  @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + CHARSET })
  public UserDTO getUser(@PathParam("id") String id) {
    try {
      User entity = accountManager.getInitedUser(id);
      UserDTO dto = dozer.map(entity, UserDTO.class);
      return dto;
    } catch (ObjectNotFoundException e) {
      String message = "用户不存在(id:" + id + ")";
      logger.error(message, e);
View Full Code Here

  @GET
  @Path("/search")
  public Response searchUser(@QueryParam("name") String name,
      @QueryParam("format") @DefaultValue("json") String format) {
    try {
      User entity = accountManager.searchLoadedUserByName(name);
      if ("html".equals(format)) {
        //返回html格式的特定字符串.
        String html = "<div>" + entity.getName() + ", your mother call you...</div>";
        return Response.ok(html, MediaType.TEXT_HTML + CHARSET).build();
      } else {
        //返回JSON格式的对象.
        UserDTO dto = dozer.map(entity, UserDTO.class);
        return Response.ok(dto, MediaType.APPLICATION_JSON).build();
View Full Code Here

   */
  public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

    WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
    PasswordEncoder encoder = new ShaPasswordEncoder();
    User user = accountManager.findUserByLoginName(pc.getIdentifier());

    if (user == null) {
      throw new IOException("wrong login name " + pc.getIdentifier());
    }
    //对WSPasswordCallback中的明文密码进行sha1散列, 再与数据库中保存的用户sha1散列密码进行比较.
    if (!encoder.isPasswordValid(user.getShaPassword(), pc.getPassword(), null)) {
      throw new IOException("wrong password " + pc.getPassword() + " for " + pc.getIdentifier());
    }
  }
View Full Code Here

   * 根据用户名查出数据库中用户的明文密码,交由框架进行处理并与客户端提交的Digest进行比较.
   */
  public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
    String loginName = pc.getIdentifier();
    User user = accountManager.findUserByLoginName(loginName);
    if (user == null) {
      throw new IOException("wrong login name " + pc.getIdentifier());
    }

    pc.setPassword(user.getPlainPassword());
  }
View Full Code Here

  @Test
  public void normal() {

    Function<String, User> computingFunction = new Function<String, User>() {
      public User apply(String key) {
        User user = accountManager.getUser(key);
        return user;
      }
    };

    ConcurrentMap<String, User> userMap = new MapMaker().concurrencyLevel(32).expiration(7, TimeUnit.DAYS)
View Full Code Here

TOP

Related Classes of org.springside.examples.showcase.common.entity.User

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.