package com.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.config.annotation.web.configurers.FormLoginConfigurer;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import common.spring.AvoidDuplicateSubmission;

@Controller
@RequestMapping("/")
public class IndexController {

	public IndexController() {
		// TODO Auto-generated constructor stub
	}
	
	private boolean isAuthenticated() {
		SecurityContext securityContext = SecurityContextHolder.getContext();
		Authentication authentication = securityContext.getAuthentication();
		boolean isAuthenticated = !(authentication instanceof AnonymousAuthenticationToken)
				&& authentication.isAuthenticated();
		return isAuthenticated;
	}
	
	@RequestMapping(value="/",method=RequestMethod.GET/*, method = RequestMethod.POST*/)
    public ModelAndView getAll(HttpServletRequest request,HttpServletResponse response 
    		, RedirectAttributes redirectAttributes){
		ModelAndView model = new ModelAndView("index");

        return model;
    }

}

@@ -537,24 +537,91 @@
 extHolder;%0D%0A
+import org.springframework.security.core.userdetails.UserDetails;%0D%0A
 import org.s
@@ -1212,16 +1212,388 @@
 %0A%09%7D%0D%0A%09%0D%0A
+%09private UserDetails getUserDetails()%7B%0D%0A%09%09UserDetails ret = null;%0D%0A%09%09// check if user is login%0D%0A%09%09Authentication auth = SecurityContextHolder.getContext().getAuthentication();%0D%0A%09%09if (!(auth instanceof AnonymousAuthenticationToken)) %7B%0D%0A%09%09%09ret = (UserDetails) auth.getPrincipal();%0D%0A%09%09%09%0D%0A%09%09%7D%0D%0A%09%09//model.addObject(%22username%22, userDetail.getUsername());%0D%0A%09%09return ret;%0D%0A%09%7D%0D%0A%09%0D%0A
 %09private

add getUserDetails method