1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.permission;
|
10
|
|
11
|
import java.io.Serializable;
|
12
|
|
13
|
import org.apache.logging.log4j.LogManager;
|
14
|
import org.apache.logging.log4j.Logger;
|
15
|
|
16
|
import com.vaadin.navigator.View;
|
17
|
import com.vaadin.spring.access.ViewInstanceAccessControl;
|
18
|
import com.vaadin.ui.UI;
|
19
|
|
20
|
/**
|
21
|
* Denies, allows access to view by evaluating the {@link AccessRestrictedView#isAccessDenied()} flag.
|
22
|
*
|
23
|
* @author a.kohlbecker
|
24
|
*/
|
25
|
public class AccessRestrictedViewControlBean implements ViewInstanceAccessControl, Serializable {
|
26
|
|
27
|
private static final long serialVersionUID = -5192116600545639108L;
|
28
|
|
29
|
private final static Logger logger = LogManager.getLogger();
|
30
|
|
31
|
@Override
|
32
|
public boolean isAccessGranted(UI ui, String beanName, View view) {
|
33
|
|
34
|
if(AccessRestrictedView.class.isAssignableFrom(view.getClass())){
|
35
|
AccessRestrictedView restricedView = (AccessRestrictedView)view;
|
36
|
if(logger.isDebugEnabled()){
|
37
|
logger.debug("Access to view " + view.getClass().getSimpleName() + (restricedView.isAccessDenied() ? " denied": " allowed"));
|
38
|
}
|
39
|
return !restricedView.isAccessDenied();
|
40
|
}
|
41
|
logger.debug("allowing view by fall through, no check performed");
|
42
|
return true;
|
43
|
}
|
44
|
}
|