Package com.logigear.spring.mvc.security.models

Examples of com.logigear.spring.mvc.security.models.UserInfo


    private IMovieService moviesService;

    @RequestMapping(method = RequestMethod.GET, value = "/{id}")
    @ResponseBody
    public String loadMovie(@PathVariable int id) {
        UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        int count = userInfo.getAuthorities().size();
        SimpleGrantedAuthority[] authorities = new SimpleGrantedAuthority[count];
        userInfo.getAuthorities().toArray(authorities);
        Movie movie = moviesService.loadMovie(id);
        return "You are watching movie <b>" + movie.getMovieName() + "</b> - [logged in as <b>" + userInfo.getUsername() + ", " + userInfo.getLastName() + "</b>]";
    }
View Full Code Here


public class AdminController /*implements IAdminController*/ {

    //@Override
    @RequestMapping(method = RequestMethod.GET, value = { "", "/index" })   
    public ModelAndView index() {
  UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
 
  ModelAndView model = new ModelAndView();
  model.addObject("title", "Administrator Dashboard");
  model.addObject("message", "Welcome to admin page!")
  model.addObject("userName", userInfo.getUsername() + ", " + userInfo.getLastName());
 
  model.setViewName("admin");
  return model;
    }
View Full Code Here

    public CustomWebSecurityExpressionRoot(Authentication a, FilterInvocation fi) {
  super(a, fi);
    }

    public boolean isOver18() {
  UserInfo user = (UserInfo) this.getPrincipal();
  return user.getAge() > 18;
    }
View Full Code Here

    @Override
    public UserDetails loadUserByUsername(String username)
      throws UsernameNotFoundException {

  UserInfo user = users.get(username.toLowerCase());

  if (user == null) {
      throw new UsernameNotFoundException(username);
  }

  UserInfo newUser = new UserInfo(user.getUsername(), user.getPassword(),
    user.getAuthorities(), user.getLastName(), user.getAge());

  return newUser;
    }
View Full Code Here

    public CustomMethodSecurityExpressionRoot(Authentication authentication, MethodInvocation invocation) {
        super(authentication, invocation);
    }

    public boolean isOver18(Movie movie) {
        UserInfo user = (UserInfo) this.getAuthentication().getPrincipal();
        if (movie.getMovieType() == MovieType.Adult18plus) {
            return user.getAge() > 18;
        }

        return true;
    }
View Full Code Here

public class AdminController {

    @RequestMapping(method = RequestMethod.GET, value = { "", "/index" })
    @ResponseBody
    public ModelAndView index() {
  UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
 
  ModelAndView model = new ModelAndView();
  model.addObject("title", "Administrator Dashboard");
  model.addObject("message", "Welcome to admin page!")
  model.addObject("userName", userInfo.getUsername() + ", " + userInfo.getLastName());
 
  model.setViewName("admin");
  return model;
    }
View Full Code Here

    @Override
    public UserDetails loadUserByUsername(String username)
      throws UsernameNotFoundException {

  UserInfo user = users.get(username.toLowerCase());

  if (user == null) {
      throw new UsernameNotFoundException(username);
  }

  UserInfo newUser = new UserInfo(user.getUsername(), user.getPassword(),
    user.getAuthorities(), user.getLastName());

  return newUser;
    }
View Full Code Here

TOP

Related Classes of com.logigear.spring.mvc.security.models.UserInfo

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.