Package org.springframework.security.core.userdetails

Examples of org.springframework.security.core.userdetails.User


        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        UserDetails userDetails = new User(adminUser, "FAKE_PASSWORD", true, true, true, true, authorities);
        Authentication authentication = new TestingAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities);
        SecurityContextHolder.getContext().setAuthentication(authentication);
    }
View Full Code Here


                            getEntitlementNameFromRoleId(role.getId())));
                }
            }
        }

        return new User(username, "<PASSWORD_PLACEHOLDER>", true, true, true, true, authorities);
    }
View Full Code Here

        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        final UserDetails userDetails = new User("admin", "FAKE_PASSWORD", true, true, true, true, authorities);

        SecurityContextHolder.getContext().setAuthentication(
                new UsernamePasswordAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities));

        try {
View Full Code Here

      authorities.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
    }
    logger.debug(originalUser.getUsername());
    logger.debug(originalUser.getPassword());
    logger.debug(authorities.toString());
    User newUser = new User(originalUser.getUsername(), "password", authorities);

    return newUser;
  }
View Full Code Here

    com.lanyuan.entity.User users = userDao.querySingleUser(username);
    if  (users==null
            throw new UsernameNotFoundException(username+" not exist!")
    Collection<GrantedAuthority> grantedAuths = obtionGrantedAuthorities(users);
    // 封装成spring security的user
    User userdetail = new User(
        users.getUserName(),
        users.getUserPassword(),
        true,
        true,
        true,
View Full Code Here

  @EventBusListenerMethod(filter=StartupFilter.class)
  public void onStartup(Action action) {
    if (security.isAuthenticated()) {
      Authentication auth = security.getAuthentication();
      User user = (User) auth.getPrincipal();
      getView().setUser(user.getUsername());
    }
  }
View Full Code Here

    TodoService todoService;


  @RequestMapping(method = RequestMethod.DELETE, headers = "Accept=application/json")
  public ResponseEntity<String> deleteAllTodos(Authentication authentication) {
     User user=(User) authentication.getPrincipal();
     List<Todo> todos = todoService.findTodosByUserName(user.getUsername());
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/json");
    for (Todo todo : todos) {
      todo.setUserName(null);
      todoService.deleteTodo(todo);
View Full Code Here

  @RequestMapping(headers = "Accept=application/json")
    @ResponseBody
    public ResponseEntity<String> listJson(Authentication authentication) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json; charset=utf-8");
        User user=(User) authentication.getPrincipal();
        List<Todo> result = todoService.findTodosByUserName(user.getUsername());
        return new ResponseEntity<String>(Todo.toJsonArray(result), headers, HttpStatus.OK);
    }
View Full Code Here

    }

  @RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
    public ResponseEntity<String> createFromJson(@RequestBody String json,Authentication authentication) {
        Todo todo = Todo.fromJsonToTodo(json);
        User user=(User) authentication.getPrincipal();
        Userinfo userinfo=userService.findByUserName(user.getUsername()).get(0);
        todo.setUserName(userinfo);
        todoService.saveTodo(todo);
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        return new ResponseEntity<String>(headers, HttpStatus.CREATED);
View Full Code Here

    }

  @RequestMapping(value = "/{id}", method = RequestMethod.DELETE, headers = "Accept=application/json")
    public ResponseEntity<String> deleteFromJson(@PathVariable("id") Long id,Authentication authentication) {
       
        User user=(User) authentication.getPrincipal();
        Todo todo = todoService.findTodoByUserNameAndId(user.getUsername(),id);
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        if (todo == null) {
            return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
        }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.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.