private void checkLoginLogout(HttpServletRequest request) {
    		Principal user = request.getUserPrincipal();

    		mainWindow.removeAllComponents();
    		
    		mainWindow.addComponent(authInfo);
    		
    		if (authInfo.getComponentIterator().hasNext()
    				&& ((user != null && getUser() != null) || (user == null && getUser() == null))) {
    			return; // Layout initialized, and no login/logout detected
    		}

    		UserService userService = UserServiceFactory.getUserService();

    		Link link;
    		Label email;
    		if (request.getUserPrincipal() != null) {
    			// Login detected, store user email to application
    			setUser(request.getUserPrincipal().getName());

    			
    			usuarioLogado = userService.getCurrentUser();  
    			// TODO : esse usuarioLogado pode ser setado no setUser mais acima.
    			// O vaadin tem esse setuser que vc seta o usuario geral da aplicacao.
    			
    			
    			if (userService.isUserAdmin()) {
    				mainWindow.showNotification("You have admin privileges");
    			}

    			//mainWindow.showNotification("Hello " + request.getUserPrincipal().getName());

    			showMsg("Bem vindo " + request.getUserPrincipal().getName());
    			
    			email = new Label(request.getUserPrincipal().getName());
    			link = new Link("Logout", new ExternalResource(userService
    					.createLogoutURL("/")));
    		} else {
    			// Logout detected, or application initialized without login info
    			if (getUser() != null) {
    				//mainWindow.showNotification("Bye " + getUser().toString());
    				showMsg("Saiu " + getUser().toString());
    			}

    			setUser(null);

    			email = new Label("Usuario nao logado - ");
    			link = new Link(" Clique aqui para fazer o login", 
    					new ExternalResource(userService.createLoginURL("/")));
    		}

    		authInfo.removeAllComponents();

    		email.setStyleName("email");
    		authInfo.addComponent(email);

    		authInfo.addComponent(link);    		
    	}