Escolar Documentos
Profissional Documentos
Cultura Documentos
java.util.Arrays;
javax.faces.application.FacesMessage;
javax.faces.application.NavigationHandler;
javax.faces.context.FacesContext;
javax.faces.event.PhaseEvent;
javax.faces.event.PhaseId;
javax.faces.event.PhaseListener;
javax.persistence.criteria.CriteriaBuilder;
javax.servlet.http.HttpSession;
"/Dicionario/linhaExtensao.xhtml", "/Dicionario/meioDivulgacao.xhtml
", "/Dicionario/modalidade.xhtml", "/Dicionario/participacao.xhtml",
"/Dicionario/perfilAcesso.xhtml", "/Dicionario/pessoa.xhtml", "/prop
osta/lista-todas-acoes.xhtml" };
private String[] pageProreitor = {"/login.xhtml", "/proposta/acao.xhtml", "/
proposta/acaoModal.xhtml", "/proposta/index.xhtml",
"/proposta/avaliacao.xhtml", "/proposta/caracteristicas.xhtml", "/pr
oposta/caracterizacaoProposta.xhtml",
"/proposta/cronogramaExecucao.xhtml", "/proposta/divulgacao.xhtml",
"/proposta/identificacaoGeral.xhtml",
"/proposta/index.xhtml", "/proposta/infraEstrutura.xhtml", "/propost
a/Lista.xhtml",
"/proposta/MenuAcao.xhtml", "proposta/menuPrincipal.xhtml", "/propos
ta/minhasAcoes.xhtml",
"/proposta/modalCadEquipeExecutora.xhtml", "/proposta/objetivos.xhtm
l", "/proposta/orcamento.xhtml",
"/proposta/parceriaExterna.xhtml", "proposta/participante.xhtml", "/
proposta/programa.xhtml",
"/proposta/publicoAlvo.xhtml", "/proposta/transparenciaAcoes.xhtml"}
;
private String[] pageAuditor = {"/login.xhtml", "/proposta/minhasAcoes.xhtml
", "/proposta/acao.xhtml","/proposta/transparenciaAcoes.xhtml",
"/proposta/index.xhtml"};
@Override
public void afterPhase(PhaseEvent event) {
FacesContext facesContext = event.getFacesContext();
//String currentPage = facesContext.getViewRoot().getViewId().replace("/
", "");
String currentPage = facesContext.getViewRoot().getViewId();
boolean isLoginPage = ((currentPage.lastIndexOf("login.xhtml") > -1) ||
(currentPage.lastIndexOf("transparencia.xhtml") > -1));
final int ADMINISTRADOR = 1, PROPONENTE = 3, PARTICIPANTE = 5, PRO_REITO
R = 2, AUDITOR = 4;
// Verifica Autorizao da pgina solicitada ao perfil corrente
boolean permitirProponente = Arrays.asList(pageProponente).contains(curr
entPage);
boolean permitirAdministrador = Arrays.asList(pageAdministrador).contain
s(currentPage);
boolean permitirParticipante = Arrays.asList(pageParticipante).contains(
currentPage);
boolean permitirProreitor = Arrays.asList(pageProreitor).contains(curren
tPage);
boolean permitirAuditor = Arrays.asList(pageAuditor).contains(currentPag
e);
//Verifica se h sesso aberta
HttpSession session = (HttpSession) facesContext.getExternalContext().ge
tSession(true);
//Caso haja sesso corrente recupera o objeto 'usurio' da sesso
Object currentUser = session.getAttribute("user");
Object perfilUsuario = session.getAttribute("perfilAcesso");
System.out.println("TESTE "+currentUser+ " "+perfilUsuario);
Pessoa p = (Pessoa) currentUser;