package com.rms.tfc.util;

import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContext;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.userdetails.User;

public class SessionUtil {

	public static String getUserSession(){
		SecurityContext sc = (SecurityContext) SecurityContextHolder.getContext();
		String usuarioSession = "";
		if (sc != null){
			Authentication auth = sc.getAuthentication();
			User usuario = (User) auth.getPrincipal();
			usuarioSession = usuario.getUsername();
		}
		return usuarioSession;
	}
}