// Path: src/main/java/org/vaadin/spring/sample/security/ui/security/AccessDeniedEvent.java
// @SuppressWarnings("serial")
// public class AccessDeniedEvent implements Serializable {
// 	
// 	private final Throwable cause;
// 	private final String viewToken;
// 			
// 	public AccessDeniedEvent(Throwable cause, String viewToken) {
// 		this.cause = cause;
// 		this.viewToken = viewToken;
// 	}
// 	
// 	public AccessDeniedEvent(Throwable cause) {
// 		this(cause, null);		
// 	}
// 	
// 	public AccessDeniedEvent(String viewToken) {
// 		this(null, viewToken);		
// 	}
// 	
// 	public AccessDeniedEvent() {
// 		this(null, null);
// 	}
// 	
// 	public Throwable getCause() {
// 		return cause;
// 	}
// 	
// 	public String getViewToken() {
// 		return viewToken;
// 	}
// 
// }


import java.util.UUID;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.vaadin.spring.UIScope;
import org.vaadin.spring.VaadinComponent;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBusListenerMethod;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.mvp.MvpPresenterView;
import org.vaadin.spring.navigator.SpringViewProvider;
import org.vaadin.spring.sample.security.ui.security.AccessDeniedEvent;
import org.vaadin.spring.security.Security;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.navigator.ViewDisplay;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.themes.ValoTheme;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
					btn.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
				}
			}
		}
						
	}
	
	private void displayAnonymousNavbar() {
		btnAdminHidden.setVisible(false);
		btnLogout.setVisible(false);
		btnSignIn.setVisible(true);
		btnSignUp.setVisible(true);		
	}
	
	private void displayUserNavbar() {
		btnAdminHidden.setVisible(false);
		btnLogout.setVisible(true);
		btnSignIn.setVisible(false);
		btnSignUp.setVisible(false);
	}
	
	private void displayAdminNavbar() {
		btnAdminHidden.setVisible(true);
		btnLogout.setVisible(true);
		btnSignIn.setVisible(false);
		btnSignUp.setVisible(false);
	}
	
	
	@EventBusListenerMethod
// Path: src/main/java/org/vaadin/spring/sample/security/ui/security/AccessDeniedEvent.java
// @SuppressWarnings("serial")
// public class AccessDeniedEvent implements Serializable {
// 	
// 	private final Throwable cause;
// 	private final String viewToken;
// 			
// 	public AccessDeniedEvent(Throwable cause, String viewToken) {
// 		this.cause = cause;
// 		this.viewToken = viewToken;
// 	}
// 	
// 	public AccessDeniedEvent(Throwable cause) {
// 		this(cause, null);		
// 	}
// 	
// 	public AccessDeniedEvent(String viewToken) {
// 		this(null, viewToken);		
// 	}
// 	
// 	public AccessDeniedEvent() {
// 		this(null, null);
// 	}
// 	
// 	public Throwable getCause() {
// 		return cause;
// 	}
// 	
// 	public String getViewToken() {
// 		return viewToken;
// 	}
// 
// }


// Path: src/main/java/org/vaadin/spring/sample/security/ui/MainLayout.java
import java.util.UUID;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.vaadin.spring.UIScope;
import org.vaadin.spring.VaadinComponent;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBusListenerMethod;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.mvp.MvpPresenterView;
import org.vaadin.spring.navigator.SpringViewProvider;
import org.vaadin.spring.sample.security.ui.security.AccessDeniedEvent;
import org.vaadin.spring.security.Security;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.navigator.ViewDisplay;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.themes.ValoTheme;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

					btn.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
				}
			}
		}
						
	}
	
	private void displayAnonymousNavbar() {
		btnAdminHidden.setVisible(false);
		btnLogout.setVisible(false);
		btnSignIn.setVisible(true);
		btnSignUp.setVisible(true);		
	}
	
	private void displayUserNavbar() {
		btnAdminHidden.setVisible(false);
		btnLogout.setVisible(true);
		btnSignIn.setVisible(false);
		btnSignUp.setVisible(false);
	}
	
	private void displayAdminNavbar() {
		btnAdminHidden.setVisible(true);
		btnLogout.setVisible(true);
		btnSignIn.setVisible(false);
		btnSignUp.setVisible(false);
	}
	
	
	@EventBusListenerMethod
	public void onAccessDenied(org.vaadin.spring.events.Event<AccessDeniedEvent> event) {