Correct use of Appfoundation Addon


I’m trying to use the Authorization module from the AppFoundation Addon. My Problem is, that I don’t know how to use it correctly. This Wiki article helped me to a lot to understand how it works.

I’m trying to explain my problem with the following scenario.

I have an Application where I initialize the module:

public class MyVaadinApplication extends Application {

	public void init() {
		LoginWindow loginWindow = new LoginWindow();
		Permissions.initialize(this, new MemoryPermissionManager());
		Role visitors = new Visitor();
		Resource ress = new Ress();

		Permissions.allow(visitors, "read", test);


The LoginWindow shows a simple form with username and password Textfields. After logging in, the user see one Button. If the user clicks, it should check the permission and do anything. The listener looks like this

ButtonCheck.addListener(new ClickListener() {

			public void buttonClick(ClickEvent event) {
				if (Permissions.hasAccess(user, "read", ress)) {
			             // do anything

But I cannot access the Resource at this point. How I handle this? Should I create a Resource Object every time I want to check the permission?

Furthermore, in the above mentioned Wiki article is this example:

if(Permissions.hasAccess(usersRoles, "read", newsFeedView)) {

But how can I add a Resource to a layout?. My Resource looks like this:

public class Ress extends CustomComponent implements Resource{

	private final String id;
	public Ress(){
		 id = UUID.randomUUID().toString();
	public String getIdentifier() {
		return id;


Thanks in advance