package com.ejie.ab61.comun;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

public abstract class SeguridadAplicacion {

	/**
	 * 
	 */
	public static String ROLE_ADMINISTRADOR = "ROLE_AB61-IN-0001";
	public static String ROLE_AB61_IN_0008 = "ROLE_AB61-IN-0008";
	public static String ROLE_RESPONSABLE_TURISMO = "ROLE_AB61-IN-0002";
	public static String ROLE_TECNICO_TURISMO = "ROLE_AB61-IN-0003";
	public static String ROLE_RESPONSABLE_COMERCIO = "ROLE_AB61-IN-0004";
	public static String ROLE_TECNICO_COMERCIO = "ROLE_AB61-IN-0005";
	public static String ROLE_RESPONSABLE_CONSUMO = "ROLE_AB61-IN-0006";
	public static String ROLE_TECNICO_CONSUMO = "ROLE_AB61-IN-0007";

	/**
	 * 
	 */
	private static final long serialVersionUID = 7601398309596598460L;

	public SeguridadAplicacion() {

	}

	/**
	 * 
	 * @param authentication
	 *            org.springframework.security.core.Authentication
	 * @return Vector<String> con los roles del usuario
	 */
	public static Vector<String> getRolesUsuario(Authentication authentication) {
		List<GrantedAuthority> list = new ArrayList<GrantedAuthority>(authentication.getAuthorities());
		Vector<String> vecPermisos = new Vector<String>();

		for (GrantedAuthority grantedAuthority : list) {
			vecPermisos.add(grantedAuthority.getAuthority());
		}

		return vecPermisos;
	}
}
